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/] [transpose-2.c] - Blame information for rev 826

Details | Compare with Previous | View Log

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