]> git.ipfire.org Git - thirdparty/gcc.git/commit
OpenACC: Improve implicit mapping for non-lexically nested offload regions
authorJulian Brown <julian@codesourcery.com>
Sat, 10 Jun 2023 15:17:19 +0000 (15:17 +0000)
committerPaul-Antoine Arras <parras@baylibre.com>
Thu, 27 Jun 2024 15:58:11 +0000 (17:58 +0200)
commitb918a7e4b4bdf070bfa9ede48ef9d22f89ff7795
tree733d1cd2b631c8001d0f00ee7336bac20e8881a1
parent5813266ee2fc9f9f9e90e44f72bde348411318e4
OpenACC: Improve implicit mapping for non-lexically nested offload regions

This patch enables use of the OMP_CLAUSE_RUNTIME_IMPLICIT_P flag for
OpenACC.

This allows code like this to work correctly:

  int arr[100];
  [...]
  #pragma acc enter data copyin(arr[20:10])

  /* No explicit mapping of 'arr' here.  */
  #pragma acc parallel
  { /* use of arr[20:10]... */ }

  #pragma acc exit data copyout(arr[20:10])

Otherwise, the implicit "copy" ("present_or_copy") on the parallel
corresponds to the whole array, and that fails at runtime when the
subarray is mapped.

The numbering of the GOMP_MAP_IMPLICIT bit clashes with the OpenACC
"non-contiguous" dynamic array support, so the GOMP_MAP_NONCONTIG_ARRAY_P
macro has been adjusted to account for that.

This behaviour relates to upstream OpenACC issue 490 (not yet resolved).

2023-06-16  Julian Brown  <julian@codesourcery.com>

gcc/
* gimplify.cc (gimplify_adjust_omp_clauses_1): Set
OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P for OpenACC also.

gcc/testsuite/
* c-c++-common/goacc/combined-reduction.c: Adjust scan output.
* c-c++-common/goacc/reduction-1.c: Likewise.
* c-c++-common/goacc/reduction-2.c: Likewise.
* c-c++-common/goacc/reduction-3.c: Likewise.
* c-c++-common/goacc/reduction-4.c: Likewise.
* c-c++-common/goacc/reduction-10.c: Likewise.
* gfortran.dg/goacc/loop-tree-1.f90: Likewise.

include/
* gomp-constants.h (GOMP_MAP_NONCONTIG_ARRAY_P): Tweak condition.

libgomp/
* testsuite/libgomp.oacc-c-c++-common/implicit-mapping-1.c: New test.
14 files changed:
gcc/ChangeLog.omp
gcc/gimplify.cc
gcc/testsuite/ChangeLog.omp
gcc/testsuite/c-c++-common/goacc/combined-reduction.c
gcc/testsuite/c-c++-common/goacc/reduction-1.c
gcc/testsuite/c-c++-common/goacc/reduction-10.c
gcc/testsuite/c-c++-common/goacc/reduction-2.c
gcc/testsuite/c-c++-common/goacc/reduction-3.c
gcc/testsuite/c-c++-common/goacc/reduction-4.c
gcc/testsuite/gfortran.dg/goacc/loop-tree-1.f90
include/ChangeLog.omp
include/gomp-constants.h
libgomp/ChangeLog.omp
libgomp/testsuite/libgomp.oacc-c-c++-common/implicit-mapping-1.c [new file with mode: 0644]