[PATCH 0/5] openmp: Support array-of-pointers (multi-segment) noncontiguous array sections and array-shaping casts
Paul-Antoine Arras <[email protected]> Wed, 5 Aug 2026 22:23:38 +0200
| Newsgroups | gmane.comp.gcc.patches |
|---|---|
| Message-ID | <[email protected]> |
GCC already lets a "target"/"target update" map clause describe a
noncontiguous array section or an array-shaping cast over a single
array or a single pointer indirection, e.g.:
int a[N][M];
#pragma omp target update to(a[2:3:4][0:4:2])
int *p;
#pragma omp target update to((([N]) p)[2:3:4])
What wasn't supported is a section or shape-cast that crosses more
than one pointer indirection, e.g. an array-of-pointers:
int *a[N];
#pragma omp target update to(a[2:3:4][0:4:2])
Each further indirection needs its own, independently-strided
"segment" of dimensions in the noncontiguous-array descriptor that
gets built for the directive and walked on the target side, since the
memory reachable through each pointer in the outer dimension(s) is a
separate, unrelated allocation. This series adds that support, for C
and C++, on top of the existing single-segment (plain array section /
single pointer indirection) machinery [1].
Patch 1 adds the new GOMP_MAP_SHAPE_DIM map kind and the
OMP_CLAUSE_MAP_GRID_DIM_POINTER clause flag used by the rest of the
series to mark a dimension as selecting through a pointer.
Patch 2 teaches the C and C++ front ends to build the right clause
chain for these cases (array-of-pointers sections, array-shaping
casts crossing a pointer, decayed array parameters), with tests
scanning the "original" dump to check the clauses built for each case.
Patches 3 and 4 do the corresponding lowering work: patch 3 is a
pure, non-functional outlining of the (pre-existing, single-segment)
descriptor-construction code in lower_omp_target into its own
function, lower_omp_target_grid_desc; patch 4 generalizes that
function to multiple segments and the new clause kind, and adds the
"lower" dump scans (checking the generated descriptor) to the tests
added in patch 2.
Patch 5 extends the libgomp runtime descriptor and its gather/scatter
loops to walk multiple segments, with C and C++ runtime tests for one,
two, and three segments.
This series targets devel/omp/gcc-16.
[1] The strided patches have not landed in mainline yet. They are on
the devel/omp/gcc-16 branch in the commits:
2a5fe5c4b3f OpenMP: Support strided and shaped-array updates for C++
40617ea1249 OpenMP: Array shaping operator and strided "target update" for C
1b6460d9eb6 OpenMP: Noncontiguous "target update" for Fortran
Paul-Antoine Arras (5):
openmp: Add GOMP_MAP_SHAPE_DIM and grid-dim pointer marker
prerequisites
openmp: Support pointer indirection in array-shaping casts and array
sections
openmp: Outline lower_omp_target_grid_desc from lower_omp_target
openmp: Generalize lower_omp_target_grid_desc to segments and pointer
sections
openmp: Support multi-segment noncontiguous descriptors in libgomp
gcc/c-family/c-omp.cc | 151 +++-
gcc/c/c-parser.cc | 59 +-
gcc/c/c-typeck.cc | 144 +++-
gcc/cp/decl.cc | 50 +-
gcc/cp/parser.cc | 69 +-
gcc/cp/semantics.cc | 114 ++-
gcc/gimplify.cc | 18 +-
gcc/omp-general.cc | 5 +-
gcc/omp-low.cc | 798 +++++++++++-------
.../c-c++-common/gomp/array-section-1.c | 40 +
.../c-c++-common/gomp/array-section-2.c | 22 +
.../c-c++-common/gomp/array-section-3.c | 45 +
.../c-c++-common/gomp/array-section-4.c | 28 +
.../c-c++-common/gomp/array-section-5.c | 32 +
.../c-c++-common/gomp/array-section-6.c | 19 +
.../c-c++-common/gomp/array-section-8.c | 34 +
.../c-c++-common/gomp/array-section-9.c | 28 +
.../gomp/target-update-iterators-4.c | 19 +
gcc/testsuite/g++.dg/gomp/array-shaping-3.C | 71 ++
gcc/testsuite/g++.dg/gomp/array-shaping-4.C | 37 +
.../g++.dg/gomp/bad-array-shaping-9.C | 51 ++
gcc/testsuite/gcc.dg/gomp/array-shaping-9.c | 25 +
.../gcc.dg/gomp/bad-array-section-c-9.c | 60 ++
.../gcc.dg/gomp/bad-array-shaping-c-8.c | 45 +
gcc/tree-pretty-print.cc | 9 +
gcc/tree.h | 7 +
include/gomp-constants.h | 3 +-
libgomp/libgomp.h | 24 +-
libgomp/target.c | 176 +++-
.../testsuite/libgomp.c++/array-section-1.C | 204 +++++
.../testsuite/libgomp.c++/array-section-2.C | 130 +++
.../libgomp.c-c++-common/array-section-1.c | 181 ++++
.../libgomp.c-c++-common/array-section-10.c | 69 ++
.../libgomp.c-c++-common/array-section-11.c | 73 ++
.../libgomp.c-c++-common/array-section-2.c | 75 ++
.../libgomp.c-c++-common/array-section-3.c | 135 +++
.../libgomp.c-c++-common/array-section-4.c | 134 +++
.../libgomp.c-c++-common/array-section-5.c | 136 +++
.../libgomp.c-c++-common/array-section-6.c | 75 ++
.../libgomp.c-c++-common/array-section-7.c | 104 +++
.../libgomp.c-c++-common/array-section-8.c | 87 ++
.../libgomp.c-c++-common/array-section-9.c | 120 +++
42 files changed, 3213 insertions(+), 493 deletions(-)
create mode 100644 gcc/testsuite/c-c++-common/gomp/array-section-1.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/array-section-2.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/array-section-3.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/array-section-4.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/array-section-5.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/array-section-6.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/array-section-8.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/array-section-9.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/target-update-iterators-4.c
create mode 100644 gcc/testsuite/g++.dg/gomp/array-shaping-3.C
create mode 100644 gcc/testsuite/g++.dg/gomp/array-shaping-4.C
create mode 100644 gcc/testsuite/g++.dg/gomp/bad-array-shaping-9.C
create mode 100644 gcc/testsuite/gcc.dg/gomp/array-shaping-9.c
create mode 100644 gcc/testsuite/gcc.dg/gomp/bad-array-section-c-9.c
create mode 100644 gcc/testsuite/gcc.dg/gomp/bad-array-shaping-c-8.c
create mode 100644 libgomp/testsuite/libgomp.c++/array-section-1.C
create mode 100644 libgomp/testsuite/libgomp.c++/array-section-2.C
create mode 100644 libgomp/testsuite/libgomp.c-c++-common/array-section-1.c
create mode 100644 libgomp/testsuite/libgomp.c-c++-common/array-section-10.c
create mode 100644 libgomp/testsuite/libgomp.c-c++-common/array-section-11.c
create mode 100644 libgomp/testsuite/libgomp.c-c++-common/array-section-2.c
create mode 100644 libgomp/testsuite/libgomp.c-c++-common/array-section-3.c
create mode 100644 libgomp/testsuite/libgomp.c-c++-common/array-section-4.c
create mode 100644 libgomp/testsuite/libgomp.c-c++-common/array-section-5.c
create mode 100644 libgomp/testsuite/libgomp.c-c++-common/array-section-6.c
create mode 100644 libgomp/testsuite/libgomp.c-c++-common/array-section-7.c
create mode 100644 libgomp/testsuite/libgomp.c-c++-common/array-section-8.c
create mode 100644 libgomp/testsuite/libgomp.c-c++-common/array-section-9.c
--
2.53.0