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-4.c] - Blame information for rev 826

Details | Compare with Previous | View Log

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