Wait at end of OpenACC asynchronous kernels regions
authorJulian Brown <julian@codesourcery.com>
Fri, 9 Aug 2019 20:01:33 +0000 (13:01 -0700)
committerThomas Schwinge <thomas@codesourcery.com>
Thu, 13 Jan 2022 09:42:17 +0000 (10:42 +0100)
commite52253bcc0916d9a7c7ba4bbe7501ae1ded3b8a8
treef3db6f02e83c461c74ebcac56f2558a7f3936fe4
parent9b32c1669aad5459dd053424f9967011348add83
Wait at end of OpenACC asynchronous kernels regions

In OpenACC 'kernels' decomposition, we're improperly nesting synchronous and
asynchronous data and compute regions, giving rise to data races when the
asynchronicity is actually executed, as is visible in at least on test case
with GCN offloading.

The proper fix is to correctly use the asynchronous interfaces, making the
currently synchronous data regions fully asynchronous (see also
<https://gcc.gnu.org/PR97390> "[OpenACC] 'async' clause on 'data' construct",
which is to share the same implementation), but that's for later; for now add
some more synchronization.

gcc/
* omp-oacc-kernels-decompose.cc (add_wait): New function, split out
of...
(add_async_clauses_and_wait): ...here. Call new outlined function.
(decompose_kernels_region_body): Add wait at the end of
explicitly-asynchronous kernels regions.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/f-asyncwait-1.c: Remove GCN
offloading execution XFAIL.

Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com>
gcc/omp-oacc-kernels-decompose.cc
libgomp/testsuite/libgomp.oacc-c-c++-common/f-asyncwait-1.c