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

Subversion Repositories openrisc

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

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
/* The last dimension of VEL escapes because it was sent
14
   as argumet to just_a_call(). (external function)
15
   Only the two external dimensions are flattened.
16
   Run with -c.  */
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
      free (vel[i][j]);
46
 
47
  for (i = 0; i < ARCHnodes; i++)
48
    free (vel[i]);
49
 
50
  free (vel);
51
  return 0;
52
}
53
 
54
/*--------------------------------------------------------------------------*/
55
/* Dynamic memory allocations and initializations                           */
56
 
57
void
58
mem_init (void)
59
{
60
 
61
  int i, j, k,d;
62
 
63
  d = 0;
64
  vel = (int ***) malloc (ARCHnodes * sizeof (int **));
65
 
66
  for (i = 0; i < ARCHnodes; i++)
67
    {
68
      vel[i] = (int **) malloc (3 * sizeof (int *));
69
      if (vel[i] == (int **) NULL)
70
        {
71
          fprintf (stderr, "malloc failed for vel[%d]\n", i);
72
          fflush (stderr);
73
          exit (0);
74
        }
75
    }
76
  for (i = 0; i < ARCHnodes; i++)
77
    {
78
      for (j = 0; j < 3; j++)
79
        {
80
          vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
81
        }
82
    }
83
  for (i = 0; i < ARCHnodes; i++)
84
    {
85
      for (j = 0; j < 3; j++)
86
        {
87
          for (k = 0; k < ARCHnodes1; k++)
88
            {
89
              vel[i][j][k] = d;
90
              d++;
91
            }
92
        }
93
    }
94
  just_a_call (vel[1][1]);
95
}
96
 
97
/*--------------------------------------------------------------------------*/
98
/* { dg-final { scan-ipa-dump-times "Flattened 2 dimensions" 1 "matrix-reorg"  } } */
99
/* { 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.