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

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/gnu-stable/gcc-4.5.1/gcc/testsuite/gcc.dg/matrix
    from Rev 816 to Rev 826
    Reverse comparison

Rev 816 → Rev 826

/matrix.exp
0,0 → 1,64
# Copyright (C) 2001, 2002, 2004, 2005, 2007 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 3 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 GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
 
# 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"
 
# 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
}
 
/transpose-3.c
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" } } */
transpose-3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: transpose-4.c =================================================================== --- transpose-4.c (nonexistent) +++ transpose-4.c (revision 826) @@ -0,0 +1,100 @@ +#include +#include +#include +#include + +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" } } */
transpose-4.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: transpose-5.c =================================================================== --- transpose-5.c (nonexistent) +++ transpose-5.c (revision 826) @@ -0,0 +1,96 @@ +#include +#include +#include +#include + +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" } } */
transpose-5.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: transpose-6.c =================================================================== --- transpose-6.c (nonexistent) +++ transpose-6.c (revision 826) @@ -0,0 +1,96 @@ +#include +#include +#include +#include + +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" } } */
transpose-6.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: matrix-1.c =================================================================== --- matrix-1.c (nonexistent) +++ matrix-1.c (revision 826) @@ -0,0 +1,92 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +#include +#include +#include + +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" } } */
matrix-1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: matrix-2.c =================================================================== --- matrix-2.c (nonexistent) +++ matrix-2.c (revision 826) @@ -0,0 +1,115 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + + +#include +#include +#include +#include + +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" } } */
matrix-2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: matrix-3.c =================================================================== --- matrix-3.c (nonexistent) +++ matrix-3.c (revision 826) @@ -0,0 +1,101 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fipa-matrix-reorg -fdump-ipa-matrix-reorg -c -fwhole-program -combine" } */ + + +#include +#include +#include +#include + +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" } } */
matrix-3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: matrix-4.c =================================================================== --- matrix-4.c (nonexistent) +++ matrix-4.c (revision 826) @@ -0,0 +1,99 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fipa-matrix-reorg -fdump-ipa-matrix-reorg -c -fwhole-program -combine" } */ + + +#include +#include +#include +#include + +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" } } */
matrix-4.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: matrix-5.c =================================================================== --- matrix-5.c (nonexistent) +++ matrix-5.c (revision 826) @@ -0,0 +1,98 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + + +#include +#include +#include +#include + +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" } } */
matrix-5.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: matrix-6.c =================================================================== --- matrix-6.c (nonexistent) +++ matrix-6.c (revision 826) @@ -0,0 +1,97 @@ +/* { dg-do compile } */ + + +#include +#include +#include +#include + +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] = &d; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump-times "Flattened 2 dimensions" 1 "matrix-reorg" } } */ +/* { dg-final { cleanup-ipa-dump "matrix-reorg" } } */
matrix-6.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: transpose-1.c =================================================================== --- transpose-1.c (nonexistent) +++ transpose-1.c (revision 826) @@ -0,0 +1,98 @@ +#include +#include +#include +#include + +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" } } */ +
transpose-1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: transpose-2.c =================================================================== --- transpose-2.c (nonexistent) +++ transpose-2.c (revision 826) @@ -0,0 +1,95 @@ + +#include +#include +#include +#include + +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" } } */
transpose-2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property

powered by: WebSVN 2.1.0

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