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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [matrix/] [transpose-6.c] - Blame information for rev 858

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