matrix: New directory.

2007-05-28  Razya Ladelsky  <razya@il.ibm.com>

        * gcc.dg/matrix: New directory.

From-SVN: r125128
This commit is contained in:
Razya Ladelsky 2007-05-28 11:27:34 +00:00
parent 138e99d1a0
commit ae5dd5f579
13 changed files with 1252 additions and 0 deletions

View File

@ -0,0 +1,92 @@
/* { dg-do compile } */
/* { dg-do run } */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void mem_init (void);
int ARCHnodes, ARCHnodes1;
int ***vel;
/* The whole matrix VEL is flattened (3 dimensions). */
/*--------------------------------------------------------------------------*/
int
main (int argc, char **argv)
{
int i, j, k, id;
ARCHnodes = 2;
ARCHnodes1 = 4;
/* Dynamic memory allocations and initializations */
mem_init ();
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]);
printf ("\n");
}
printf ("\n");
}
for (i = 0; i < ARCHnodes; i++)
for (j = 0; j < 3; j++)
free (vel[i][j]);
for (i = 0; i < ARCHnodes; i++)
free (vel[i]);
free (vel);
return 0;
}
/*--------------------------------------------------------------------------*/
/* Dynamic memory allocations and initializations */
void
mem_init (void)
{
int i, j, k,d;
d = 0;
vel = (int ***) malloc (ARCHnodes * sizeof (int **));
for (i = 0; i < ARCHnodes; i++)
{
vel[i] = (int **) malloc (3 * sizeof (int *));
if (vel[i] == (int **) NULL)
{
fprintf (stderr, "malloc failed for vel[%d]\n", i);
fflush (stderr);
exit (0);
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
{
vel[i][j][k] = d;
d++;
}
}
}
}
/*--------------------------------------------------------------------------*/
/* { dg-final { scan-ipa-dump-times "Flattened 3 dimensions" 1 "matrix-reorg" } } */
/* { dg-final { cleanup-ipa-dump "matrix-reorg" } } */

View File

@ -0,0 +1,115 @@
/* { dg-do compile } */
/* { dg-do run } */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void mem_init (void);
int ARCHnodes, ARCHnodes1;
int ***vel;
/* The last dimension of VEL escapes because of
the assignment : vel[1][1] =...
Only the two external dimensions are flattened. */
/*--------------------------------------------------------------------------*/
int
main (int argc, char **argv)
{
int i, j, k;
ARCHnodes = 2;
ARCHnodes1 = 4;
/* Dynamic memory allocations and initializations */
mem_init ();
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]);
printf ("\n");
}
printf ("\n");
}
for (i = 0; i < ARCHnodes; i++)
for (j = 0; j < 3; j++)
printf ("%x\n",vel[i][j]);
/*if (i!=1 || j!=1)*/
/*if (i==1 && j==1)
continue;
else
free (vel[i][j]);*/
for (i = 0; i < ARCHnodes; i++)
free (vel[i]);
free (vel);
return 0;
}
/*--------------------------------------------------------------------------*/
/* Dynamic memory allocations and initializations */
void
mem_init (void)
{
int i, j, k,d;
d = 0;
vel = (int ***) malloc (ARCHnodes * sizeof (int **));
for (i = 0; i < ARCHnodes; i++)
{
vel[i] = (int **) malloc (3 * sizeof (int *));
if (vel[i] == (int **) NULL)
{
fprintf (stderr, "malloc failed for vel[%d]\n", i);
fflush (stderr);
exit (0);
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
printf ("%x %d %d\n",vel[i][j], ARCHnodes1, sizeof (int));
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
printf ("%x\n",vel[i][j]);
}
}
printf ("again:\n\n");
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
printf ("%x\n",vel[i][j]);
/*for (k = 0; k < ARCHnodes1; k++)
{
vel[i][j][k] = d;
d++;
}*/
}
}
/*vel[1][1] = vel[0][1];*/
}
/*--------------------------------------------------------------------------*/
/* { dg-final { scan-ipa-dump-times "Flattened 2 dimensions" 1 "matrix-reorg" } } */
/* { dg-final { cleanup-ipa-dump "matrix-reorg" } } */

View File

@ -0,0 +1,101 @@
/* { dg-do compile } */
/* { dg-options "-O3 -fipa-matrix-reorg -fdump-ipa-matrix-reorg -c -fwhole-program -combine" } */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void mem_init (void);
int ARCHnodes, ARCHnodes1;
int ***vel;
void just_a_call (int *);
/* The last dimension of VEL escapes because it was sent
as argumet to just_a_call(). (external function)
Only the two external dimensions are flattened.
Run with -c. */
/*--------------------------------------------------------------------------*/
int
main (int argc, char **argv)
{
int i, j, k;
ARCHnodes = 2;
ARCHnodes1 = 4;
/* Dynamic memory allocations and initializations */
mem_init ();
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]);
printf ("\n");
}
printf ("\n");
}
for (i = 0; i < ARCHnodes; i++)
for (j = 0; j < 3; j++)
free (vel[i][j]);
for (i = 0; i < ARCHnodes; i++)
free (vel[i]);
free (vel);
return 0;
}
/*--------------------------------------------------------------------------*/
/* Dynamic memory allocations and initializations */
void
mem_init (void)
{
int i, j, k,d;
d = 0;
vel = (int ***) malloc (ARCHnodes * sizeof (int **));
for (i = 0; i < ARCHnodes; i++)
{
vel[i] = (int **) malloc (3 * sizeof (int *));
if (vel[i] == (int **) NULL)
{
fprintf (stderr, "malloc failed for vel[%d]\n", i);
fflush (stderr);
exit (0);
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
{
vel[i][j][k] = d;
d++;
}
}
}
just_a_call (vel[1][1]);
}
/*--------------------------------------------------------------------------*/
/* { dg-final { scan-ipa-dump-times "Flattened 2 dimensions" 1 "matrix-reorg" } } */
/* { dg-final { cleanup-ipa-dump "matrix-reorg" } } */

View File

@ -0,0 +1,99 @@
/* { dg-do compile } */
/* { dg-options "-O3 -fipa-matrix-reorg -fdump-ipa-matrix-reorg -c -fwhole-program -combine" } */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void mem_init (void);
int ARCHnodes, ARCHnodes1;
int ***vel;
void just_a_call (int ****);
/* Address of VEL is taken.
It is not flattened. */
/*--------------------------------------------------------------------------*/
int
main (int argc, char **argv)
{
int i, j, k;
ARCHnodes = 2;
ARCHnodes1 = 4;
/* Dynamic memory allocations and initializations */
mem_init ();
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]);
printf ("\n");
}
printf ("\n");
}
for (i = 0; i < ARCHnodes; i++)
for (j = 0; j < 3; j++)
free (vel[i][j]);
for (i = 0; i < ARCHnodes; i++)
free (vel[i]);
free (vel);
return 0;
}
/*--------------------------------------------------------------------------*/
/* Dynamic memory allocations and initializations */
void
mem_init (void)
{
int i, j, k,d;
d = 0;
vel = (int ***) malloc (ARCHnodes * sizeof (int **));
for (i = 0; i < ARCHnodes; i++)
{
vel[i] = (int **) malloc (3 * sizeof (int *));
if (vel[i] == (int **) NULL)
{
fprintf (stderr, "malloc failed for vel[%d]\n", i);
fflush (stderr);
exit (0);
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
{
vel[i][j][k] = d;
d++;
}
}
}
just_a_call (&vel);
}
/*--------------------------------------------------------------------------*/
/* { dg-final { scan-ipa-dump-times "Flattened" 0 "matrix-reorg" } } */
/* { dg-final { cleanup-ipa-dump "matrix-reorg" } } */

View File

@ -0,0 +1,98 @@
/* { dg-do compile } */
/* { dg-do run } */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void mem_init (void);
int ARCHnodes, ARCHnodes1;
int ***vel;
/* The two inner dimesions of matrix escape because of the
assignment vel[1]= ...
VEL is not Flattened. */
/*--------------------------------------------------------------------------*/
int
main (int argc, char **argv)
{
int i, j, k;
ARCHnodes = 2;
ARCHnodes1 = 4;
/* Dynamic memory allocations and initializations */
mem_init ();
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]);
printf ("\n");
}
printf ("\n");
}
for (i = 0; i < ARCHnodes-1; i++)
for (j = 0; j < 3; j++)
free (vel[i][j]);
for (i = 0; i < ARCHnodes-1; i++)
free (vel[i]);
free (vel);
return 0;
}
/*--------------------------------------------------------------------------*/
/* Dynamic memory allocations and initializations */
void
mem_init (void)
{
int i, j, k,d;
d = 0;
vel = (int ***) malloc (ARCHnodes * sizeof (int **));
for (i = 0; i < ARCHnodes; i++)
{
vel[i] = (int **) malloc (3 * sizeof (int *));
if (vel[i] == (int **) NULL)
{
fprintf (stderr, "malloc failed for vel[%d]\n", i);
fflush (stderr);
exit (0);
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
{
vel[i][j][k] = d;
d++;
}
}
}
vel[1] = vel[0];
}
/*--------------------------------------------------------------------------*/
/* { dg-final { scan-ipa-dump-times "Flattened" 0 "matrix-reorg" } } */
/* { dg-final { cleanup-ipa-dump "matrix-reorg" } } */

View File

@ -0,0 +1,97 @@
/* { dg-do compile } */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void mem_init (void);
int ARCHnodes, ARCHnodes1;
int ***vel;
/* The last dimension of VEL escapes because of
the assignment : *vel[1] =...
Only the two external dimensions are flattened. */
/*--------------------------------------------------------------------------*/
int
main (int argc, char **argv)
{
int i, j, k;
ARCHnodes = 2;
ARCHnodes1 = 4;
/* Dynamic memory allocations and initializations */
mem_init ();
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]);
printf ("\n");
}
printf ("\n");
}
for (i = 0; i < ARCHnodes; i++)
for (j = 0; j < 3; j++)
free (vel[i][j]);
for (i = 0; i < ARCHnodes; i++)
free (vel[i]);
free (vel);
return 0;
}
/*--------------------------------------------------------------------------*/
/* Dynamic memory allocations and initializations */
void
mem_init (void)
{
int i, j, k,d;
d = 0;
vel = (int ***) malloc (ARCHnodes * sizeof (int **));
for (i = 0; i < ARCHnodes; i++)
{
vel[i] = (int **) malloc (3 * sizeof (int *));
if (vel[i] == (int **) NULL)
{
fprintf (stderr, "malloc failed for vel[%d]\n", i);
fflush (stderr);
exit (0);
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
{
vel[i][j][k] = d;
d++;
}
}
}
*vel[1] = (int *)d;
}
/*--------------------------------------------------------------------------*/
/* { dg-final { scan-ipa-dump-times "Flattened 2 dimensions" 1 "matrix-reorg" } } */
/* { dg-final { cleanup-ipa-dump "matrix-reorg" } } */

View File

@ -0,0 +1,64 @@
# Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Test the functionality of programs compiled with profile-directed block
# ordering using -fprofile-generate followed by -fbranch-use.
load_lib gcc-dg.exp
load_lib target-supports.exp
set DEFAULT_MATCFLAGS "-O3 -fipa-matrix-reorg -fdump-ipa-matrix-reorg -fwhole-program -combine"
# Initialize `dg'.
dg-init
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/matrix-\[1-6\].\[cS\]]] \
"" $DEFAULT_MATCFLAGS
dg-final
# Some targets don't support tree profiling.
if { ![check_profiling_available ""] } {
return
}
# The procedures in profopt.exp need these parameters.
set tool gcc
set prof_ext "gcda gcno"
# Override the list defined in profopt.exp.
set PROFOPT_OPTIONS [list {}]
if $tracelevel then {
strace $tracelevel
}
# Load support procs.
load_lib profopt.exp
# These are globals used by profopt-execute. The first is options
# needed to generate profile data, the second is options to use the
# profile data.
set profile_option "-fprofile-generate -O3"
set feedback_option "-fprofile-use -fipa-matrix-reorg -fdump-ipa-matrix-reorg -O3 -fwhole-program -combine"
foreach src [lsort [glob -nocomplain $srcdir/$subdir/transpose-*.c]] {
# If we're only testing specific files and this isn't one of them, skip it.
if ![runtest_file_p $runtests $src] then {
continue
}
profopt-execute $src
}

View File

@ -0,0 +1,98 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void mem_init (void);
int ARCHnodes, ARCHnodes1;
int ***vel;
/* The whole matrix VEL is flattened (3 dimensions).
All dimensions are transposed : dim 0 -> dim 2
dim 1 -> dim 0
dim 2 -> dim 1
*/
/*--------------------------------------------------------------------------*/
int
main (int argc, char **argv)
{
int i, j, k;
ARCHnodes = 2;
ARCHnodes1 = 4;
/* Dynamic memory allocations and initializations */
mem_init ();
for (i = 0; i < 3; i++)
{
for (j = 0; j < 4; j++)
{
for (k = 0; k < 2; k++)
{
printf ("[%d][%d][%d]=%d ", i, j, k, vel[k][i][j]);
}
printf ("\n");
}
printf ("\n");
}
for (i = 0; i < ARCHnodes; i++)
for (j = 0; j < 3; j++)
free (vel[i][j]);
for (i = 0; i < ARCHnodes; i++)
free (vel[i]);
free (vel);
return 0;
}
/*--------------------------------------------------------------------------*/
/* Dynamic memory allocations and initializations */
void
mem_init (void)
{
int i, j, k,d;
d = 0;
vel = (int ***) malloc (ARCHnodes * sizeof (int **));
for (i = 0; i < ARCHnodes; i++)
{
vel[i] = (int **) malloc (3 * sizeof (int *));
if (vel[i] == (int **) NULL)
{
fprintf (stderr, "malloc failed for vel[%d]\n", i);
fflush (stderr);
exit (0);
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
{
vel[i][j][k] = d;
d++;
}
}
}
}
/*--------------------------------------------------------------------------*/
/* { dg-final-use { scan-ipa-dump-times "Flattened 3 dimensions" 1 "matrix-reorg" } } */
/* { dg-final-use { scan-ipa-dump-times "Transposed" 3 "matrix-reorg" } } */
/* { dg-final-use { cleanup-ipa-dump "matrix-reorg" } } */

View File

@ -0,0 +1,95 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void mem_init (void);
int ARCHnodes, ARCHnodes1;
int ***vel;
/* The whole matrix VEL is flattened (3 dimensions).
No transposing is necessary. */
/*--------------------------------------------------------------------------*/
int
main (int argc, char **argv)
{
int i, j, k;
ARCHnodes = 2;
ARCHnodes1 = 4;
/* Dynamic memory allocations and initializations */
mem_init ();
for (j = 0; j < 2; j++)
{
for (i = 0; i < 4; i++)
{
for (k = 0; k < 2; k++)
{
printf ("[%d][%d][%d]=%d ", i, j, k, vel[k][k][k]);
}
printf ("\n");
}
printf ("\n");
}
for (i = 0; i < ARCHnodes; i++)
for (j = 0; j < 3; j++)
free (vel[i][j]);
for (i = 0; i < ARCHnodes; i++)
free (vel[i]);
free (vel);
return 0;
}
/*--------------------------------------------------------------------------*/
/* Dynamic memory allocations and initializations */
void
mem_init (void)
{
int i, j, k,d;
d = 0;
vel = (int ***) malloc (ARCHnodes * sizeof (int **));
for (i = 0; i < ARCHnodes; i++)
{
vel[i] = (int **) malloc (3 * sizeof (int *));
if (vel[i] == (int **) NULL)
{
fprintf (stderr, "malloc failed for vel[%d]\n", i);
fflush (stderr);
exit (0);
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
{
vel[i][j][k] = d;
d++;
}
}
}
}
/*--------------------------------------------------------------------------*/
/* { dg-final-use { scan-ipa-dump-times "Flattened 3 dimensions" 1 "matrix-reorg" } } */
/* { dg-final-use { scan-ipa-dump-times "Transposed" 0 "matrix-reorg" } } */
/* { dg-final-use { cleanup-ipa-dump "matrix-reorg" } } */

View File

@ -0,0 +1,101 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void mem_init (void);
int ARCHnodes, ARCHnodes1;
int ***vel;
/* The inner most dimension escapes.
The two external dimensions are flattened
after being transposed. */
/*--------------------------------------------------------------------------*/
int
main (int argc, char **argv)
{
int i, j, k;
ARCHnodes = 2;
ARCHnodes1 = 4;
/* Dynamic memory allocations and initializations */
mem_init ();
for (j = 0; j < 4; j++)
{
for (i = 0; i < 3; i++)
{
for (k = 0; k < 2; k++)
{
printf ("[%d][%d][%d]=%d ", i, j, k, vel[k][i][j]);
}
printf ("\n");
}
printf ("\n");
}
vel[0][0]=vel[1][1];
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
if (i==1 && j==1)
continue;
else
free (vel[i][j]);
for (i = 0; i < 2; i++)
free (vel[i]);
free (vel);
return 0;
}
/*--------------------------------------------------------------------------*/
/* Dynamic memory allocations and initializations */
void
mem_init (void)
{
signed int i, j, k,d;
d = 0;
vel = (int ***) malloc (ARCHnodes * sizeof (int **));
for (i = 0; i < ARCHnodes; i++)
{
vel[i] = (int **) malloc (3 * sizeof (int *));
if (vel[i] == (int **) NULL)
{
fprintf (stderr, "malloc failed for vel[%d]\n", i);
fflush (stderr);
exit (0);
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
{
printf ("acc to dim2 ");
vel[i][j][k] = d;
d++;
}
}
}
printf ("\n");
}
/*--------------------------------------------------------------------------*/
/* { dg-final-use { scan-ipa-dump-times "Flattened 2 dimensions" 1 "matrix-reorg" } } */
/* { dg-final-use { scan-ipa-dump-times "Transposed" 2 "matrix-reorg" } } */
/* { dg-final-use { cleanup-ipa-dump "matrix-reorg" } } */

View File

@ -0,0 +1,100 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void mem_init (void);
int ARCHnodes, ARCHnodes1;
int ***vel;
/* The whole matrix VEL is flattened (3 dimensions).
The two inner dimensions are transposed.
dim 1 -> dim 2
dim 2 -> dim 1
*/
/*--------------------------------------------------------------------------*/
int
main (int argc, char **argv)
{
int i, j, k;
ARCHnodes = 2;
ARCHnodes1 = 4;
/* Dynamic memory allocations and initializations */
mem_init ();
for (j = 0; j < 4; j++)
{
for (i = 0; i < 2; i++)
{
for (k = 0; k < 3; k++)
{
printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][k][j]);
}
printf ("\n");
}
printf ("\n");
}
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
free (vel[i][j]);
for (i = 0; i < 2; i++)
free (vel[i]);
free (vel);
return 0;
}
/*--------------------------------------------------------------------------*/
/* Dynamic memory allocations and initializations */
void
mem_init (void)
{
signed int i, j, k,d;
d = 0;
vel = (int ***) malloc (ARCHnodes * sizeof (int **));
for (i = 0; i < ARCHnodes; i++)
{
vel[i] = (int **) malloc (3 * sizeof (int *));
if (vel[i] == (int **) NULL)
{
fprintf (stderr, "malloc failed for vel[%d]\n", i);
fflush (stderr);
exit (0);
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
{
printf ("acc to dim2 ");
vel[i][j][k] = d;
d++;
}
}
}
printf ("\n");
}
/*--------------------------------------------------------------------------*/
/* { dg-final-use { scan-ipa-dump-times "Flattened 3 dimensions" 1 "matrix-reorg" } } */
/* { dg-final-use { scan-ipa-dump-times "Transposed" 2 "matrix-reorg" } } */
/* { dg-final-use { cleanup-ipa-dump "matrix-reorg" } } */

View File

@ -0,0 +1,96 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void mem_init (void);
int ARCHnodes, ARCHnodes1;
int ***vel;
/* The whole matrix VEL is flattened (3 dimensions).
The dimensions are NOT transposed. */
/*--------------------------------------------------------------------------*/
int
main (int argc, char **argv)
{
int i, j, k;
ARCHnodes = 2;
ARCHnodes1 = 4;
/* Dynamic memory allocations and initializations */
mem_init ();
for (j = 0; j < 3; j++)
{
for (i = 0; i < 2; i++)
{
for (k = 0; k < 4; k++)
{
printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]);
}
printf ("\n");
}
printf ("\n");
}
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
free (vel[i][j]);
for (i = 0; i < 2; i++)
free (vel[i]);
free (vel);
return 0;
}
/*--------------------------------------------------------------------------*/
/* Dynamic memory allocations and initializations */
void
mem_init (void)
{
signed int i, j, k,d;
d = 0;
vel = (int ***) malloc (ARCHnodes * sizeof (int **));
for (i = 0; i < ARCHnodes; i++)
{
vel[i] = (int **) malloc (3 * sizeof (int *));
if (vel[i] == (int **) NULL)
{
fprintf (stderr, "malloc failed for vel[%d]\n", i);
fflush (stderr);
exit (0);
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
{
printf ("acc to dim2 ");
vel[i][j][k] = d;
d++;
}
}
}
printf ("\n");
}
/*--------------------------------------------------------------------------*/
/* { dg-final-use { scan-ipa-dump-times "Flattened 3 dimensions" 1 "matrix-reorg" } } */
/* { dg-final-use { scan-ipa-dump-times "Transposed" 0 "matrix-reorg" } } */
/* { dg-final-use { cleanup-ipa-dump "matrix-reorg" } } */

View File

@ -0,0 +1,96 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void mem_init (void);
int ARCHnodes, ARCHnodes1;
int ***vel;
/* The whole matrix VEL is flattened (3 dimensions).
The dimensions are NOT transposed. */
/*--------------------------------------------------------------------------*/
int
main (int argc, char **argv)
{
int i, j, k;
ARCHnodes = 2;
ARCHnodes1 = 4;
/* Dynamic memory allocations and initializations */
mem_init ();
for (j = 0; j < 3; j++)
{
for (i = 0; i < 2; i++)
{
for (k = 0; k < 3; k++)
{
printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][k][k]);
}
printf ("\n");
}
printf ("\n");
}
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
free (vel[i][j]);
for (i = 0; i < 2; i++)
free (vel[i]);
free (vel);
return 0;
}
/*--------------------------------------------------------------------------*/
/* Dynamic memory allocations and initializations */
void
mem_init (void)
{
signed int i, j, k,d;
d = 0;
vel = (int ***) malloc (ARCHnodes * sizeof (int **));
for (i = 0; i < ARCHnodes; i++)
{
vel[i] = (int **) malloc (3 * sizeof (int *));
if (vel[i] == (int **) NULL)
{
fprintf (stderr, "malloc failed for vel[%d]\n", i);
fflush (stderr);
exit (0);
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
}
}
for (i = 0; i < ARCHnodes; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < ARCHnodes1; k++)
{
printf ("acc to dim2 ");
vel[i][j][k] = d;
d++;
}
}
}
printf ("\n");
}
/*--------------------------------------------------------------------------*/
/* { dg-final-use { scan-ipa-dump-times "Flattened 3 dimensions" 1 "matrix-reorg" } } */
/* { dg-final-use { scan-ipa-dump-times "Transposed" 0 "matrix-reorg" } } */
/* { dg-final-use { cleanup-ipa-dump "matrix-reorg" } } */