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.


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.

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

Sebastian

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