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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [matrix/] [matrix-1.c] - Blame information for rev 298

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

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