[PATCH 0/3] OpenMP: Array-shaping operator and strided/noncontiguous "target update"
Paul-Antoine Arras <[email protected]>
| Newsgroups | gmane.comp.gcc.patches,gmane.comp.gcc.fortran |
|---|---|
| Message-ID | <[email protected]> |
This series brings OpenMP 5.0 support for the array-shaping operator
("([x][y][z]) foo[0:n]...") and for strided/rectangular (noncontiguous)
"target update" to C, C++, and Fortran. It is cherry-picked from the
devel/omp/gcc-16 branch, rebased on current master, with a handful of
additional fixes folded in (see below).
Patches:
1/3 OpenMP: Support strided and shaped-array updates for C++
2/3 OpenMP: Array shaping operator and strided "target update" for C
3/3 OpenMP: Noncontiguous "target update" for Fortran
Patch 1 introduces the shared middle-end/runtime machinery (the
OMP_ARRAY_SECTION stride field, the array-shaping cast operator, and the
GOMP_MAP_TO_GRID/FROM_GRID/GRID_DIM/GRID_STRIDE map kinds used to
represent noncontiguous updates), alongside the C++ front-end support.
Patches 2 and 3 add the C and Fortran front-end support respectively,
reusing that shared infrastructure.
Beyond the original devel/omp/gcc-16 patches, each of the three commits
also folds in fixes found while testing this series on current master:
- A parser fix (C and C++) so that a provably-contiguous access such as
indexing a fixed array of pointers is not misrouted into the
noncontiguous/"grid" update path.
- A gimplify.cc fix for a leaked gimplify context when several clauses
in a shared-iterator-group update take the grid path.
- A C/C++ fix so a genuinely discontiguous update correctly replaces
the original map clause regardless of access-chain depth (e.g. for a
struct member).
- Fortran-specific fixes: exempting "target update" from contiguity/
stride restrictions that were only meant for OpenACC, correct block
scoping for iterator-scoped temporaries, a libgomp fix for rank-2+
noncontiguous updates (the CUDA memcpy2d/memcpy3d fast paths were
silently treating non-unit strides as contiguous), and a fix so a
fully-indexed element reference into a bare POINTER array is not
routed through the noncontiguous/"grid" path unnecessarily.
- A fix (all three languages) for a case where an OpenMP "iterator"
modifier combined with a noncontiguous/strided map expression is
currently unsupported: the iterator-expansion protocol and the
grid/noncontiguous-update lowering are mutually incompatible and
collide, producing wrong results if let through silently. This is
now rejected with a sorry, independently of the source language,
in the gimplifier. For Fortran, where a plain POINTER's contiguity
often can't be proven at compile time, the common case (an iterator
over an array section that is actually contiguous at runtime, just
not provably so) is instead handled correctly via a runtime
contiguity check, falling back to the same runtime error only when
the array turns out to be genuinely noncontiguous.
Regtested on x86_64-linux-gnu with amdgcn offloading.
Known limitation: combining map iterators with noncontiguous/strided
updates is currently unsupported.
Julian Brown (3):
OpenMP: Support strided and shaped-array updates for C++
OpenMP: Array shaping operator and strided "target update" for C
OpenMP: Noncontiguous "target update" for Fortran
gcc/c-family/c-omp.cc | 213 ++++++-
gcc/c-family/c-pretty-print.cc | 5 +
gcc/c/c-parser.cc | 361 ++++++++++--
gcc/c/c-tree.h | 11 +-
gcc/c/c-typeck.cc | 287 ++++++++--
gcc/cp/cp-objcp-common.cc | 1 +
gcc/cp/cp-tree.def | 1 +
gcc/cp/cp-tree.h | 13 +-
gcc/cp/decl.cc | 75 +++
gcc/cp/decl2.cc | 17 +-
gcc/cp/error.cc | 5 +
gcc/cp/mangle.cc | 1 +
gcc/cp/operators.def | 1 +
gcc/cp/parser.cc | 352 ++++++++++--
gcc/cp/parser.h | 13 +-
gcc/cp/pt.cc | 32 +-
gcc/cp/semantics.cc | 287 ++++++++--
gcc/cp/typeck.cc | 16 +-
gcc/fortran/expr.cc | 3 +
gcc/fortran/openmp.cc | 6 +-
gcc/fortran/trans-openmp.cc | 522 ++++++++++++++++++
gcc/gimplify.cc | 78 ++-
gcc/omp-general.cc | 47 ++
gcc/omp-general.h | 4 +-
gcc/omp-low.cc | 475 +++++++++++++++-
.../gomp/target-map-iterators-1.c | 2 +-
.../gomp/target-update-iterators-4.c | 13 +
gcc/testsuite/g++.dg/gomp/array-shaping-1.C | 22 +
gcc/testsuite/g++.dg/gomp/array-shaping-2.C | 134 +++++
.../g++.dg/gomp/bad-array-shaping-1.C | 47 ++
.../g++.dg/gomp/bad-array-shaping-2.C | 52 ++
.../g++.dg/gomp/bad-array-shaping-3.C | 53 ++
.../g++.dg/gomp/bad-array-shaping-4.C | 60 ++
.../g++.dg/gomp/bad-array-shaping-5.C | 55 ++
.../g++.dg/gomp/bad-array-shaping-6.C | 59 ++
.../g++.dg/gomp/bad-array-shaping-7.C | 44 ++
.../g++.dg/gomp/bad-array-shaping-8.C | 50 ++
.../g++.dg/gomp/map-static-cast-lvalue-1.C | 1 -
.../gcc.dg/gomp/bad-array-shaping-c-1.c | 26 +
.../gcc.dg/gomp/bad-array-shaping-c-2.c | 24 +
.../gcc.dg/gomp/bad-array-shaping-c-3.c | 30 +
.../gcc.dg/gomp/bad-array-shaping-c-4.c | 27 +
.../gcc.dg/gomp/bad-array-shaping-c-5.c | 17 +
.../gcc.dg/gomp/bad-array-shaping-c-6.c | 26 +
.../gcc.dg/gomp/bad-array-shaping-c-7.c | 15 +
.../gfortran.dg/gomp/noncontig-updates-1.f90 | 19 +
.../gfortran.dg/gomp/noncontig-updates-2.f90 | 16 +
.../gfortran.dg/gomp/noncontig-updates-3.f90 | 16 +
.../gfortran.dg/gomp/noncontig-updates-4.f90 | 15 +
.../gomp/target-update-iterators-3.f90 | 11 +-
.../gomp/target-update-iterators-4.f90 | 21 +
gcc/tree-pretty-print.cc | 17 +
gcc/tree.def | 2 +-
include/gomp-constants.h | 9 +-
libgomp/libgomp.h | 15 +
libgomp/target.c | 249 ++++++---
.../testsuite/libgomp.c++/array-shaping-1.C | 469 ++++++++++++++++
.../testsuite/libgomp.c++/array-shaping-10.C | 61 ++
.../testsuite/libgomp.c++/array-shaping-11.C | 63 +++
.../testsuite/libgomp.c++/array-shaping-12.C | 65 +++
.../testsuite/libgomp.c++/array-shaping-13.C | 89 +++
.../testsuite/libgomp.c++/array-shaping-2.C | 38 ++
.../testsuite/libgomp.c++/array-shaping-3.C | 38 ++
.../testsuite/libgomp.c++/array-shaping-4.C | 38 ++
.../testsuite/libgomp.c++/array-shaping-5.C | 38 ++
.../testsuite/libgomp.c++/array-shaping-6.C | 54 ++
.../testsuite/libgomp.c++/array-shaping-7.C | 54 ++
.../testsuite/libgomp.c++/array-shaping-8.C | 65 +++
.../testsuite/libgomp.c++/array-shaping-9.C | 95 ++++
.../libgomp.c++/map-static-cast-lvalue-1.C | 16 +
.../libgomp.c-c++-common/array-shaping-14.c | 34 ++
libgomp/testsuite/libgomp.c/array-shaping-1.c | 236 ++++++++
libgomp/testsuite/libgomp.c/array-shaping-2.c | 39 ++
libgomp/testsuite/libgomp.c/array-shaping-3.c | 42 ++
libgomp/testsuite/libgomp.c/array-shaping-4.c | 36 ++
libgomp/testsuite/libgomp.c/array-shaping-5.c | 38 ++
libgomp/testsuite/libgomp.c/array-shaping-6.c | 45 ++
.../libgomp.fortran/noncontig-updates-1.f90 | 54 ++
.../libgomp.fortran/noncontig-updates-10.f90 | 29 +
.../libgomp.fortran/noncontig-updates-11.f90 | 51 ++
.../libgomp.fortran/noncontig-updates-12.f90 | 59 ++
.../libgomp.fortran/noncontig-updates-13.f90 | 42 ++
.../libgomp.fortran/noncontig-updates-2.f90 | 101 ++++
.../libgomp.fortran/noncontig-updates-3.f90 | 47 ++
.../libgomp.fortran/noncontig-updates-4.f90 | 78 +++
.../libgomp.fortran/noncontig-updates-5.f90 | 55 ++
.../libgomp.fortran/noncontig-updates-6.f90 | 34 ++
.../libgomp.fortran/noncontig-updates-7.f90 | 36 ++
.../libgomp.fortran/noncontig-updates-8.f90 | 39 ++
.../libgomp.fortran/noncontig-updates-9.f90 | 34 ++
.../target-update-iterators-4.f90 | 36 ++
91 files changed, 6016 insertions(+), 305 deletions(-)
create mode 100644 gcc/testsuite/c-c++-common/gomp/target-update-iterators-4.c
create mode 100644 gcc/testsuite/g++.dg/gomp/array-shaping-1.C
create mode 100644 gcc/testsuite/g++.dg/gomp/array-shaping-2.C
create mode 100644 gcc/testsuite/g++.dg/gomp/bad-array-shaping-1.C
create mode 100644 gcc/testsuite/g++.dg/gomp/bad-array-shaping-2.C
create mode 100644 gcc/testsuite/g++.dg/gomp/bad-array-shaping-3.C
create mode 100644 gcc/testsuite/g++.dg/gomp/bad-array-shaping-4.C
create mode 100644 gcc/testsuite/g++.dg/gomp/bad-array-shaping-5.C
create mode 100644 gcc/testsuite/g++.dg/gomp/bad-array-shaping-6.C
create mode 100644 gcc/testsuite/g++.dg/gomp/bad-array-shaping-7.C
create mode 100644 gcc/testsuite/g++.dg/gomp/bad-array-shaping-8.C
create mode 100644 gcc/testsuite/gcc.dg/gomp/bad-array-shaping-c-1.c
create mode 100644 gcc/testsuite/gcc.dg/gomp/bad-array-shaping-c-2.c
create mode 100644 gcc/testsuite/gcc.dg/gomp/bad-array-shaping-c-3.c
create mode 100644 gcc/testsuite/gcc.dg/gomp/bad-array-shaping-c-4.c
create mode 100644 gcc/testsuite/gcc.dg/gomp/bad-array-shaping-c-5.c
create mode 100644 gcc/testsuite/gcc.dg/gomp/bad-array-shaping-c-6.c
create mode 100644 gcc/testsuite/gcc.dg/gomp/bad-array-shaping-c-7.c
create mode 100644 gcc/testsuite/gfortran.dg/gomp/noncontig-updates-1.f90
create mode 100644 gcc/testsuite/gfortran.dg/gomp/noncontig-updates-2.f90
create mode 100644 gcc/testsuite/gfortran.dg/gomp/noncontig-updates-3.f90
create mode 100644 gcc/testsuite/gfortran.dg/gomp/noncontig-updates-4.f90
create mode 100644 gcc/testsuite/gfortran.dg/gomp/target-update-iterators-4.f90
create mode 100644 libgomp/testsuite/libgomp.c++/array-shaping-1.C
create mode 100644 libgomp/testsuite/libgomp.c++/array-shaping-10.C
create mode 100644 libgomp/testsuite/libgomp.c++/array-shaping-11.C
create mode 100644 libgomp/testsuite/libgomp.c++/array-shaping-12.C
create mode 100644 libgomp/testsuite/libgomp.c++/array-shaping-13.C
create mode 100644 libgomp/testsuite/libgomp.c++/array-shaping-2.C
create mode 100644 libgomp/testsuite/libgomp.c++/array-shaping-3.C
create mode 100644 libgomp/testsuite/libgomp.c++/array-shaping-4.C
create mode 100644 libgomp/testsuite/libgomp.c++/array-shaping-5.C
create mode 100644 libgomp/testsuite/libgomp.c++/array-shaping-6.C
create mode 100644 libgomp/testsuite/libgomp.c++/array-shaping-7.C
create mode 100644 libgomp/testsuite/libgomp.c++/array-shaping-8.C
create mode 100644 libgomp/testsuite/libgomp.c++/array-shaping-9.C
create mode 100644 libgomp/testsuite/libgomp.c++/map-static-cast-lvalue-1.C
create mode 100644 libgomp/testsuite/libgomp.c-c++-common/array-shaping-14.c
create mode 100644 libgomp/testsuite/libgomp.c/array-shaping-1.c
create mode 100644 libgomp/testsuite/libgomp.c/array-shaping-2.c
create mode 100644 libgomp/testsuite/libgomp.c/array-shaping-3.c
create mode 100644 libgomp/testsuite/libgomp.c/array-shaping-4.c
create mode 100644 libgomp/testsuite/libgomp.c/array-shaping-5.c
create mode 100644 libgomp/testsuite/libgomp.c/array-shaping-6.c
create mode 100644 libgomp/testsuite/libgomp.fortran/noncontig-updates-1.f90
create mode 100644 libgomp/testsuite/libgomp.fortran/noncontig-updates-10.f90
create mode 100644 libgomp/testsuite/libgomp.fortran/noncontig-updates-11.f90
create mode 100644 libgomp/testsuite/libgomp.fortran/noncontig-updates-12.f90
create mode 100644 libgomp/testsuite/libgomp.fortran/noncontig-updates-13.f90
create mode 100644 libgomp/testsuite/libgomp.fortran/noncontig-updates-2.f90
create mode 100644 libgomp/testsuite/libgomp.fortran/noncontig-updates-3.f90
create mode 100644 libgomp/testsuite/libgomp.fortran/noncontig-updates-4.f90
create mode 100644 libgomp/testsuite/libgomp.fortran/noncontig-updates-5.f90
create mode 100644 libgomp/testsuite/libgomp.fortran/noncontig-updates-6.f90
create mode 100644 libgomp/testsuite/libgomp.fortran/noncontig-updates-7.f90
create mode 100644 libgomp/testsuite/libgomp.fortran/noncontig-updates-8.f90
create mode 100644 libgomp/testsuite/libgomp.fortran/noncontig-updates-9.f90
create mode 100644 libgomp/testsuite/libgomp.fortran/target-update-iterators-4.f90
--
2.55.0