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]

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


On Wed, May 6, 2009 at 11:48 PM, Sebastian Pop <sebpop@gmail.com> wrote:
> Hi Li,
>
> On Wed, May 6, 2009 at 09:45, Li Feng <nemokingdom@gmail.com> wrote:
>> 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?
>>
>
> You may want to look at a similar file testsuite/gcc.dg/vect/vect.exp
> that does the same thing. ?You may want to add different options to
> the testcases following a filter based on the file names. ?I would
> recommend to change the name of these files from
> graphite_autopar/parallelization-1.c to something more meaningful like
> graphite_autopar/force-parallel-1.c and use this filter to set the flags:
>
> dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/force-parallel-*.c]] \
> ? ? ? ?"" $DEFAULT_CFLAGS_FORCE_PARALLEL
>
> I am asking you for this change because we will have in the near
> future some other flags than -fgraphite-force-parallel.

This is done. You may want to review the patch below.

>
> Otherwise the approach looks good, and we should do the same with the
> testcases that we have in the graphite directory.
>

1. We can filter the testcases in graphite/block-*.c
2. We can't filter the testcases in graphite/id-*.c, because their
    option differs (about 3 different option or more).
So we just filter the block-*.c?

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..26dad14
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/graphite_autopar.exp
@@ -0,0 +1,49 @@
+#   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.
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+
+# -fgraphite-force-parallel tests.
+set DEFAULT_CFLAGS_FORCE_PARALLEL " -ansi -pedantic-errors -O2 \
+-ftree-parallelize-loops=4 -fgraphite-force-parallel \
+-fdump-tree-parloops-details -fdump-tree-final_cleanup"
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/force-parallel-*.c]] \
+	"" $DEFAULT_CFLAGS_FORCE_PARALLEL
+
+# 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/force-parallel-1.c
b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/force-parallel-1.c
new file mode 100644
index 0000000..09bf770
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/force-parallel-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/force-parallel-2.c
b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/force-parallel-2.c
new file mode 100644
index 0000000..7aa3d91
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/force-parallel-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/force-parallel-3.c
b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/force-parallel-3.c
new file mode 100644
index 0000000..7cc0489
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/graphite_autopar/force-parallel-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" } } */

>> 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
>>
>

Li


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