From fedf3e94efe774b8c0539d344130a7b25f50a881 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Thu, 22 Oct 2020 09:45:31 +0200 Subject: [PATCH] [OpenACC] Split up testcases for inconsistent nested 'reduction' clauses checking gcc/testsuite/ * c-c++-common/goacc/nested-reductions.c: Split file into... * c-c++-common/goacc/nested-reductions-1-kernels.c: ... this... * c-c++-common/goacc/nested-reductions-1-parallel.c: ..., this... * c-c++-common/goacc/nested-reductions-1-routine.c: ..., and this. * c-c++-common/goacc/nested-reductions-warn.c: Split file into... * c-c++-common/goacc/nested-reductions-2-kernels.c: ... this... * c-c++-common/goacc/nested-reductions-2-parallel.c: ..., this... * c-c++-common/goacc/nested-reductions-2-routine.c: ..., and this. * gfortran.dg/goacc/nested-reductions.f90: Split file into... * gfortran.dg/goacc/nested-reductions-1-kernels.f90: ... this... * gfortran.dg/goacc/nested-reductions-1-parallel.f90: ..., this... * gfortran.dg/goacc/nested-reductions-1-routine.f90: ..., and this. * gfortran.dg/goacc/nested-reductions-warn.f90: Split file into... * gfortran.dg/goacc/nested-reductions-2-kernels.f90: ... this... * gfortran.dg/goacc/nested-reductions-2-parallel.f90: ..., this... * gfortran.dg/goacc/nested-reductions-2-routine.f90: ..., and this. --- .../goacc/nested-reductions-1-kernels.c | 41 ++++ ...tions.c => nested-reductions-1-parallel.c} | 108 +---------- .../goacc/nested-reductions-1-routine.c | 68 +++++++ .../goacc/nested-reductions-2-kernels.c | 50 +++++ ...-warn.c => nested-reductions-2-parallel.c} | 142 +------------- .../goacc/nested-reductions-2-routine.c | 93 +++++++++ .../goacc/nested-reductions-1-kernels.f90 | 55 ++++++ ...s.f90 => nested-reductions-1-parallel.f90} | 142 +------------- .../goacc/nested-reductions-1-routine.f90 | 88 +++++++++ .../goacc/nested-reductions-2-kernels.f90 | 63 ++++++ ...n.f90 => nested-reductions-2-parallel.f90} | 181 +----------------- .../goacc/nested-reductions-2-routine.f90 | 119 ++++++++++++ 12 files changed, 589 insertions(+), 561 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/goacc/nested-reductions-1-kernels.c rename gcc/testsuite/c-c++-common/goacc/{nested-reductions.c => nested-reductions-1-parallel.c} (76%) create mode 100644 gcc/testsuite/c-c++-common/goacc/nested-reductions-1-routine.c create mode 100644 gcc/testsuite/c-c++-common/goacc/nested-reductions-2-kernels.c rename gcc/testsuite/c-c++-common/goacc/{nested-reductions-warn.c => nested-reductions-2-parallel.c} (78%) create mode 100644 gcc/testsuite/c-c++-common/goacc/nested-reductions-2-routine.c create mode 100644 gcc/testsuite/gfortran.dg/goacc/nested-reductions-1-kernels.f90 rename gcc/testsuite/gfortran.dg/goacc/{nested-reductions.f90 => nested-reductions-1-parallel.f90} (75%) create mode 100644 gcc/testsuite/gfortran.dg/goacc/nested-reductions-1-routine.f90 create mode 100644 gcc/testsuite/gfortran.dg/goacc/nested-reductions-2-kernels.f90 rename gcc/testsuite/gfortran.dg/goacc/{nested-reductions-warn.f90 => nested-reductions-2-parallel.f90} (78%) create mode 100644 gcc/testsuite/gfortran.dg/goacc/nested-reductions-2-routine.f90 diff --git a/gcc/testsuite/c-c++-common/goacc/nested-reductions-1-kernels.c b/gcc/testsuite/c-c++-common/goacc/nested-reductions-1-kernels.c new file mode 100644 index 00000000000..68cb8f82ee5 --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/nested-reductions-1-kernels.c @@ -0,0 +1,41 @@ +/* Test cases of nested 'reduction' clauses expected to compile cleanly. */ + +/* See also 'gfortran.dg/goacc/nested-reductions-1-kernels.f90'. */ + +void acc_kernels (void) +{ + int i, j, k, sum, diff; + + /* FIXME: These tests are not meaningful yet because reductions in + kernels regions are not supported yet. */ + #pragma acc kernels + { + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop reduction(+:sum) + for (j = 0; j < 10; j++) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop reduction(+:sum) + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + } +} diff --git a/gcc/testsuite/c-c++-common/goacc/nested-reductions.c b/gcc/testsuite/c-c++-common/goacc/nested-reductions-1-parallel.c similarity index 76% rename from gcc/testsuite/c-c++-common/goacc/nested-reductions.c rename to gcc/testsuite/c-c++-common/goacc/nested-reductions-1-parallel.c index 15385c4da99..ce1d0a13527 100644 --- a/gcc/testsuite/c-c++-common/goacc/nested-reductions.c +++ b/gcc/testsuite/c-c++-common/goacc/nested-reductions-1-parallel.c @@ -1,4 +1,6 @@ -/* Test cases of nested reduction loops that should compile cleanly. */ +/* Test cases of nested 'reduction' clauses expected to compile cleanly. */ + +/* See also 'gfortran.dg/goacc/nested-reductions-1-parallel.f90'. */ void acc_parallel (void) { @@ -314,107 +316,3 @@ void acc_parallel_loop_reduction (void) } } } - -/* The same tests as above, but inside a routine construct. */ -#pragma acc routine gang -void acc_routine (void) -{ - int i, j, k, sum, diff; - - { - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop collapse(2) reduction(+:sum) - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop reduction(+:sum) - for (j = 0; j < 10; j++) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop collapse(2) reduction(+:sum) - for (j = 0; j < 10; j++) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop reduction(+:sum) - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) reduction(-:diff) - for (i = 0; i < 10; i++) - { - #pragma acc loop reduction(+:sum) - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(-:diff) - for (j = 0; j < 10; j++) - #pragma acc loop reduction(-:diff) - for (k = 0; k < 10; k++) - diff = 1; - } - } -} - -void acc_kernels (void) -{ - int i, j, k, sum, diff; - - /* FIXME: These tests are not meaningful yet because reductions in - kernels regions are not supported yet. */ - #pragma acc kernels - { - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop reduction(+:sum) - for (j = 0; j < 10; j++) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop reduction(+:sum) - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - } -} diff --git a/gcc/testsuite/c-c++-common/goacc/nested-reductions-1-routine.c b/gcc/testsuite/c-c++-common/goacc/nested-reductions-1-routine.c new file mode 100644 index 00000000000..83d39950295 --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/nested-reductions-1-routine.c @@ -0,0 +1,68 @@ +/* Test cases of nested 'reduction' clauses expected to compile cleanly. */ + +/* See also 'gfortran.dg/goacc/nested-reductions-1-routine.f90'. */ + +#pragma acc routine gang +void acc_routine (void) +{ + int i, j, k, sum, diff; + + { + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop collapse(2) reduction(+:sum) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop reduction(+:sum) + for (j = 0; j < 10; j++) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop collapse(2) reduction(+:sum) + for (j = 0; j < 10; j++) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop reduction(+:sum) + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) reduction(-:diff) + for (i = 0; i < 10; i++) + { + #pragma acc loop reduction(+:sum) + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(-:diff) + for (j = 0; j < 10; j++) + #pragma acc loop reduction(-:diff) + for (k = 0; k < 10; k++) + diff = 1; + } + } +} diff --git a/gcc/testsuite/c-c++-common/goacc/nested-reductions-2-kernels.c b/gcc/testsuite/c-c++-common/goacc/nested-reductions-2-kernels.c new file mode 100644 index 00000000000..80d7c53daca --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/nested-reductions-2-kernels.c @@ -0,0 +1,50 @@ +/* Test erroneous cases of nested 'reduction' clauses. */ + +/* See also 'gfortran.dg/goacc/nested-reductions-2-kernels.f90'. */ + +void acc_kernels (void) +{ + int i, j, k, sum, diff; + + /* FIXME: No diagnostics are produced for these loops because reductions + in kernels regions are not supported yet. */ + #pragma acc kernels + { + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop + for (j = 0; j < 10; j++) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop reduction(-:diff) + for (j = 0; j < 10; j++) + #pragma acc loop + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop reduction(-:sum) + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + } +} diff --git a/gcc/testsuite/c-c++-common/goacc/nested-reductions-warn.c b/gcc/testsuite/c-c++-common/goacc/nested-reductions-2-parallel.c similarity index 78% rename from gcc/testsuite/c-c++-common/goacc/nested-reductions-warn.c rename to gcc/testsuite/c-c++-common/goacc/nested-reductions-2-parallel.c index e2af66e4fa3..1f6b4e78293 100644 --- a/gcc/testsuite/c-c++-common/goacc/nested-reductions-warn.c +++ b/gcc/testsuite/c-c++-common/goacc/nested-reductions-2-parallel.c @@ -1,4 +1,6 @@ -/* Test erroneous cases of nested reduction loops. */ +/* Test erroneous cases of nested 'reduction' clauses. */ + +/* See also 'gfortran.dg/goacc/nested-reductions-2-parallel.f90'. */ void acc_parallel (void) { @@ -385,141 +387,3 @@ void acc_parallel_loop_reduction (void) } } } - -/* The same tests as above, but inside a routine construct. */ -#pragma acc routine gang -void acc_routine (void) -{ - int i, j, k, l, sum, diff; - - { - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop collapse(2) // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - for (j = 0; j < 10; j++) - for (k = 0; k < 10; k++) - #pragma acc loop reduction(+:sum) - for (l = 0; l < 10; l++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - for (j = 0; j < 10; j++) - #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - for (k = 0; k < 10; k++) - #pragma acc loop reduction(+:sum) - for (l = 0; l < 10; l++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) // { dg-warning "conflicting reduction operations for .sum." } - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(-:sum) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } - for (j = 0; j < 10; j++) - #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - for (k = 0; k < 10; k++) - #pragma acc loop reduction(*:sum) // { dg-warning "conflicting reduction operations for .sum." } - for (l = 0; l < 10; l++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) // { dg-warning "conflicting reduction operations for .sum." }) - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - for (k = 0; k < 10; k++) - #pragma acc loop reduction(*:sum) // { dg-warning "conflicting reduction operations for .sum." } - for (l = 0; l < 10; l++) - sum = 1; - - #pragma acc loop reduction(+:sum) reduction(-:diff) - for (i = 0; i < 10; i++) - { - #pragma acc loop reduction(-:diff) // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) // { dg-warning "nested loop in reduction needs reduction clause for .diff." } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(-:diff) - for (k = 0; k < 10; k++) - diff = 1; - } - } -} - -void acc_kernels (void) -{ - int i, j, k, sum, diff; - - /* FIXME: No diagnostics are produced for these loops because reductions - in kernels regions are not supported yet. */ - #pragma acc kernels - { - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop - for (j = 0; j < 10; j++) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop reduction(-:diff) - for (j = 0; j < 10; j++) - #pragma acc loop - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - #pragma acc loop reduction(-:sum) - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - } -} diff --git a/gcc/testsuite/c-c++-common/goacc/nested-reductions-2-routine.c b/gcc/testsuite/c-c++-common/goacc/nested-reductions-2-routine.c new file mode 100644 index 00000000000..5988d509bec --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/nested-reductions-2-routine.c @@ -0,0 +1,93 @@ +/* Test erroneous cases of nested 'reduction' clauses. */ + +/* See also 'gfortran.dg/goacc/nested-reductions-2-routine.f90'. */ + +#pragma acc routine gang +void acc_routine (void) +{ + int i, j, k, l, sum, diff; + + { + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop collapse(2) // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + for (j = 0; j < 10; j++) + for (k = 0; k < 10; k++) + #pragma acc loop reduction(+:sum) + for (l = 0; l < 10; l++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + for (j = 0; j < 10; j++) + #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + for (k = 0; k < 10; k++) + #pragma acc loop reduction(+:sum) + for (l = 0; l < 10; l++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) // { dg-warning "conflicting reduction operations for .sum." } + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(-:sum) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } + for (j = 0; j < 10; j++) + #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + for (k = 0; k < 10; k++) + #pragma acc loop reduction(*:sum) // { dg-warning "conflicting reduction operations for .sum." } + for (l = 0; l < 10; l++) + sum = 1; + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) // { dg-warning "conflicting reduction operations for .sum." }) + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + for (k = 0; k < 10; k++) + #pragma acc loop reduction(*:sum) // { dg-warning "conflicting reduction operations for .sum." } + for (l = 0; l < 10; l++) + sum = 1; + + #pragma acc loop reduction(+:sum) reduction(-:diff) + for (i = 0; i < 10; i++) + { + #pragma acc loop reduction(-:diff) // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(+:sum) // { dg-warning "nested loop in reduction needs reduction clause for .diff." } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(-:diff) + for (k = 0; k < 10; k++) + diff = 1; + } + } +} diff --git a/gcc/testsuite/gfortran.dg/goacc/nested-reductions-1-kernels.f90 b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-1-kernels.f90 new file mode 100644 index 00000000000..0999f8767c6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-1-kernels.f90 @@ -0,0 +1,55 @@ +! Test cases of nested 'reduction' clauses expected to compile cleanly. + +! See also 'c-c++-common/goacc/nested-reductions-1-kernels.c'. + +subroutine acc_kernels () + implicit none (type, external) + integer :: i, j, k, sum, diff + + ! FIXME: These tests are not meaningful yet because reductions in + ! kernels regions are not supported yet. + !$acc kernels + !$acc loop reduction(+:sum) + do i = 1, 10 + do j = 1, 10 + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop reduction(+:sum) + do j = 1, 10 + do k = 1, 10 + sum = 1 + end do + end do + end do + + + !$acc loop reduction(+:sum) + do i = 1, 10 + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + end do + + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop reduction(+:sum) + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc end kernels +end subroutine acc_kernels diff --git a/gcc/testsuite/gfortran.dg/goacc/nested-reductions.f90 b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-1-parallel.f90 similarity index 75% rename from gcc/testsuite/gfortran.dg/goacc/nested-reductions.f90 rename to gcc/testsuite/gfortran.dg/goacc/nested-reductions-1-parallel.f90 index 3becafabe62..2915d6755de 100644 --- a/gcc/testsuite/gfortran.dg/goacc/nested-reductions.f90 +++ b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-1-parallel.f90 @@ -1,4 +1,6 @@ -! Test cases of nested reduction loops that should compile cleanly. +! Test cases of nested 'reduction' clauses expected to compile cleanly. + +! See also 'c-c++-common/goacc/nested-reductions-1-parallel.c'. subroutine acc_parallel () implicit none (type, external) @@ -400,141 +402,3 @@ subroutine acc_parallel_loop_reduction () end do end do end subroutine acc_parallel_loop_reduction - -! The same tests as above, but inside a routine construct. -subroutine acc_routine () - implicit none (type, external) - !$acc routine gang - - integer :: i, j, k, sum, diff - - !$acc loop reduction(+:sum) - do i = 1, 10 - do j = 1, 10 - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop collapse(2) reduction(+:sum) - do i = 1, 10 - do j = 1, 10 - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop reduction(+:sum) - do j = 1, 10 - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop collapse(2) reduction(+:sum) - do j = 1, 10 - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop reduction(+:sum) - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) reduction(-:diff) - do i = 1, 10 - !$acc loop reduction(+:sum) - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - - !$acc loop reduction(-:diff) - do j = 1, 10 - !$acc loop reduction(-:diff) - do k = 1, 10 - diff = 1 - end do - end do - end do -end subroutine acc_routine - -subroutine acc_kernels () - implicit none (type, external) - integer :: i, j, k, sum, diff - - ! FIXME: These tests are not meaningful yet because reductions in - ! kernels regions are not supported yet. - !$acc kernels - !$acc loop reduction(+:sum) - do i = 1, 10 - do j = 1, 10 - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop reduction(+:sum) - do j = 1, 10 - do k = 1, 10 - sum = 1 - end do - end do - end do - - - !$acc loop reduction(+:sum) - do i = 1, 10 - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - end do - - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop reduction(+:sum) - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc end kernels -end subroutine acc_kernels diff --git a/gcc/testsuite/gfortran.dg/goacc/nested-reductions-1-routine.f90 b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-1-routine.f90 new file mode 100644 index 00000000000..17a586152c7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-1-routine.f90 @@ -0,0 +1,88 @@ +! Test cases of nested 'reduction' clauses expected to compile cleanly. + +! See also 'c-c++-common/goacc/nested-reductions-1-routine.c'. + +subroutine acc_routine () + implicit none (type, external) + !$acc routine gang + + integer :: i, j, k, sum, diff + + !$acc loop reduction(+:sum) + do i = 1, 10 + do j = 1, 10 + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop collapse(2) reduction(+:sum) + do i = 1, 10 + do j = 1, 10 + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop reduction(+:sum) + do j = 1, 10 + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop collapse(2) reduction(+:sum) + do j = 1, 10 + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop reduction(+:sum) + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) reduction(-:diff) + do i = 1, 10 + !$acc loop reduction(+:sum) + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + + !$acc loop reduction(-:diff) + do j = 1, 10 + !$acc loop reduction(-:diff) + do k = 1, 10 + diff = 1 + end do + end do + end do +end subroutine acc_routine diff --git a/gcc/testsuite/gfortran.dg/goacc/nested-reductions-2-kernels.f90 b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-2-kernels.f90 new file mode 100644 index 00000000000..edfd8625faf --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-2-kernels.f90 @@ -0,0 +1,63 @@ +! Test erroneous cases of nested 'reduction' clauses. + +! See also 'c-c++-common/goacc/nested-reductions-2-kernels.c'. + +subroutine acc_kernels () + integer :: i, j, k, sum, diff + + ! FIXME: No diagnostics are produced for these loops because reductions + ! in kernels regions are not supported yet. + !$acc kernels + !$acc loop reduction(+:sum) + do i = 1, 10 + do j = 1, 10 + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop + do j = 1, 10 + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop reduction(-:diff) + do j = 1, 10 + !$acc loop + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop reduction(-:sum) + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + end do + !$acc end kernels +end subroutine acc_kernels diff --git a/gcc/testsuite/gfortran.dg/goacc/nested-reductions-warn.f90 b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-2-parallel.f90 similarity index 78% rename from gcc/testsuite/gfortran.dg/goacc/nested-reductions-warn.f90 rename to gcc/testsuite/gfortran.dg/goacc/nested-reductions-2-parallel.f90 index ec36bc9616e..8fa2cabd35f 100644 --- a/gcc/testsuite/gfortran.dg/goacc/nested-reductions-warn.f90 +++ b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-2-parallel.f90 @@ -1,4 +1,6 @@ -! Test erroneous cases of nested reduction loops. +! Test erroneous cases of nested 'reduction' clauses. + +! See also 'c-c++-common/goacc/nested-reductions-2-parallel.c'. subroutine acc_parallel () implicit none (type, external) @@ -495,180 +497,3 @@ subroutine acc_parallel_loop_reduction () end do end do end subroutine acc_parallel_loop_reduction - -! The same tests as above, but inside a routine construct. -subroutine acc_routine () - implicit none (type, external) - !$acc routine gang - integer :: i, j, k, l, sum, diff - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop collapse(2) ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - do j = 1, 10 - do k = 1, 10 - !$acc loop reduction(+:sum) - do l = 1, 10 - sum = 1 - end do - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - do j = 1, 10 - !$acc loop ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - do k = 1, 10 - !$acc loop reduction(+:sum) - do l = 1, 10 - sum = 1 - end do - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } - do j = 1, 10 - !$acc loop reduction(+:sum) ! { dg-warning "conflicting reduction operations for .sum." } - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } - do j = 1, 10 - !$acc loop reduction(-:sum) - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } - do j = 1, 10 - !$acc loop ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - do k = 1, 10 - !$acc loop reduction(*:sum) ! { dg-warning "conflicting reduction operations for .sum." } - do l = 1, 10 - sum = 1 - end do - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } - do j = 1, 10 - !$acc loop reduction(+:sum) ! { dg-warning "conflicting reduction operations for .sum." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - do k = 1, 10 - !$acc loop reduction(*:sum) ! { dg-warning "conflicting reduction operations for .sum." } - do l = 1, 10 - sum = 1 - end do - end do - end do - end do - - !$acc loop reduction(+:sum) reduction(-:diff) - do i = 1, 10 - !$acc loop reduction(-:diff) ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - - !$acc loop reduction(+:sum) ! { dg-warning "nested loop in reduction needs reduction clause for .diff." } - do j = 1, 10 - !$acc loop reduction(-:diff) - do k = 1, 10 - diff = 1 - end do - end do - end do -end subroutine acc_routine - -subroutine acc_kernels () - integer :: i, j, k, sum, diff - - ! FIXME: No diagnostics are produced for these loops because reductions - ! in kernels regions are not supported yet. - !$acc kernels - !$acc loop reduction(+:sum) - do i = 1, 10 - do j = 1, 10 - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop - do j = 1, 10 - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop reduction(-:diff) - do j = 1, 10 - !$acc loop - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop reduction(-:sum) - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - end do - !$acc end kernels -end subroutine acc_kernels diff --git a/gcc/testsuite/gfortran.dg/goacc/nested-reductions-2-routine.f90 b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-2-routine.f90 new file mode 100644 index 00000000000..cc7802ecd10 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-2-routine.f90 @@ -0,0 +1,119 @@ +! Test erroneous cases of nested 'reduction' clauses. + +! See also 'c-c++-common/goacc/nested-reductions-2-routine.c'. + +subroutine acc_routine () + implicit none (type, external) + !$acc routine gang + integer :: i, j, k, l, sum, diff + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop collapse(2) ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + do j = 1, 10 + do k = 1, 10 + !$acc loop reduction(+:sum) + do l = 1, 10 + sum = 1 + end do + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + do j = 1, 10 + !$acc loop ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + do k = 1, 10 + !$acc loop reduction(+:sum) + do l = 1, 10 + sum = 1 + end do + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } + do j = 1, 10 + !$acc loop reduction(+:sum) ! { dg-warning "conflicting reduction operations for .sum." } + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } + do j = 1, 10 + !$acc loop reduction(-:sum) + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } + do j = 1, 10 + !$acc loop ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + do k = 1, 10 + !$acc loop reduction(*:sum) ! { dg-warning "conflicting reduction operations for .sum." } + do l = 1, 10 + sum = 1 + end do + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } + do j = 1, 10 + !$acc loop reduction(+:sum) ! { dg-warning "conflicting reduction operations for .sum." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + do k = 1, 10 + !$acc loop reduction(*:sum) ! { dg-warning "conflicting reduction operations for .sum." } + do l = 1, 10 + sum = 1 + end do + end do + end do + end do + + !$acc loop reduction(+:sum) reduction(-:diff) + do i = 1, 10 + !$acc loop reduction(-:diff) ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + + !$acc loop reduction(+:sum) ! { dg-warning "nested loop in reduction needs reduction clause for .diff." } + do j = 1, 10 + !$acc loop reduction(-:diff) + do k = 1, 10 + diff = 1 + end do + end do + end do +end subroutine acc_routine -- 2.30.2