This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[graphite][patch] Add test cases for autopar's code generation part.


Hi,

After connecting autopar's code generation part to Graphite,
I made testsuites for this part to ensure it works correctly.

This patch has been bootstrapped and success. One
might be problem is about the expect file(*.exp). So your
comment about this part will be appreciated.

The problem about this part is about :

In .exp there is always some statement like this:
global DEFAULT_CFLAGS
if ![info exists DEFAULT_CFLAGS] then {
    set DEFAULT_CFLAGS " -ansi -pedantic-errors"
}

1.
I have noticed that DEFAULT_CFLAGS has appeared in
more than one expect files. With each file has the code I
listed above. Since it's declared as global.
If it's set by one file, when running another expect file will
![info exists DEFAULT_CFLAGS] still be true?

eg. : If I run graphite.exp firstly with setting DEFAULT_CFLAGS
to " -ansi -pedantic-errors", then run another expect file with:
if ![info exists DEFAULT_CFLAGS] then {
    set DEFAULT_CFLAGS " -O2"}
Will it set DEFAULT_CFLAGS to "-O2"?
(I think no because ![info exists DEFAULT_CFLAGS]  will return
false when we have set DEFAULT_CFLAGS in graphite.exp)

If this is true, when a series of this file is run one after another,
the DEFAULT_CFLAGS  will only affected with the first running
expect file. Because the after will fail the test.

2.
Here in my patch , I simply introduce a local variable
DEFAULT_CFLAGS_AUTOPAR set to some default flags.
When the test cases without dg-option, I expect it to
compile with DEFAULT_CFLAGS_AUTOPAR, otherwise,
it will use the flag in dg-option *** in testcases.
Is this Ok/proper?

This is the patch:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/gcc/testsuite/gcc.dg/graphite/graphite_autopar/graphite_autopar.exp
b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/graphite_autopar.exp
new file mode 100644
index 0000000..f1017f1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/graphite_autopar.exp
@@ -0,0 +1,47 @@
+#   Copyright (C) 2008 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/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+if ![check_effective_target_fgraphite] {
+  return
+}
+
+# Set default action for these tests is 'run'.  Save current default.
+global dg-do-what-default
+set save-dg-do-what-default ${dg-do-what-default}
+set dg-do-what-default run
+
+# If a testcase doesn't have special options, use these.
+set DEFAULT_CFLAGS_AUTOPAR " -ansi -pedantic-errors -O2 \
+-ftree-parallelize-loops=4 -fgraphite-force-parallel \
+-fdump-tree-parloops-details -fdump-tree-final_cleanup"
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
+	"" $DEFAULT_CFLAGS_AUTOPAR
+
+# Clean up.
+set dg-do-what-default ${save-dg-do-what-default}
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gcc.dg/graphite/graphite_autopar/parallelization-1.c
b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/parallelization-1.c
new file mode 100644
index 0000000..09bf770
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/parallelization-1.c
@@ -0,0 +1,27 @@
+void abort (void);
+
+void parloop (int N)
+{
+  int i;
+  int x[10000000];
+
+  for (i = 0; i < N; i++)
+    x[i] = i + 3;
+
+  for (i = 0; i < N; i++)
+    {
+      if (x[i] != i + 3)
+	abort ();
+    }
+}
+
+int main(void)
+{
+  parloop(10000000);
+
+  return 0;
+}
+/* Check that parallel code generation part make the right answer.  */
+/* { dg-final { scan-tree-dump-times "loopfn" 5 "final_cleanup" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "final_cleanup" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/graphite_autopar/parallelization-2.c
b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/parallelization-2.c
new file mode 100644
index 0000000..7aa3d91
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/parallelization-2.c
@@ -0,0 +1,28 @@
+void abort (void);
+
+void parloop (int N)
+{
+  int i, j;
+  int x[10000][10000];
+
+  for (i = 0; i < N; i++)
+    for (j = 0; j < N; j++)
+      x[i][j] = i + j + 3;
+
+  for (i = 0; i < N; i++)
+    for (j = 0; j < N; j++)
+      if (x[i][j] != i + j + 3)
+	abort ();
+}
+
+int main(void)
+{
+  parloop(10000);
+
+  return 0;
+}
+
+/* Check that parallel code generation part make the right answer.  */
+/* { dg-final { scan-tree-dump-times "loopfn" 5 "final_cleanup" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "final_cleanup" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/graphite_autopar/parallelization-3.c
b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/parallelization-3.c
new file mode 100644
index 0000000..7cc0489
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/parallelization-3.c
@@ -0,0 +1,28 @@
+void abort (void);
+
+void parloop (int N)
+{
+  int i, j;
+  int Z[3000][3000];
+
+  for (i = 0; i <= N; i++)
+    for (j = 0; j <= N; j++)
+      Z[i][j] = Z[j+N][i+N+1];
+
+  for (i = 0; i <= N; i++)
+    for (j = 0; j <= N; j++)
+      if (Z[i][j] != Z[j+N][i+N+1])
+	abort();
+}
+
+int main(void)
+{
+  parloop(1000);
+
+  return 0;
+}
+
+/* Check that parallel code generation part make the right answer.  */
+/* { dg-final { scan-tree-dump-times "loopfn" 5 "final_cleanup" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "final_cleanup" } } */

Li


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]