OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [matrix/] [matrix-4.c] - Blame information for rev 713

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do compile } */
2
 
3
#include <stdio.h>
4
#include <stdlib.h>
5
#include <math.h>
6
#include <string.h>
7
 
8
void mem_init (void);
9
int ARCHnodes, ARCHnodes1;
10
int ***vel;
11
void just_a_call (int ****);
12
 
13
/* Address of VEL is taken.
14
   It is not flattened.  */
15
 
16
 
17
/*--------------------------------------------------------------------------*/
18
 
19
int
20
main (int argc, char **argv)
21
{
22
  int i, j, k;
23
 
24
  ARCHnodes = 2;
25
  ARCHnodes1 = 4;
26
 
27
/* Dynamic memory allocations and initializations */
28
 
29
  mem_init ();
30
 
31
  for (i = 0; i < ARCHnodes; i++)
32
    {
33
      for (j = 0; j < 3; j++)
34
        {
35
          for (k = 0; k < ARCHnodes1; k++)
36
            printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]);
37
          printf ("\n");
38
        }
39
      printf ("\n");
40
    }
41
  for (i = 0; i < ARCHnodes; i++)
42
    for (j = 0; j < 3; j++)
43
      free (vel[i][j]);
44
 
45
  for (i = 0; i < ARCHnodes; i++)
46
    free (vel[i]);
47
 
48
  free (vel);
49
  return 0;
50
}
51
 
52
/*--------------------------------------------------------------------------*/
53
/* Dynamic memory allocations and initializations                           */
54
 
55
void
56
mem_init (void)
57
{
58
 
59
  int i, j, k,d;
60
 
61
  d = 0;
62
  vel = (int ***) malloc (ARCHnodes * sizeof (int **));
63
 
64
  for (i = 0; i < ARCHnodes; i++)
65
    {
66
      vel[i] = (int **) malloc (3 * sizeof (int *));
67
      if (vel[i] == (int **) NULL)
68
        {
69
          fprintf (stderr, "malloc failed for vel[%d]\n", i);
70
          fflush (stderr);
71
          exit (0);
72
        }
73
    }
74
  for (i = 0; i < ARCHnodes; i++)
75
    {
76
      for (j = 0; j < 3; j++)
77
        {
78
          vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
79
        }
80
    }
81
  for (i = 0; i < ARCHnodes; i++)
82
    {
83
      for (j = 0; j < 3; j++)
84
        {
85
          for (k = 0; k < ARCHnodes1; k++)
86
            {
87
              vel[i][j][k] = d;
88
              d++;
89
            }
90
        }
91
    }
92
  just_a_call (&vel);
93
}
94
 
95
/*--------------------------------------------------------------------------*/
96
/* { dg-final { scan-ipa-dump-times "Flattened" 0 "matrix-reorg"  } } */
97
/* { dg-final { cleanup-ipa-dump "matrix-reorg" } } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.