diff options
author | Julian Brown <julian@codesourcery.com> | 2022-10-12 20:44:57 +0000 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2022-10-28 10:17:34 +0200 |
commit | 11e811d8e2f63667f60f73731bb934273f5882b8 (patch) | |
tree | 008e6f5e9504992b24cb6d8a433645bb5647a1a4 /gcc | |
parent | 0607307768b66a90e27c5bc91a247acc938f070e (diff) | |
download | gcc-11e811d8e2f63667f60f73731bb934273f5882b8.zip gcc-11e811d8e2f63667f60f73731bb934273f5882b8.tar.gz gcc-11e811d8e2f63667f60f73731bb934273f5882b8.tar.bz2 |
OpenACC: Don't gang-privatize artificial variables [PR90115]
This patch prevents compiler-generated artificial variables from being
treated as privatization candidates for OpenACC.
The rationale is that e.g. "gang-private" variables actually must be
shared by each worker and vector spawned within a particular gang, but
that sharing is not necessary for any compiler-generated variable (at
least at present, but no such need is anticipated either). Variables on
the stack (and machine registers) are already private per-"thread"
(gang, worker and/or vector), and that's fine for artificial variables.
We're restricting this to blocks, as we still need to understand what it
means for a 'DECL_ARTIFICIAL' to appear in a 'private' clause.
Several tests need their scan output patterns adjusted to compensate.
2022-10-14 Julian Brown <julian@codesourcery.com>
PR middle-end/90115
gcc/
* omp-low.cc (oacc_privatization_candidate_p): Artificial vars are not
privatization candidates.
libgomp/
* testsuite/libgomp.oacc-fortran/declare-1.f90: Adjust scan output.
* testsuite/libgomp.oacc-fortran/host_data-5.F90: Likewise.
* testsuite/libgomp.oacc-fortran/if-1.f90: Likewise.
* testsuite/libgomp.oacc-fortran/print-1.f90: Likewise.
* testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Likewise.
Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/omp-low.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc index a880973..82a93d0 100644 --- a/gcc/omp-low.cc +++ b/gcc/omp-low.cc @@ -10710,6 +10710,28 @@ oacc_privatization_candidate_p (const location_t loc, const tree c, } } + /* If an artificial variable has been added to a bind, e.g. + a compiler-generated temporary structure used by the Fortran front-end, do + not consider it as a privatization candidate. Note that variables on + the stack are private per-thread by default: making them "gang-private" + for OpenACC actually means to share a single instance of a variable + amongst all workers and threads spawned within each gang. + At present, no compiler-generated artificial variables require such + sharing semantics, so this is safe. */ + + if (res && block && DECL_ARTIFICIAL (decl)) + { + res = false; + + if (dump_enabled_p ()) + { + oacc_privatization_begin_diagnose_var (l_dump_flags, loc, c, decl); + dump_printf (l_dump_flags, + "isn%'t candidate for adjusting OpenACC privatization " + "level: %s\n", "artificial"); + } + } + if (res) { if (dump_enabled_p ()) |