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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

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