OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [matrix/] [matrix-2.c] - Blame information for rev 300

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
 
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 last dimension of VEL escapes because of
15
   the assignment : vel[1][1] =...
16
   Only the two external dimensions are flattened.  */
17
 
18
 
19
/*--------------------------------------------------------------------------*/
20
 
21
int
22
main (int argc, char **argv)
23
{
24
  int i, j, k;
25
 
26
  ARCHnodes = 2;
27
  ARCHnodes1 = 4;
28
 
29
/* Dynamic memory allocations and initializations */
30
 
31
  mem_init ();
32
 
33
  for (i = 0; i < ARCHnodes; i++)
34
    {
35
      for (j = 0; j < 3; j++)
36
        {
37
          for (k = 0; k < ARCHnodes1; k++)
38
            printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]);
39
          printf ("\n");
40
        }
41
      printf ("\n");
42
    }
43
  for (i = 0; i < ARCHnodes; i++)
44
    for (j = 0; j < 3; j++)
45
      printf ("%x\n",vel[i][j]);
46
      /*if (i!=1 || j!=1)*/
47
      /*if (i==1 && j==1)
48
        continue;
49
      else
50
        free (vel[i][j]);*/
51
 
52
  for (i = 0; i < ARCHnodes; i++)
53
    free (vel[i]);
54
 
55
  free (vel);
56
  return 0;
57
}
58
 
59
/*--------------------------------------------------------------------------*/
60
/* Dynamic memory allocations and initializations                           */
61
 
62
void
63
mem_init (void)
64
{
65
 
66
  int i, j, k,d;
67
 
68
  d = 0;
69
  vel = (int ***) malloc (ARCHnodes * sizeof (int **));
70
 
71
  for (i = 0; i < ARCHnodes; i++)
72
    {
73
      vel[i] = (int **) malloc (3 * sizeof (int *));
74
      if (vel[i] == (int **) NULL)
75
        {
76
          fprintf (stderr, "malloc failed for vel[%d]\n", i);
77
          fflush (stderr);
78
          exit (0);
79
        }
80
    }
81
  for (i = 0; i < ARCHnodes; i++)
82
    {
83
      for (j = 0; j < 3; j++)
84
        {
85
          vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
86
          printf ("%x %d %d\n",vel[i][j], ARCHnodes1, sizeof (int));
87
        }
88
    }
89
   for (i = 0; i < ARCHnodes; i++)
90
    {
91
      for (j = 0; j < 3; j++)
92
        {
93
          printf ("%x\n",vel[i][j]);
94
        }
95
    }
96
 
97
  printf ("again:\n\n");
98
  for (i = 0; i < ARCHnodes; i++)
99
    {
100
      for (j = 0; j < 3; j++)
101
        {
102
          printf ("%x\n",vel[i][j]);
103
          /*for (k = 0; k < ARCHnodes1; k++)
104
            {
105
              vel[i][j][k] = d;
106
              d++;
107
            }*/
108
        }
109
    }
110
  /*vel[1][1] = vel[0][1];*/
111
}
112
 
113
/*--------------------------------------------------------------------------*/
114
/* { dg-final { scan-ipa-dump-times "Flattened 2 dimensions" 1 "matrix-reorg"  } } */
115
/* { 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.