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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [matrix/] [transpose-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
#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
/* The inner most dimension escapes.
10
   The two external dimensions are flattened
11
   after being 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 < 4; j++)
27
    {
28
      for (i = 0; i < 3; i++)
29
        {
30
          for (k = 0; k < 2; k++)
31
           {
32
            printf ("[%d][%d][%d]=%d ", i, j, k, vel[k][i][j]);
33
           }
34
          printf ("\n");
35
        }
36
      printf ("\n");
37
    }
38
  vel[0][0]=vel[1][1];
39
 
40
  for (i = 0; i < 2; i++)
41
    for (j = 0; j < 3; j++)
42
      if (i==1 && j==1)
43
        continue;
44
      else
45
        free (vel[i][j]);
46
 
47
  for (i = 0; i < 2; 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
  signed 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
              printf ("acc to dim2 ");
90
              vel[i][j][k] = d;
91
              d++;
92
            }
93
        }
94
    }
95
  printf ("\n");
96
}
97
 
98
/*--------------------------------------------------------------------------*/
99
/* { dg-final-use { scan-ipa-dump-times "Flattened 2 dimensions" 1 "matrix-reorg"  } } */
100
/* { dg-final-use { scan-ipa-dump-times "Transposed" 2 "matrix-reorg"  } } */
101
/* { 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.