Commit 64630e61 by Sebastian Pop Committed by Sebastian Pop

Add runtime tests for interchange and blocking.

2010-02-03  Sebastian Pop  <sebastian.pop@amd.com>

	* testsuite/g++.dg/graphite/graphite.exp: Rewritten.
	* testsuite/gcc.dg/graphite/graphite.exp: Rewritten.
	* testsuite/gfortran.dg/graphite/graphite.exp: Rewritten.
	* gcc/testsuite/gcc.dg/graphite/block-0.c: Added runtime test.
	* testsuite/gcc.dg/graphite/block-1.c: Same.
	* testsuite/gcc.dg/graphite/block-3.c: Same.
	* testsuite/gcc.dg/graphite/block-4.c: Same.
	* testsuite/gcc.dg/graphite/block-5.c: Same.
	* testsuite/gcc.dg/graphite/block-6.c: Same.
	* testsuite/gcc.dg/graphite/block-7.c: Same.
	* testsuite/gcc.dg/graphite/interchange-0.c: Same.
	* testsuite/gcc.dg/graphite/interchange-1.c: Same.
	* testsuite/gcc.dg/graphite/interchange-10.c: Same.
	* testsuite/gcc.dg/graphite/interchange-11.c: Same.
	* testsuite/gcc.dg/graphite/interchange-12.c: Same.
	* testsuite/gcc.dg/graphite/interchange-2.c: Same.
	* testsuite/gcc.dg/graphite/interchange-3.c: Same.
	* testsuite/gcc.dg/graphite/interchange-4.c: Same.
	* testsuite/gcc.dg/graphite/interchange-5.c: Same.
	* testsuite/gcc.dg/graphite/interchange-6.c: Same.
	* testsuite/gcc.dg/graphite/interchange-7.c: Same.
	* testsuite/gcc.dg/graphite/interchange-8.c: Same.
	* testsuite/gcc.dg/graphite/interchange-9.c: Same.
	* testsuite/gcc.dg/graphite/interchange-mvt.c: Same.
	* testsuite/gcc.dg/graphite/run-id-2.c: Remove useless dg-do run.

From-SVN: r156548
parent 4c8f3c48
2010-02-03 Sebastian Pop <sebastian.pop@amd.com>
* testsuite/g++.dg/graphite/graphite.exp: Rewritten.
* testsuite/gcc.dg/graphite/graphite.exp: Rewritten.
* testsuite/gfortran.dg/graphite/graphite.exp: Rewritten.
* gcc/testsuite/gcc.dg/graphite/block-0.c: Added runtime test.
* testsuite/gcc.dg/graphite/block-1.c: Same.
* testsuite/gcc.dg/graphite/block-3.c: Same.
* testsuite/gcc.dg/graphite/block-4.c: Same.
* testsuite/gcc.dg/graphite/block-5.c: Same.
* testsuite/gcc.dg/graphite/block-6.c: Same.
* testsuite/gcc.dg/graphite/block-7.c: Same.
* testsuite/gcc.dg/graphite/interchange-0.c: Same.
* testsuite/gcc.dg/graphite/interchange-1.c: Same.
* testsuite/gcc.dg/graphite/interchange-10.c: Same.
* testsuite/gcc.dg/graphite/interchange-11.c: Same.
* testsuite/gcc.dg/graphite/interchange-12.c: Same.
* testsuite/gcc.dg/graphite/interchange-2.c: Same.
* testsuite/gcc.dg/graphite/interchange-3.c: Same.
* testsuite/gcc.dg/graphite/interchange-4.c: Same.
* testsuite/gcc.dg/graphite/interchange-5.c: Same.
* testsuite/gcc.dg/graphite/interchange-6.c: Same.
* testsuite/gcc.dg/graphite/interchange-7.c: Same.
* testsuite/gcc.dg/graphite/interchange-8.c: Same.
* testsuite/gcc.dg/graphite/interchange-9.c: Same.
* testsuite/gcc.dg/graphite/interchange-mvt.c: Same.
* testsuite/gcc.dg/graphite/run-id-2.c: Remove useless dg-do run.
2010-01-22 Ramakrishna Upadrasta <Ramakrishna.Upadrasta@inria.fr> 2010-01-22 Ramakrishna Upadrasta <Ramakrishna.Upadrasta@inria.fr>
* graphite-scop-detection.c (dot_all_scops): Make calls to dot run in * graphite-scop-detection.c (dot_all_scops): Make calls to dot run in
......
...@@ -33,58 +33,36 @@ proc lremove {list_variable value} { ...@@ -33,58 +33,36 @@ proc lremove {list_variable value} {
# The default action for a test is 'compile'. Save current default. # The default action for a test is 'compile'. Save current default.
global dg-do-what-default global dg-do-what-default
set save-dg-do-what-default ${dg-do-what-default} set save-dg-do-what-default ${dg-do-what-default}
set dg-do-what-default compile
# Initialize `dg'. # Initialize `dg'.
dg-init dg-init
# Main loop.
set wait_to_run_files [lsort [glob -nocomplain $srcdir/$subdir/*.C ] ] set wait_to_run_files [lsort [glob -nocomplain $srcdir/$subdir/*.C ] ]
set scop_files [lsort [glob -nocomplain $srcdir/$subdir/scop-*.C ] ]
# Flags using for block-* files.
set DEFAULT_FLAGS_GRAPHITE_BLOCK "-O2 -floop-block -fno-loop-strip-mine \
-fno-loop-interchange -fdump-tree-graphite-all"
set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.C ] ]
dg-runtest $block_files "" $DEFAULT_FLAGS_GRAPHITE_BLOCK
foreach block_file $block_files {lremove wait_to_run_files $block_file}
# Flags using for id-* files.
set DEFAULT_FLAGS_GRAPHITE_IDENTITY "-O2 -fgraphite-identity"
set id_files [lsort [glob -nocomplain $srcdir/$subdir/id-*.C ] ] set id_files [lsort [glob -nocomplain $srcdir/$subdir/id-*.C ] ]
dg-runtest $id_files "" $DEFAULT_FLAGS_GRAPHITE_IDENTITY set run_id_files [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.C ] ]
foreach id_file $id_files {lremove wait_to_run_files $id_file}
# Flags using for interchange-* files.
set DEFAULT_FLAGS_GRAPHITE_INTERCHANGE "-O2 -fdump-tree-graphite-all \
-floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math"
set interchange_files [lsort [glob -nocomplain $srcdir/$subdir/interchange-*.C ] ] set interchange_files [lsort [glob -nocomplain $srcdir/$subdir/interchange-*.C ] ]
dg-runtest $interchange_files "" $DEFAULT_FLAGS_GRAPHITE_INTERCHANGE set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.C ] ]
foreach interchange_file $interchange_files {lremove wait_to_run_files $interchange_file}
# Flags using for scop-* files.
set DEFAULT_FLAGS_GRAPHITE_SCOP "-O2 -fgraphite -fdump-tree-graphite-all"
set scop_files [lsort [glob -nocomplain $srcdir/$subdir/scop-*.C ] ]
dg-runtest $scop_files "" $DEFAULT_FLAGS_GRAPHITE_SCOP
foreach scop_file $scop_files {lremove wait_to_run_files $scop_file}
# Tests to be compiled.
set dg-do-what-default compile
dg-runtest $scop_files "" "-O2 -fgraphite -fdump-tree-graphite-all"
dg-runtest $id_files "" "-O2 -fgraphite-identity -ffast-math"
# Schedule now the tests to be run. # Tests to be run.
set dg-do-what-default run set dg-do-what-default run
dg-runtest $run_id_files "" "-O2 -fgraphite-identity"
# Flags using for run-id-* files. dg-runtest $interchange_files "" "-O2 -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math -fdump-tree-graphite-all"
set DEFAULT_FLAGS_RUN_ID "-O2 -fgraphite-identity" dg-runtest $block_files "" "-O2 -floop-block -fno-loop-strip-mine -fno-loop-interchange -ffast-math -fdump-tree-graphite-all"
set run_id_files [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.C ] ]
dg-runtest $run_id_files "" $DEFAULT_FLAGS_RUN_ID
foreach run_id_file $run_id_files {lremove wait_to_run_files $run_id_file}
# The default action for the rest of the files is 'compile'. # The default action for the rest of the files is 'compile'.
set dg-do-what-default compile set dg-do-what-default compile
foreach f $scop_files {lremove wait_to_run_files $f}
# Flags using for other files. foreach f $id_files {lremove wait_to_run_files $f}
set DEFAULT_FLAGS_GRAPHITE "-ansi -pedantic-errors" foreach f $run_id_files {lremove wait_to_run_files $f}
dg-runtest $wait_to_run_files "" $DEFAULT_FLAGS_GRAPHITE foreach f $interchange_files {lremove wait_to_run_files $f}
foreach f $block_files {lremove wait_to_run_files $f}
dg-runtest $wait_to_run_files "" "-ansi -pedantic-errors"
# Clean up. # Clean up.
set dg-do-what-default ${save-dg-do-what-default} set dg-do-what-default ${save-dg-do-what-default}
......
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
#define N 1000 #define N 1000
int a[N];
int toto() static int __attribute__((noinline))
foo (void)
{ {
int j; int j;
int i; int i;
int a[N];
int b[N];
for (i = 0; i < N; i++) for (i = 0; i < N; i++)
for (j = 0; j < N; j++) for (j = 0; j < N; j++)
...@@ -16,7 +21,18 @@ int toto() ...@@ -16,7 +21,18 @@ int toto()
main() main()
{ {
return toto(); int i, res;
for (i = 0; i < N; i++)
a[i] = i;
res = foo ();
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 1999;
} }
/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */
......
/* { dg-require-effective-target size32plus } */ /* { dg-require-effective-target size32plus } */
#define MAX 8192 #define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
void bar (void); #define MAX 100
int main() int main()
{ {
...@@ -11,8 +14,6 @@ int main() ...@@ -11,8 +14,6 @@ int main()
int A[MAX * MAX]; int A[MAX * MAX];
int B[MAX * MAX]; int B[MAX * MAX];
bar ();
for (i = 0; i < MAX; i++) for (i = 0; i < MAX; i++)
for (j = 0; j < MAX; j++) for (j = 0; j < MAX; j++)
{ {
...@@ -24,13 +25,15 @@ int main() ...@@ -24,13 +25,15 @@ int main()
for (j = 0; j < MAX; j++) for (j = 0; j < MAX; j++)
A[i*MAX + j] += B[j*MAX + i]; A[i*MAX + j] += B[j*MAX + i];
bar ();
for(i = 0; i < MAX; i++) for(i = 0; i < MAX; i++)
for(j = 0; j < MAX; j++) for(j = 0; j < MAX; j++)
sum += A[i*MAX + j]; sum += A[i*MAX + j];
return sum; #if DEBUG
fprintf (stderr, "sum = %d \n", sum);
#endif
return sum != 990000;
} }
/* { dg-final { scan-tree-dump-times "will be loop blocked" 2 "graphite" { xfail *-*-* } } } */ /* { dg-final { scan-tree-dump-times "will be loop blocked" 2 "graphite" { xfail *-*-* } } } */
......
/* { dg-require-effective-target size32plus } */ /* { dg-require-effective-target size32plus } */
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
#define N 24 #define N 24
#define M 100 #define M 100
float A[M][M][M], B[M][M], C[M][M]; int A[M][M][M], B[M][M], C[M][M];
void test (void) static int __attribute__((noinline))
foo (void)
{ {
int i, j, k; int i, j, k;
...@@ -20,6 +26,29 @@ void test (void) ...@@ -20,6 +26,29 @@ void test (void)
for (j = 0; j < M; j++) for (j = 0; j < M; j++)
for (k = 0; k < M; k++) for (k = 0; k < M; k++)
A[i][j][k] = B[i][k] * C[k][j]; A[i][j][k] = B[i][k] * C[k][j];
return A[0][0][0] + A[M-1][M-1][M-1];
}
int
main (void)
{
int i, j, res;
for (i = 0; i < M; i++)
for (j = 0; j < M; j++)
{
B[i][j] = i;
C[i][j] = j;
}
res = foo ();
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 9801;
} }
/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */
......
/* { dg-require-effective-target size32plus } */ /* { dg-require-effective-target size32plus } */
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
#define N 24 #define N 24
#define M 1000 #define M 1000
float A[1000][1000], B[1000][1000], C[1000][1000]; int A[M][M], B[M][M], C[M][M];
void test (void) static int __attribute__((noinline))
foo (void)
{ {
int i, j, k; int i, j, k;
...@@ -14,10 +20,33 @@ void test (void) ...@@ -14,10 +20,33 @@ void test (void)
for (k = 0; k < 24; k++) for (k = 0; k < 24; k++)
A[i][j] = B[i][k] * C[k][j]; A[i][j] = B[i][k] * C[k][j];
for (i = 0; i < 1000; i++) for (i = 0; i < M; i++)
for (j = 0; j < 1000; j++) for (j = 0; j < M; j++)
for (k = 0; k < 1000; k++) for (k = 0; k < M; k++)
A[i][j] = B[i][k] * C[k][j]; A[i][j] = B[i][k] * C[k][j];
return A[0][0] + A[M-1][M-1];
}
int
main (void)
{
int i, j, res;
for (i = 0; i < M; i++)
for (j = 0; j < M; j++)
{
B[i][j] = i;
C[i][j] = j;
}
res = foo ();
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 998001;
} }
/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */
......
/* { dg-require-effective-target size32plus } */ /* { dg-require-effective-target size32plus } */
#define N 10000 #define DEBUG 0
void foo (int); #if DEBUG
int test () #include <stdio.h>
{ #endif
int a[N][N];
int b[N][N];
unsigned i, j;
for (i = 0; i < N; i++) #define N 200
for (j = 0; j < N; j++)
a[i][j] = i*j; int a[N][N];
int b[N][N];
static int __attribute__((noinline))
foo (void)
{
int i, j;
int res = 0;
/* This loop nest should be blocked. */ /* This loop nest should be blocked. */
for (j = 1; j < N; j++) for (j = 1; j < N; j++)
...@@ -18,8 +22,30 @@ int test () ...@@ -18,8 +22,30 @@ int test ()
a[i][j] = a[i][j-1] + b[i][j]; a[i][j] = a[i][j-1] + b[i][j];
for (i = 0; i < N; i++) for (i = 0; i < N; i++)
res += a[i][i];
return res;
}
int
main (void)
{
int i, j, res;
for (i = 0; i < N; i++)
for (j = 0; j < N; j++) for (j = 0; j < N; j++)
foo (a[i][j]); {
a[i][j] = i + j;
b[i][j] = i - j;
}
res = foo ();
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 1333300;
} }
/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */
......
/* { dg-require-effective-target size32plus } */ /* { dg-require-effective-target size32plus } */
#define N 10000 #define DEBUG 0
void foo (int); #if DEBUG
int test () #include <stdio.h>
{ #endif
int a[N][N];
unsigned i, j;
for (i = 0; i < N; i++) #define N 200
for (j = 0; j < N; j++) int a[N][N];
a[i][j] = i*j;
static int __attribute__((noinline))
foo (void)
{
int i, j;
int res = 0;
/* Interchange is not legal for loops 0 and 1. */ /* Interchange is not legal for loops 0 and 1. */
for (i = 1; i < N; i++) for (i = 1; i < N; i++)
for (j = 1; j < (N-1) ; j++) for (j = 1; j < N - 1; j++)
a[i][j] = a[i-1][j+1] * a[i-1][j+1]/2; a[i][j] = a[i-1][j+1] * a[i-1][j+1] / 2;
for (i = 0; i < N; i++)
res += a[i][i];
return res;
}
int
main (void)
{
int i, j, res;
for (i = 0; i < N; i++) for (i = 0; i < N; i++)
for (j = 0; j < N; j++) for (j = 0; j < N; j++)
foo (a[i][j]); a[i][j] = i + j;
res = foo ();
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 204007516;
} }
/* { dg-final { scan-tree-dump-times "will be loop blocked" 0 "graphite" } } */ /* { dg-final { scan-tree-dump-times "will be loop blocked" 0 "graphite" } } */
/* { dg-final { cleanup-tree-dump "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */
#define N 1000 /* { dg-require-effective-target size32plus } */
float A[N][N], B[N][N], C[N][N]; #define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
void matmult () #define N 200
int A[N][N], B[N][N], C[N][N];
static void __attribute__((noinline))
matmult (void)
{ {
int i, j, k; int i, j, k;
...@@ -15,5 +23,29 @@ void matmult () ...@@ -15,5 +23,29 @@ void matmult ()
} }
} }
int
main (void)
{
int i, j, res = 0;
for (i = 0; i < N; i++)
for (j = 0; j < N; j++)
{
B[i][j] = j;
C[i][j] = i;
}
matmult ();
for (i = 0; i < N; i++)
res += A[i][i];
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 529340000;
}
/* { dg-final { scan-tree-dump-times "SCoP will be loop blocked" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "SCoP will be loop blocked" 1 "graphite" } } */
/* { dg-final { cleanup-tree-dump "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */
...@@ -33,58 +33,36 @@ proc lremove {list_variable value} { ...@@ -33,58 +33,36 @@ proc lremove {list_variable value} {
# The default action for a test is 'compile'. Save current default. # The default action for a test is 'compile'. Save current default.
global dg-do-what-default global dg-do-what-default
set save-dg-do-what-default ${dg-do-what-default} set save-dg-do-what-default ${dg-do-what-default}
set dg-do-what-default compile
# Initialize `dg'. # Initialize `dg'.
dg-init dg-init
# Main loop.
set wait_to_run_files [lsort [glob -nocomplain $srcdir/$subdir/*.c ] ] set wait_to_run_files [lsort [glob -nocomplain $srcdir/$subdir/*.c ] ]
set scop_files [lsort [glob -nocomplain $srcdir/$subdir/scop-*.c ] ]
# Flags using for block-* files.
set DEFAULT_FLAGS_GRAPHITE_BLOCK "-O2 -floop-block -fno-loop-strip-mine \
-fno-loop-interchange -fdump-tree-graphite-all"
set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.c ] ]
dg-runtest $block_files "" $DEFAULT_FLAGS_GRAPHITE_BLOCK
foreach block_file $block_files {lremove wait_to_run_files $block_file}
# Flags using for id-* files.
set DEFAULT_FLAGS_GRAPHITE_IDENTITY "-O2 -fgraphite-identity"
set id_files [lsort [glob -nocomplain $srcdir/$subdir/id-*.c ] ] set id_files [lsort [glob -nocomplain $srcdir/$subdir/id-*.c ] ]
dg-runtest $id_files "" $DEFAULT_FLAGS_GRAPHITE_IDENTITY set run_id_files [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.c ] ]
foreach id_file $id_files {lremove wait_to_run_files $id_file}
# Flags using for interchange-* files.
set DEFAULT_FLAGS_GRAPHITE_INTERCHANGE "-O2 -fdump-tree-graphite-all \
-floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math"
set interchange_files [lsort [glob -nocomplain $srcdir/$subdir/interchange-*.c ] ] set interchange_files [lsort [glob -nocomplain $srcdir/$subdir/interchange-*.c ] ]
dg-runtest $interchange_files "" $DEFAULT_FLAGS_GRAPHITE_INTERCHANGE set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.c ] ]
foreach interchange_file $interchange_files {lremove wait_to_run_files $interchange_file}
# Flags using for scop-* files.
set DEFAULT_FLAGS_GRAPHITE_SCOP "-O2 -fgraphite -fdump-tree-graphite-all"
set scop_files [lsort [glob -nocomplain $srcdir/$subdir/scop-*.c ] ]
dg-runtest $scop_files "" $DEFAULT_FLAGS_GRAPHITE_SCOP
foreach scop_file $scop_files {lremove wait_to_run_files $scop_file}
# Tests to be compiled.
set dg-do-what-default compile
dg-runtest $scop_files "" "-O2 -fgraphite -fdump-tree-graphite-all"
dg-runtest $id_files "" "-O2 -fgraphite-identity -ffast-math"
# Schedule now the tests to be run. # Tests to be run.
set dg-do-what-default run set dg-do-what-default run
dg-runtest $run_id_files "" "-O2 -fgraphite-identity"
# Flags using for run-id-* files. dg-runtest $interchange_files "" "-O2 -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math -fdump-tree-graphite-all"
set DEFAULT_FLAGS_RUN_ID "-O2 -fgraphite-identity" dg-runtest $block_files "" "-O2 -floop-block -fno-loop-strip-mine -fno-loop-interchange -ffast-math -fdump-tree-graphite-all"
set run_id_files [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.c ] ]
dg-runtest $run_id_files "" $DEFAULT_FLAGS_RUN_ID
foreach run_id_file $run_id_files {lremove wait_to_run_files $run_id_file}
# The default action for the rest of the files is 'compile'. # The default action for the rest of the files is 'compile'.
set dg-do-what-default compile set dg-do-what-default compile
foreach f $scop_files {lremove wait_to_run_files $f}
# Flags using for other files. foreach f $id_files {lremove wait_to_run_files $f}
set DEFAULT_FLAGS_GRAPHITE "-ansi -pedantic-errors" foreach f $run_id_files {lremove wait_to_run_files $f}
dg-runtest $wait_to_run_files "" $DEFAULT_FLAGS_GRAPHITE foreach f $interchange_files {lremove wait_to_run_files $f}
foreach f $block_files {lremove wait_to_run_files $f}
dg-runtest $wait_to_run_files "" "-ansi -pedantic-errors"
# Clean up. # Clean up.
set dg-do-what-default ${save-dg-do-what-default} set dg-do-what-default ${save-dg-do-what-default}
......
/* { dg-require-effective-target size32plus } */ /* { dg-require-effective-target size32plus } */
int a[1000][1000]; #define DEBUG 0
int #if DEBUG
foo (int N) #include <stdio.h>
#endif
#define N 1000
int a[N][N];
static int __attribute__((noinline))
foo (void)
{ {
int j; int j;
int i; int i;
...@@ -12,8 +19,27 @@ foo (int N) ...@@ -12,8 +19,27 @@ foo (int N)
for (j = 0; j < N; j++) for (j = 0; j < N; j++)
a[j][i] = a[j][i] + 1; a[j][i] = a[j][i] + 1;
return a[N][123]; return a[N-1][N-1];
}
int
main (void)
{
int i, j, res;
for (i = 0; i < N; i++)
for (j = 0; j < N; j++)
a[i][j] = 1;
a[N-1][N-1] = 12;
res = foo ();
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 13;
} }
/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
/* { dg-final { cleanup-tree-dump "graphite" } } */ /* { dg -final { cleanup-tree-dump "graphite" } } */
...@@ -2,8 +2,15 @@ ...@@ -2,8 +2,15 @@
/* Formerly known as ltrans-1.c */ /* Formerly known as ltrans-1.c */
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
double u[1782225]; double u[1782225];
int foo(int N, int *res)
static int __attribute__((noinline))
foo (int N)
{ {
int i, j; int i, j;
double sum = 0.0; double sum = 0.0;
...@@ -15,8 +22,27 @@ int foo(int N, int *res) ...@@ -15,8 +22,27 @@ int foo(int N, int *res)
u[1336 * i] *= 2; u[1336 * i] *= 2;
} }
*res = sum + N;
return sum + N + u[1336 * 2] + u[1336];
} }
int
main (void)
{
int i, j, res;
for (i = 0; i < 1782225; i++)
u[i] = 2;
res = foo (1335);
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 3565793;
}
/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */ /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */
/* { dg-final { cleanup-tree-dump "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */
/* { dg-require-effective-target size32plus } */
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
double u[1782225]; double u[1782225];
int foo(int N, int *res)
static void __attribute__((noinline))
foo (int N, int *res)
{ {
int i, j; int i, j;
double sum = 0.0; double sum = 0.0;
...@@ -12,7 +21,24 @@ int foo(int N, int *res) ...@@ -12,7 +21,24 @@ int foo(int N, int *res)
for (j = 0; j < N; j++) for (j = 0; j < N; j++)
sum = sum + u[i + 1335 * j]; sum = sum + u[i + 1335 * j];
*res = sum + N; *res = sum + N + u[1336 * 2] + u[1336];
}
int
main (void)
{
int i, res;
for (i = 0; i < 1782225; i++)
u[i] = 2;
foo (1335, &res);
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 7130239;
} }
/* { dg-final { scan-tree-dump-times "will be interchanged" 2 "graphite" } } */ /* { dg-final { scan-tree-dump-times "will be interchanged" 2 "graphite" } } */
......
/* { dg-require-effective-target size32plus } */
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
double u[1782225]; double u[1782225];
int foo(int N, int *res)
static void __attribute__((noinline))
foo (int N, int *res)
{ {
int i, j; int i, j;
double sum = 0.0; double sum = 0.0;
...@@ -14,5 +23,22 @@ int foo(int N, int *res) ...@@ -14,5 +23,22 @@ int foo(int N, int *res)
*res = sum; *res = sum;
} }
int
main (void)
{
int i, res;
for (i = 0; i < 1782225; i++)
u[i] = 2;
foo (1335, &res);
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 3564450;
}
/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */ /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */
/* { dg-final { cleanup-tree-dump "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */
#define N 1000 /* { dg-require-effective-target size32plus } */
float A[N][N], B[N][N], C[N][N]; #define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
void matmult () #define N 200
int A[N][N], B[N][N], C[N][N];
static int __attribute__((noinline))
matmult (void)
{ {
int i, j, k; int i, j, k;
...@@ -13,6 +21,30 @@ void matmult () ...@@ -13,6 +21,30 @@ void matmult ()
for (k = 0; k < N; k++) for (k = 0; k < N; k++)
A[i][j] += B[i][k] * C[k][j]; A[i][j] += B[i][k] * C[k][j];
} }
return A[0][0] + A[N-1][N-1];
}
int
main (void)
{
int i, j, res;
for (i = 0; i < N; i++)
for (j = 0; j < N; j++)
{
A[i][j] = 0;
B[i][j] = i - j;
C[i][j] = i + j;
}
res = matmult ();
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 2626800;
} }
/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
......
...@@ -2,8 +2,15 @@ ...@@ -2,8 +2,15 @@
/* Formerly known as ltrans-2.c */ /* Formerly known as ltrans-2.c */
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
double u[1782225]; double u[1782225];
int foo(int N, int *res)
static void __attribute__((noinline))
foo (int N, int *res)
{ {
unsigned int i, j; unsigned int i, j;
double sum = 0; double sum = 0;
...@@ -19,7 +26,25 @@ int foo(int N, int *res) ...@@ -19,7 +26,25 @@ int foo(int N, int *res)
u[1336 * i] *= 2; u[1336 * i] *= 2;
} }
} }
*res = sum + N;
*res = sum + N + u[1336 * 2] + u[1336];
}
int
main (void)
{
int i, j, res;
for (i = 0; i < 1782225; i++)
u[i] = 2;
foo (1335, &res);
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 3565793;
} }
/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */ /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */
......
...@@ -2,8 +2,15 @@ ...@@ -2,8 +2,15 @@
/* Formerly known as ltrans-3.c */ /* Formerly known as ltrans-3.c */
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
double u[1782225]; double u[1782225];
int foo(int N, int *res)
static void __attribute__((noinline))
foo (int N, int *res)
{ {
unsigned int i, j; unsigned int i, j;
double sum = 0; double sum = 0;
...@@ -14,7 +21,25 @@ int foo(int N, int *res) ...@@ -14,7 +21,25 @@ int foo(int N, int *res)
sum = sum + u[i + 1335 * j]; sum = sum + u[i + 1335 * j];
} }
} }
*res = sum + N;
*res = sum + N + u[1336 * 2] + u[1336];
}
int
main (void)
{
int i, j, res;
for (i = 0; i < 1782225; i++)
u[i] = 2;
foo (1335, &res);
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 3565789;
} }
/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
......
...@@ -2,8 +2,15 @@ ...@@ -2,8 +2,15 @@
/* Formerly known as ltrans-4.c */ /* Formerly known as ltrans-4.c */
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
double u[1782225]; double u[1782225];
int foo(int N, int *res)
static int __attribute__((noinline))
foo (int N, int *res)
{ {
int i, j; int i, j;
double sum = 0; double sum = 0;
...@@ -13,7 +20,25 @@ int foo(int N, int *res) ...@@ -13,7 +20,25 @@ int foo(int N, int *res)
for (i = 0; i < N; i++) for (i = 0; i < N; i++)
u[1336 * i] *= 2; u[1336 * i] *= 2;
*res = sum + N;
*res = sum + N + u[1336 * 2] + u[1336];
}
int
main (void)
{
int i, j, res;
for (i = 0; i < 1782225; i++)
u[i] = 2;
foo (1335, &res);
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 3565793;
} }
/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
......
...@@ -2,16 +2,43 @@ ...@@ -2,16 +2,43 @@
/* Formerly known as ltrans-5.c */ /* Formerly known as ltrans-5.c */
int foo () #define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
#define N 100
#define M 1111
int A[N][M];
static int __attribute__((noinline))
foo (void)
{ {
int A[100][1111];
int i, j; int i, j;
for( i = 0; i < 1111; i++) for( i = 0; i < M; i++)
for( j = 0; j < 100; j++) for( j = 0; j < N; j++)
A[j][i] = 5 * A[j][i]; A[j][i] = 5 * A[j][i];
return A[10][10]; return A[0][0] + A[N-1][M-1];
}
int
main (void)
{
int i, j, res;
for (i = 0; i < N; i++)
for (j = 0; j < M; j++)
A[i][j] = 2;
res = foo ();
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 20;
} }
/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
......
...@@ -2,17 +2,44 @@ ...@@ -2,17 +2,44 @@
/* Formerly known as ltrans-6.c */ /* Formerly known as ltrans-6.c */
int medium_loop_interchange(int A[100][200]) #define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
#define N 100
#define M 200
static int __attribute__((noinline))
foo (int A[N][M])
{ {
int i,j; int i, j;
/* This loop should be interchanged. */ /* This loop should be interchanged. */
for(j = 0; j < M; j++)
for(j = 0; j < 200; j++) for(i = 0; i < N; i++)
for(i = 0; i < 100; i++)
A[i][j] = A[i][j] + A[i][j]; A[i][j] = A[i][j] + A[i][j];
return A[1][1]; return A[0][0] + A[N-1][M-1];
}
int
main (void)
{
int A[N][M];
int i, j, res;
for (i = 0; i < N; i++)
for (j = 0; j < M; j++)
A[i][j] = 2;
res = foo (A);
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 8;
} }
/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
......
/* { dg-require-effective-target size32plus } */
/* Formerly known as ltrans-8.c */ /* Formerly known as ltrans-8.c */
double #define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
#define N 111
#define M 1111
static int __attribute__((noinline))
foo (double *a) foo (double *a)
{ {
int i,j; int i,j;
double r = 0.0; int r = 0;
for (i = 0; i < 100; ++i) for (i = 0; i < N; ++i)
for (j = 0; j < 1000; ++j) for (j = 0; j < M; ++j)
r += a[j * 100 + i]; r += a[j * N + i];
return r; return r;
} }
int
main (void)
{
double A[N*M];
int i, res;
for (i = 0; i < N*M; i++)
A[i] = 2;
res = foo (A);
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 246642;
}
/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
/* { dg-final { cleanup-tree-dump "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */
int #define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
int B[4];
int A[4][4][4][4];
static int __attribute__((noinline))
foo (void) foo (void)
{ {
int i, j, k, l; int i, j, k, l;
int B[4];
int A[4][4][4][4];
for (l = 0; l < 4; l++) for (l = 0; l < 4; l++)
{ {
...@@ -37,7 +43,36 @@ foo (void) ...@@ -37,7 +43,36 @@ foo (void)
} }
} }
return A[0][1][0][2]; return A[0][1][0][2] + A[0][3][0][3] + A[0][2][0][2] + A[0][1][0][1] + A[3][3][0][2];
}
int
main (void)
{
int i, j, k, l, res;
for (i = 0; i < 4; i++)
B[i] = 2;
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
for (k = 0; k < 4; k++)
for (l = 0; l < 4; l++)
A[i][j][k][l] = i + j + k + l;
res = foo ();
#if DEBUG
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
for (k = 0; k < 4; k++)
for (l = 0; l < 4; l++)
fprintf (stderr, "A[%d][%d][%d][%d] = %d \n", i, j, k, l, A[i][j][k][l]);
fprintf (stderr, "res = %d \n", res);
#endif
return res != 424;
} }
/* Loops K and L should be interchanged. */ /* Loops K and L should be interchanged. */
......
int /* { dg-require-effective-target size32plus } */
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
#define N 1111
#define M 1111
static int __attribute__((noinline))
foo (int *x) foo (int *x)
{ {
int i, j; int i, j;
int sum = 0; int sum = 0;
for (j = 0; j < 10000; ++j) for (j = 0; j < M; ++j)
for (i = 0; i < 10000; ++i) for (i = 0; i < N; ++i)
sum += x[10000 * i + j]; sum += x[M * i + j];
return sum; return sum;
} }
int
main (void)
{
int A[N*M];
int i, res;
for (i = 0; i < N*M; i++)
A[i] = 2;
res = foo (A);
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 2468642;
}
/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */
/* { dg-final { cleanup-tree-dump "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */
/* { dg-require-effective-target size32plus } */
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
#define NMAX 2000 #define NMAX 2000
static double x1[NMAX], x2[NMAX], a[NMAX][NMAX], y_1[NMAX], y_2[NMAX]; static int x1[NMAX], x2[NMAX], a[NMAX][NMAX], y1[NMAX], y2[NMAX];
void mvt(long N) { static int __attribute__((noinline))
mvt (long N)
{
int i,j; int i,j;
for (i=0; i<N; i++) { for (i = 0; i < N; i++)
for (j=0; j<N; j++) { for (j = 0; j < N; j++)
x1[i] = x1[i] + a[i][j] * y_1[j]; x1[i] = x1[i] + a[i][j] * y1[j];
}
}
for (i=0; i<N; i++) { for (i = 0; i < N; i++)
for (j=0; j<N; j++) { for (j = 0; j < N; j++)
x2[i] = x2[i] + a[j][i] * y_2[j]; x2[i] = x2[i] + a[j][i] * y2[j];
}
return x1[0] + x2[0];
}
int
main (void)
{
int i, j, res;
for (i = 0; i < NMAX; i++)
for (j = 0; j < NMAX; j++)
a[i][j] = i + j;
for (i = 0; i < NMAX; i++)
{
x1[i] = 0;
x2[i] = 2*i;
y1[i] = 100 - i;
y2[i] = i;
} }
res = mvt (NMAX);
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
return res != 199900000;
} }
/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */ /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */
......
int a[1] = {1}; int a[1] = {1};
static int __attribute__((noinline)) foo(int n) static int __attribute__((noinline))
foo(int n)
{ {
int i, c = 0; int i, c = 0;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
...@@ -24,5 +25,3 @@ int main() ...@@ -24,5 +25,3 @@ int main()
foo(0) != 0 || foo(1) != 1 || bar(0) != 0 || bar(1) != 2 || bar(2) != 5; foo(0) != 0 || foo(1) != 1 || bar(0) != 0 || bar(1) != 2 || bar(2) != 5;
} }
/* { dg-do run } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
...@@ -33,56 +33,36 @@ proc lremove {list_variable value} { ...@@ -33,56 +33,36 @@ proc lremove {list_variable value} {
# The default action for a test is 'compile'. Save current default. # The default action for a test is 'compile'. Save current default.
global dg-do-what-default global dg-do-what-default
set save-dg-do-what-default ${dg-do-what-default} set save-dg-do-what-default ${dg-do-what-default}
set dg-do-what-default compile
# Initialize `dg'. # Initialize `dg'.
dg-init dg-init
# Main loop.
set wait_to_run_files [lsort [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] set wait_to_run_files [lsort [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ]
# Flags using for block-* files.
set DEFAULT_FLAGS_GRAPHITE_BLOCK "-O2 -floop-block -fno-loop-strip-mine \
-fno-loop-interchange -fdump-tree-graphite-all"
set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.\[fF\]{,90,95,03,08} ] ] set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.\[fF\]{,90,95,03,08} ] ]
gfortran-dg-runtest $block_files $DEFAULT_FLAGS_GRAPHITE_BLOCK
foreach block_file $block_files {lremove wait_to_run_files $block_file}
# Flags using for id-* files.
set DEFAULT_FLAGS_GRAPHITE_IDENTITY "-O2 -fgraphite-identity"
set id_files [lsort [glob -nocomplain $srcdir/$subdir/id-*.\[fF\]{,90,95,03,08} ] ] set id_files [lsort [glob -nocomplain $srcdir/$subdir/id-*.\[fF\]{,90,95,03,08} ] ]
gfortran-dg-runtest $id_files $DEFAULT_FLAGS_GRAPHITE_IDENTITY
foreach id_file $id_files {lremove wait_to_run_files $id_file}
# Flags using for interchange-* files.
set DEFAULT_FLAGS_GRAPHITE_INTERCHANGE "-O2 -fdump-tree-graphite-all \
-floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math"
set interchange_files [lsort [glob -nocomplain $srcdir/$subdir/interchange-*.\[fF\]{,90,95,03,08} ] ] set interchange_files [lsort [glob -nocomplain $srcdir/$subdir/interchange-*.\[fF\]{,90,95,03,08} ] ]
gfortran-dg-runtest $interchange_files $DEFAULT_FLAGS_GRAPHITE_INTERCHANGE
foreach interchange_file $interchange_files {lremove wait_to_run_files $interchange_file}
# Flags using for scop-* files.
set DEFAULT_FLAGS_GRAPHITE_SCOP "-O2 -fgraphite -fdump-tree-graphite-all"
set scop_files [lsort [glob -nocomplain $srcdir/$subdir/scop-*.\[fF\]{,90,95,03,08} ] ] set scop_files [lsort [glob -nocomplain $srcdir/$subdir/scop-*.\[fF\]{,90,95,03,08} ] ]
gfortran-dg-runtest $scop_files $DEFAULT_FLAGS_GRAPHITE_SCOP
foreach scop_file $scop_files {lremove wait_to_run_files $scop_file}
# Schedule now the tests to be run.
set dg-do-what-default run
# Flags using for run-id-* files.
set DEFAULT_FLAGS_RUN_ID "-O2 -fgraphite-identity"
set run_id_files [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.\[fF\]{,90,95,03,08} ] ] set run_id_files [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.\[fF\]{,90,95,03,08} ] ]
gfortran-dg-runtest $run_id_files $DEFAULT_FLAGS_RUN_ID
foreach run_id_file $run_id_files {lremove wait_to_run_files $run_id_file}
# Tests to be compiled.
set dg-do-what-default compile
gfortran-dg-runtest $scop_files "-O2 -fgraphite -fdump-tree-graphite-all"
gfortran-dg-runtest $id_files "-O2 -fgraphite-identity -ffast-math"
gfortran-dg-runtest $interchange_files "-O2 -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math -fdump-tree-graphite-all"
gfortran-dg-runtest $block_files "-O2 -floop-block -fno-loop-strip-mine -fno-loop-interchange -ffast-math -fdump-tree-graphite-all"
# Tests to be run.
set dg-do-what-default run
gfortran-dg-runtest $run_id_files "-O2 -fgraphite-identity"
# The default action for the rest of the files is 'compile'. # The default action for the rest of the files is 'compile'.
set dg-do-what-default compile set dg-do-what-default compile
foreach f $block_files {lremove wait_to_run_files $f}
# Flags using for other files. foreach f $id_files {lremove wait_to_run_files $f}
set DEFAULT_GRAPHITE_FLAGS "" foreach f $interchange_files {lremove wait_to_run_files $f}
gfortran-dg-runtest $wait_to_run_files $DEFAULT_GRAPHITE_FLAGS foreach f $scop_files {lremove wait_to_run_files $f}
foreach f $run_id_files {lremove wait_to_run_files $f}
gfortran-dg-runtest $wait_to_run_files ""
# Clean up. # Clean up.
set dg-do-what-default ${save-dg-do-what-default} set dg-do-what-default ${save-dg-do-what-default}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment