Warn about inconsistent OpenACC nested reduction clauses
authorFrederik Harwath <frederik@gcc.gnu.org>
Wed, 6 Nov 2019 10:43:52 +0000 (10:43 +0000)
committerFrederik Harwath <frederik@gcc.gnu.org>
Wed, 6 Nov 2019 10:43:52 +0000 (10:43 +0000)
commit5d183d1740d8d8b84991f186ce4d992ee799536f
tree3445dfb2c8e435ce0d5878394fbc00b923de7eab
parent5f6705b7b57c0461766f784d6d495986163692bb
Warn about inconsistent OpenACC nested reduction clauses

OpenACC (cf. OpenACC 2.7, section 2.9.11. "reduction clause";
this was first clarified by OpenACC 2.6) requires that, if a
variable is used in reduction clauses on two nested loops, then
there must be reduction clauses for that variable on all loops
that are nested in between the two loops and all these reduction
clauses must use the same operator.
This commit introduces a check for that property which reports
warnings if it is violated.

2019-11-06  Gergö Barany  <gergo@codesourcery.com>
            Frederik Harwath  <frederik@codesourcery.com>
            Thomas Schwinge  <thomas@codesourcery.com>

gcc/
* omp-low.c (struct omp_context): New fields
local_reduction_clauses, outer_reduction_clauses.
(new_omp_context): Initialize these.
(scan_sharing_clauses): Record reduction clauses on OpenACC constructs.
(scan_omp_for): Check reduction clauses for incorrect nesting.
gcc/testsuite/
* c-c++-common/goacc/nested-reductions-warn.c: New test.
* c-c++-common/goacc/nested-reductions.c: New test.
* gfortran.dg/goacc/nested-reductions-warn.f90: New test.
* gfortran.dg/goacc/nested-reductions.f90: New test.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-1.c:
Add expected warnings about missing reduction clauses.
* testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-3.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-4.c:
Likewise.

Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
From-SVN: r277875
12 files changed:
gcc/ChangeLog
gcc/omp-low.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/goacc/nested-reductions-warn.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/goacc/nested-reductions.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/goacc/nested-reductions-warn.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/goacc/nested-reductions.f90 [new file with mode: 0644]
libgomp/ChangeLog
libgomp/testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-1.c
libgomp/testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c
libgomp/testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-3.c
libgomp/testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-4.c