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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [matrix/] [transpose-1.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
#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
   All dimensions are transposed : dim 0 -> dim 2
12
                                   dim 1 -> dim 0
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 (i = 0; i < 3; i++)
30
    {
31
      for (j = 0; j < 4; j++)
32
        {
33
          for (k = 0; k < 2; k++)
34
        {
35
            printf ("[%d][%d][%d]=%d ", i, j, k, vel[k][i][j]);
36
        }
37
          printf ("\n");
38
        }
39
      printf ("\n");
40
    }
41
  for (i = 0; i < ARCHnodes; i++)
42
    for (j = 0; j < 3; j++)
43
      free (vel[i][j]);
44
 
45
  for (i = 0; i < ARCHnodes; 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
  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
              vel[i][j][k] = d;
88
              d++;
89
            }
90
        }
91
    }
92
}
93
 
94
/*--------------------------------------------------------------------------*/
95
/* { dg-final-use { scan-ipa-dump-times "Flattened 3 dimensions" 1 "matrix-reorg"  } } */
96
/* { dg-final-use { scan-ipa-dump-times "Transposed" 3 "matrix-reorg"  } } */
97
/* { dg-final-use { cleanup-ipa-dump "matrix-reorg" } } */
98
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.