From: Thomas Schwinge Date: Thu, 22 Oct 2020 07:45:31 +0000 (+0200) Subject: [OpenACC] Split up testcases for inconsistent nested 'reduction' clauses checking X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fedf3e94efe774b8c0539d344130a7b25f50a881;p=gcc.git [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. --- 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-1-parallel.c b/gcc/testsuite/c-c++-common/goacc/nested-reductions-1-parallel.c new file mode 100644 index 00000000000..ce1d0a13527 --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/nested-reductions-1-parallel.c @@ -0,0 +1,318 @@ +/* Test cases of nested 'reduction' clauses expected to compile cleanly. */ + +/* See also 'gfortran.dg/goacc/nested-reductions-1-parallel.f90'. */ + +void acc_parallel (void) +{ + int i, j, k, sum, diff; + + #pragma acc parallel + { + #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; + } + } +} + +/* The same tests as above, but using a combined parallel loop construct. */ + +void acc_parallel_loop (void) +{ + int i, j, k, l, sum, diff; + + #pragma acc parallel loop + for (int h = 0; h < 10; ++h) + { + #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) // { dg-warning "insufficient partitioning available to parallelize 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) reduction(-:diff) + for (i = 0; i < 10; i++) + { + #pragma acc loop reduction(+:sum) // { dg-warning "insufficient partitioning available to parallelize loop" } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(-:diff) // { dg-warning "insufficient partitioning available to parallelize loop" } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(-:diff) + for (k = 0; k < 10; k++) + diff = 1; + } + } +} + +/* The same tests as above, but now the outermost reduction clause is on + the parallel region, not the outermost loop. */ + +void acc_parallel_reduction (void) +{ + int i, j, k, sum, diff; + + #pragma acc parallel reduction(+:sum) + { + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + for (k = 0; k < 10; k++) + sum = 1; + + 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++) + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + + for (i = 0; i < 10; i++) + 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 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; + } + + #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(-:diff) + for (j = 0; j < 10; j++) + #pragma acc loop reduction(-:diff) + for (k = 0; k < 10; k++) + diff = 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 + for (j = 0; j < 10; j++) + #pragma acc loop reduction(-:diff) + for (k = 0; k < 10; k++) + diff = 1; + } + } +} + +/* The same tests as above, but using a combined parallel loop construct, and + the outermost reduction clause is on that one, not the outermost loop. */ +void acc_parallel_loop_reduction (void) +{ + int i, j, k, sum, diff; + + #pragma acc parallel loop reduction(+:sum) + for (int h = 0; h < 10; ++h) + { + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + for (k = 0; k < 10; k++) + sum = 1; + + 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++) + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + + for (i = 0; i < 10; i++) + 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 reduction(+:sum) // { dg-warning "insufficient partitioning available to parallelize 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) reduction(-:diff) + for (i = 0; i < 10; i++) + { + #pragma acc loop reduction(+:sum) // { dg-warning "insufficient partitioning available to parallelize loop" } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(-:diff) // { dg-warning "insufficient partitioning available to parallelize loop" } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(-:diff) + for (k = 0; k < 10; k++) + diff = 1; + } + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + { + #pragma acc loop reduction(+:sum) // { dg-warning "insufficient partitioning available to parallelize loop" } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(-:diff) // { dg-warning "insufficient partitioning available to parallelize loop" } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(-:diff) + for (k = 0; k < 10; k++) + diff = 1; + } + + #pragma acc loop reduction(+:sum) + for (i = 0; i < 10; i++) + { + #pragma acc loop reduction(+:sum) // { dg-warning "insufficient partitioning available to parallelize loop" } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop // { dg-warning "insufficient partitioning available to parallelize loop" } + 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-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-2-parallel.c b/gcc/testsuite/c-c++-common/goacc/nested-reductions-2-parallel.c new file mode 100644 index 00000000000..1f6b4e78293 --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/nested-reductions-2-parallel.c @@ -0,0 +1,389 @@ +/* Test erroneous cases of nested 'reduction' clauses. */ + +/* See also 'gfortran.dg/goacc/nested-reductions-2-parallel.f90'. */ + +void acc_parallel (void) +{ + int i, j, k, l, sum, diff; + + #pragma acc parallel + { + #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; + } + } +} + +/* The same tests as above, but using a combined parallel loop construct. */ + +void acc_parallel_loop (void) +{ + int i, j, k, l, sum, diff; + + #pragma acc parallel loop + for (int h = 0; h < 10; ++h) + { + #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." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(-:diff) + for (k = 0; k < 10; k++) + diff = 1; + } + } +} + +/* The same tests as above, but now the outermost reduction clause is on + the parallel region, not the outermost loop. */ +void acc_parallel_reduction (void) +{ + int i, j, k, l, sum, diff; + + #pragma acc parallel reduction(+:sum) + { + #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .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 // { dg-warning "nested loop in reduction needs reduction clause for .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 // { dg-warning "nested loop in reduction needs reduction clause for .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 // { dg-warning "nested loop in reduction needs reduction clause for .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 // { dg-warning "nested loop in reduction needs reduction clause for .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(max:sum) // { dg-warning "conflicting reduction operations for .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(max:sum) // { dg-warning "conflicting reduction operations for .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(-:diff) // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + 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; + } + } +} + +/* The same tests as above, but using a combined parallel loop construct, and + the outermost reduction clause is on that one, not the outermost loop. */ +void acc_parallel_loop_reduction (void) +{ + int i, j, k, l, sum, diff; + + #pragma acc parallel loop reduction(+:sum) + for (int h = 0; h < 10; ++h) + { + #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + for (i = 0; i < 10; i++) + #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 (j = 0; j < 10; j++) + #pragma acc loop reduction(+:sum) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + for (i = 0; i < 10; i++) + #pragma acc loop collapse(2) // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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 // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + for (i = 0; i < 10; i++) + #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 (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 // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + for (i = 0; i < 10; i++) + #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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 // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + for (i = 0; i < 10; i++) + #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + for (j = 0; j < 10; j++) + #pragma acc loop reduction(-:sum) + for (k = 0; k < 10; k++) + sum = 1; + + #pragma acc loop reduction(max:sum) // { dg-warning "conflicting reduction operations for .sum." } + for (i = 0; i < 10; i++) + #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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(max:sum) // { dg-warning "conflicting reduction operations for .sum." } + for (i = 0; i < 10; i++) + #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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(-:diff) // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + for (i = 0; i < 10; i++) + { + #pragma acc loop reduction(-:diff) // { dg-warning "nested loop in reduction needs reduction clause for .sum." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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-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/c-c++-common/goacc/nested-reductions-warn.c b/gcc/testsuite/c-c++-common/goacc/nested-reductions-warn.c deleted file mode 100644 index e2af66e4fa3..00000000000 --- a/gcc/testsuite/c-c++-common/goacc/nested-reductions-warn.c +++ /dev/null @@ -1,525 +0,0 @@ -/* Test erroneous cases of nested reduction loops. */ - -void acc_parallel (void) -{ - int i, j, k, l, sum, diff; - - #pragma acc parallel - { - #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; - } - } -} - -/* The same tests as above, but using a combined parallel loop construct. */ - -void acc_parallel_loop (void) -{ - int i, j, k, l, sum, diff; - - #pragma acc parallel loop - for (int h = 0; h < 10; ++h) - { - #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." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(-:diff) - for (k = 0; k < 10; k++) - diff = 1; - } - } -} - -/* The same tests as above, but now the outermost reduction clause is on - the parallel region, not the outermost loop. */ -void acc_parallel_reduction (void) -{ - int i, j, k, l, sum, diff; - - #pragma acc parallel reduction(+:sum) - { - #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .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 // { dg-warning "nested loop in reduction needs reduction clause for .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 // { dg-warning "nested loop in reduction needs reduction clause for .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 // { dg-warning "nested loop in reduction needs reduction clause for .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 // { dg-warning "nested loop in reduction needs reduction clause for .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(max:sum) // { dg-warning "conflicting reduction operations for .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(max:sum) // { dg-warning "conflicting reduction operations for .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(-:diff) // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - 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; - } - } -} - -/* The same tests as above, but using a combined parallel loop construct, and - the outermost reduction clause is on that one, not the outermost loop. */ -void acc_parallel_loop_reduction (void) -{ - int i, j, k, l, sum, diff; - - #pragma acc parallel loop reduction(+:sum) - for (int h = 0; h < 10; ++h) - { - #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - for (i = 0; i < 10; i++) - #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 (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - for (i = 0; i < 10; i++) - #pragma acc loop collapse(2) // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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 // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - for (i = 0; i < 10; i++) - #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 (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 // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - for (i = 0; i < 10; i++) - #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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 // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - for (i = 0; i < 10; i++) - #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(-:sum) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(max:sum) // { dg-warning "conflicting reduction operations for .sum." } - for (i = 0; i < 10; i++) - #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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(max:sum) // { dg-warning "conflicting reduction operations for .sum." } - for (i = 0; i < 10; i++) - #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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(-:diff) // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - for (i = 0; i < 10; i++) - { - #pragma acc loop reduction(-:diff) // { dg-warning "nested loop in reduction needs reduction clause for .sum." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(-:diff) - for (k = 0; k < 10; k++) - diff = 1; - } - } -} - -/* 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.c b/gcc/testsuite/c-c++-common/goacc/nested-reductions.c deleted file mode 100644 index 15385c4da99..00000000000 --- a/gcc/testsuite/c-c++-common/goacc/nested-reductions.c +++ /dev/null @@ -1,420 +0,0 @@ -/* Test cases of nested reduction loops that should compile cleanly. */ - -void acc_parallel (void) -{ - int i, j, k, sum, diff; - - #pragma acc parallel - { - #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; - } - } -} - -/* The same tests as above, but using a combined parallel loop construct. */ - -void acc_parallel_loop (void) -{ - int i, j, k, l, sum, diff; - - #pragma acc parallel loop - for (int h = 0; h < 10; ++h) - { - #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) // { dg-warning "insufficient partitioning available to parallelize 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) reduction(-:diff) - for (i = 0; i < 10; i++) - { - #pragma acc loop reduction(+:sum) // { dg-warning "insufficient partitioning available to parallelize loop" } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(-:diff) // { dg-warning "insufficient partitioning available to parallelize loop" } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(-:diff) - for (k = 0; k < 10; k++) - diff = 1; - } - } -} - -/* The same tests as above, but now the outermost reduction clause is on - the parallel region, not the outermost loop. */ - -void acc_parallel_reduction (void) -{ - int i, j, k, sum, diff; - - #pragma acc parallel reduction(+:sum) - { - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - for (k = 0; k < 10; k++) - sum = 1; - - 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++) - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - - for (i = 0; i < 10; i++) - 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 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; - } - - #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(-:diff) - for (j = 0; j < 10; j++) - #pragma acc loop reduction(-:diff) - for (k = 0; k < 10; k++) - diff = 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 - for (j = 0; j < 10; j++) - #pragma acc loop reduction(-:diff) - for (k = 0; k < 10; k++) - diff = 1; - } - } -} - -/* The same tests as above, but using a combined parallel loop construct, and - the outermost reduction clause is on that one, not the outermost loop. */ -void acc_parallel_loop_reduction (void) -{ - int i, j, k, sum, diff; - - #pragma acc parallel loop reduction(+:sum) - for (int h = 0; h < 10; ++h) - { - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - for (k = 0; k < 10; k++) - sum = 1; - - 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++) - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - - for (i = 0; i < 10; i++) - 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 reduction(+:sum) // { dg-warning "insufficient partitioning available to parallelize 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) reduction(-:diff) - for (i = 0; i < 10; i++) - { - #pragma acc loop reduction(+:sum) // { dg-warning "insufficient partitioning available to parallelize loop" } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(-:diff) // { dg-warning "insufficient partitioning available to parallelize loop" } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(-:diff) - for (k = 0; k < 10; k++) - diff = 1; - } - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - { - #pragma acc loop reduction(+:sum) // { dg-warning "insufficient partitioning available to parallelize loop" } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop reduction(-:diff) // { dg-warning "insufficient partitioning available to parallelize loop" } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(-:diff) - for (k = 0; k < 10; k++) - diff = 1; - } - - #pragma acc loop reduction(+:sum) - for (i = 0; i < 10; i++) - { - #pragma acc loop reduction(+:sum) // { dg-warning "insufficient partitioning available to parallelize loop" } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(+:sum) - for (k = 0; k < 10; k++) - sum = 1; - - #pragma acc loop // { dg-warning "insufficient partitioning available to parallelize loop" } - for (j = 0; j < 10; j++) - #pragma acc loop reduction(-:diff) - for (k = 0; k < 10; k++) - diff = 1; - } - } -} - -/* 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/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-1-parallel.f90 b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-1-parallel.f90 new file mode 100644 index 00000000000..2915d6755de --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-1-parallel.f90 @@ -0,0 +1,404 @@ +! 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) + integer :: i, j, k, sum, diff + + !$acc parallel + !$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 + !$acc end parallel +end subroutine acc_parallel + +! The same tests as above, but using a combined parallel loop construct. + +subroutine acc_parallel_loop () + implicit none (type, external) + integer :: h, i, j, k, l, sum, diff + + !$acc parallel loop + do h = 1, 10 + !$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) ! { dg-warning "insufficient partitioning available to parallelize 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) reduction(-:diff) + do i = 1, 10 + !$acc loop reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize loop" } + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + + !$acc loop reduction(-:diff) ! { dg-warning "insufficient partitioning available to parallelize loop" } + do j = 1, 10 + !$acc loop reduction(-:diff) + do k = 1, 10 + diff = 1 + end do + end do + end do + end do +end subroutine acc_parallel_loop + +! The same tests as above, but now the outermost reduction clause is on +! the parallel region, not the outermost loop. */ + +subroutine acc_parallel_reduction () + implicit none (type, external) + integer :: i, j, k, sum, diff + + !$acc parallel reduction(+:sum) + do i = 1, 10 + do j = 1, 10 + do k = 1, 10 + sum = 1 + end do + end do + end do + + 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 + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + end do + + do i = 1, 10 + 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 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 + + !$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 + + !$acc loop reduction(-:diff) + do j = 1, 10 + !$acc loop reduction(-:diff) + do k = 1, 10 + diff = 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 + + !$acc loop + do j = 1, 10 + !$acc loop reduction(-:diff) + do k = 1, 10 + diff = 1 + end do + end do + end do + !$acc end parallel +end subroutine acc_parallel_reduction + +! The same tests as above, but using a combined parallel loop construct, and +! the outermost reduction clause is on that one, not the outermost loop. */ +subroutine acc_parallel_loop_reduction () + implicit none (type, external) + integer :: h, i, j, k, sum, diff + + !$acc parallel loop reduction(+:sum) + do h = 1, 10 + do i = 1, 10 + do j = 1, 10 + do k = 1, 10 + sum = 1 + end do + end do + end do + + 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 + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + end do + + do i = 1, 10 + 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 reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize 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) reduction(-:diff) + do i = 1, 10 + !$acc loop reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize loop" } + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + + !$acc loop reduction(-:diff) ! { dg-warning "insufficient partitioning available to parallelize loop" } + do j = 1, 10 + !$acc loop reduction(-:diff) + do k = 1, 10 + diff = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize loop" } + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + + !$acc loop reduction(-:diff) ! { dg-warning "insufficient partitioning available to parallelize loop" } + do j = 1, 10 + !$acc loop reduction(-:diff) + do k = 1, 10 + diff = 1 + end do + end do + end do + + !$acc loop reduction(+:sum) + do i = 1, 10 + !$acc loop reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize loop" } + do j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + + !$acc loop ! { dg-warning "insufficient partitioning available to parallelize loop" } + do j = 1, 10 + !$acc loop reduction(-:diff) + do k = 1, 10 + diff = 1 + end do + end do + end do + end do +end subroutine acc_parallel_loop_reduction 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-2-parallel.f90 b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-2-parallel.f90 new file mode 100644 index 00000000000..8fa2cabd35f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-2-parallel.f90 @@ -0,0 +1,499 @@ +! 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) + integer :: i, j, k, l, sum, diff + + !$acc parallel + !$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 + !$acc end parallel +end subroutine acc_parallel + +! The same tests as above, but using a combined parallel loop construct. + +subroutine acc_parallel_loop () + implicit none (type, external) + integer :: h, i, j, k, l, sum, diff + + !$acc parallel loop + do h = 1, 10 + !$acc loop reduction(+:sum) + do i = 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 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." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + do j = 1, 10 + !$acc loop reduction(-:diff) + do k = 1, 10 + diff = 1 + end do + end do + end do + end do +end subroutine acc_parallel_loop + +! The same tests as above, but now the outermost reduction clause is on +! the parallel region, not the outermost loop. + +subroutine acc_parallel_reduction () + implicit none (type, external) + integer :: i, j, k, l, sum, diff + + !$acc parallel reduction(+:sum) + !$acc loop ! { dg-warning "nested loop in reduction needs reduction clause for .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 ! { dg-warning "nested loop in reduction needs reduction clause for .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 ! { dg-warning "nested loop in reduction needs reduction clause for .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 ! { dg-warning "nested loop in reduction needs reduction clause for .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 ! { dg-warning "nested loop in reduction needs reduction clause for .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(max:sum) ! { dg-warning "conflicting reduction operations for .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(max:sum) ! { dg-warning "conflicting reduction operations for .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(-:diff) ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + 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 + !$acc end parallel +end subroutine acc_parallel_reduction + +! The same tests as above, but using a combined parallel loop construct, and +! the outermost reduction clause is on that one, not the outermost loop. */ +subroutine acc_parallel_loop_reduction () + implicit none (type, external) + integer :: h, i, j, k, l, sum, diff + + !$acc parallel loop reduction(+:sum) + do h = 1, 10 + !$acc loop ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + do i = 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 j = 1, 10 + !$acc loop reduction(+:sum) + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + do i = 1, 10 + !$acc loop collapse(2) ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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 ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + do i = 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 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 ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + do i = 1, 10 + !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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 ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + do i = 1, 10 + !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + do j = 1, 10 + !$acc loop reduction(-:sum) + do k = 1, 10 + sum = 1 + end do + end do + end do + + !$acc loop reduction(max:sum) ! { dg-warning "conflicting reduction operations for .sum." } + do i = 1, 10 + !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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(max:sum) ! { dg-warning "conflicting reduction operations for .sum." } + do i = 1, 10 + !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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(-:diff) ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + do i = 1, 10 + !$acc loop reduction(-:diff) ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + 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." } + ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } + do j = 1, 10 + !$acc loop reduction(-:diff) + do k = 1, 10 + diff = 1 + end do + end do + end do + end do +end subroutine acc_parallel_loop_reduction 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 diff --git a/gcc/testsuite/gfortran.dg/goacc/nested-reductions-warn.f90 b/gcc/testsuite/gfortran.dg/goacc/nested-reductions-warn.f90 deleted file mode 100644 index ec36bc9616e..00000000000 --- a/gcc/testsuite/gfortran.dg/goacc/nested-reductions-warn.f90 +++ /dev/null @@ -1,674 +0,0 @@ -! Test erroneous cases of nested reduction loops. - -subroutine acc_parallel () - implicit none (type, external) - integer :: i, j, k, l, sum, diff - - !$acc parallel - !$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 - !$acc end parallel -end subroutine acc_parallel - -! The same tests as above, but using a combined parallel loop construct. - -subroutine acc_parallel_loop () - implicit none (type, external) - integer :: h, i, j, k, l, sum, diff - - !$acc parallel loop - do h = 1, 10 - !$acc loop reduction(+:sum) - do i = 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 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." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - do j = 1, 10 - !$acc loop reduction(-:diff) - do k = 1, 10 - diff = 1 - end do - end do - end do - end do -end subroutine acc_parallel_loop - -! The same tests as above, but now the outermost reduction clause is on -! the parallel region, not the outermost loop. - -subroutine acc_parallel_reduction () - implicit none (type, external) - integer :: i, j, k, l, sum, diff - - !$acc parallel reduction(+:sum) - !$acc loop ! { dg-warning "nested loop in reduction needs reduction clause for .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 ! { dg-warning "nested loop in reduction needs reduction clause for .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 ! { dg-warning "nested loop in reduction needs reduction clause for .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 ! { dg-warning "nested loop in reduction needs reduction clause for .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 ! { dg-warning "nested loop in reduction needs reduction clause for .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(max:sum) ! { dg-warning "conflicting reduction operations for .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(max:sum) ! { dg-warning "conflicting reduction operations for .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(-:diff) ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - 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 - !$acc end parallel -end subroutine acc_parallel_reduction - -! The same tests as above, but using a combined parallel loop construct, and -! the outermost reduction clause is on that one, not the outermost loop. */ -subroutine acc_parallel_loop_reduction () - implicit none (type, external) - integer :: h, i, j, k, l, sum, diff - - !$acc parallel loop reduction(+:sum) - do h = 1, 10 - !$acc loop ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - do i = 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 j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - do i = 1, 10 - !$acc loop collapse(2) ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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 ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - do i = 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 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 ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - do i = 1, 10 - !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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 ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - do i = 1, 10 - !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - do j = 1, 10 - !$acc loop reduction(-:sum) - do k = 1, 10 - sum = 1 - end do - end do - end do - - !$acc loop reduction(max:sum) ! { dg-warning "conflicting reduction operations for .sum." } - do i = 1, 10 - !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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(max:sum) ! { dg-warning "conflicting reduction operations for .sum." } - do i = 1, 10 - !$acc loop reduction(-:sum) ! { dg-warning "conflicting reduction operations for .sum." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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(-:diff) ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - do i = 1, 10 - !$acc loop reduction(-:diff) ! { dg-warning "nested loop in reduction needs reduction clause for .sum." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - 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." } - ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 } - do j = 1, 10 - !$acc loop reduction(-:diff) - do k = 1, 10 - diff = 1 - end do - end do - 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.f90 b/gcc/testsuite/gfortran.dg/goacc/nested-reductions.f90 deleted file mode 100644 index 3becafabe62..00000000000 --- a/gcc/testsuite/gfortran.dg/goacc/nested-reductions.f90 +++ /dev/null @@ -1,540 +0,0 @@ -! Test cases of nested reduction loops that should compile cleanly. - -subroutine acc_parallel () - implicit none (type, external) - integer :: i, j, k, sum, diff - - !$acc parallel - !$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 - !$acc end parallel -end subroutine acc_parallel - -! The same tests as above, but using a combined parallel loop construct. - -subroutine acc_parallel_loop () - implicit none (type, external) - integer :: h, i, j, k, l, sum, diff - - !$acc parallel loop - do h = 1, 10 - !$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) ! { dg-warning "insufficient partitioning available to parallelize 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) reduction(-:diff) - do i = 1, 10 - !$acc loop reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize loop" } - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - - !$acc loop reduction(-:diff) ! { dg-warning "insufficient partitioning available to parallelize loop" } - do j = 1, 10 - !$acc loop reduction(-:diff) - do k = 1, 10 - diff = 1 - end do - end do - end do - end do -end subroutine acc_parallel_loop - -! The same tests as above, but now the outermost reduction clause is on -! the parallel region, not the outermost loop. */ - -subroutine acc_parallel_reduction () - implicit none (type, external) - integer :: i, j, k, sum, diff - - !$acc parallel reduction(+:sum) - do i = 1, 10 - do j = 1, 10 - do k = 1, 10 - sum = 1 - end do - end do - end do - - 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 - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - end do - - do i = 1, 10 - 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 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 - - !$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 - - !$acc loop reduction(-:diff) - do j = 1, 10 - !$acc loop reduction(-:diff) - do k = 1, 10 - diff = 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 - - !$acc loop - do j = 1, 10 - !$acc loop reduction(-:diff) - do k = 1, 10 - diff = 1 - end do - end do - end do - !$acc end parallel -end subroutine acc_parallel_reduction - -! The same tests as above, but using a combined parallel loop construct, and -! the outermost reduction clause is on that one, not the outermost loop. */ -subroutine acc_parallel_loop_reduction () - implicit none (type, external) - integer :: h, i, j, k, sum, diff - - !$acc parallel loop reduction(+:sum) - do h = 1, 10 - do i = 1, 10 - do j = 1, 10 - do k = 1, 10 - sum = 1 - end do - end do - end do - - 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 - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - end do - - do i = 1, 10 - 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 reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize 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) reduction(-:diff) - do i = 1, 10 - !$acc loop reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize loop" } - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - - !$acc loop reduction(-:diff) ! { dg-warning "insufficient partitioning available to parallelize loop" } - do j = 1, 10 - !$acc loop reduction(-:diff) - do k = 1, 10 - diff = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize loop" } - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - - !$acc loop reduction(-:diff) ! { dg-warning "insufficient partitioning available to parallelize loop" } - do j = 1, 10 - !$acc loop reduction(-:diff) - do k = 1, 10 - diff = 1 - end do - end do - end do - - !$acc loop reduction(+:sum) - do i = 1, 10 - !$acc loop reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize loop" } - do j = 1, 10 - !$acc loop reduction(+:sum) - do k = 1, 10 - sum = 1 - end do - end do - - !$acc loop ! { dg-warning "insufficient partitioning available to parallelize loop" } - do j = 1, 10 - !$acc loop reduction(-:diff) - do k = 1, 10 - diff = 1 - end do - end do - 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