diff options
author | Tobias Burnus <tburnus@baylibre.com> | 2025-05-14 20:06:49 +0200 |
---|---|---|
committer | Tobias Burnus <tburnus@baylibre.com> | 2025-05-14 20:08:20 +0200 |
commit | a1c4b92e57874d549b3bc6bb776c7c16e9ada14a (patch) | |
tree | 9428681e9dbd952b66af3cd875e81fb8d82a3405 /libgomp/libgomp.h | |
parent | 9a06e4d6a117497c2536bf89bb6c7536289e44bb (diff) | |
download | gcc-devel/omp/gcc-14.zip gcc-devel/omp/gcc-14.tar.gz gcc-devel/omp/gcc-14.tar.bz2 |
OpenMP: Fix mapping of zero-sized arrays with non-literal size: map(var[:n]), n = 0devel/omp/gcc-14
For map(ptr[:0]), the used map kind is GOMP_MAP_ATTACH_ZERO_LENGTH_ARRAY_SECTION
and it is permitted that 'ptr' does not exist. 'ptr' is set to the device
pointee if it exists or to the host value otherwise.
For map(ptr[:3]), the variable is first mapped and then ptr is updated to point
to the just-mapped device data; the attachment uses GOMP_MAP_ATTACH.
For map(ptr[:n]), generates always a GOMP_MAP_ATTACH, but when n == 0, it
was failing with:
"pointer target not mapped for attach"
The solution is not to fail but first to check whether it was mapped before.
It turned out that for the mapping part, GCC adds a run-time check whether
n == 0 - and uses GOMP_MAP_ZERO_LEN_ARRAY_SECTION for the mapping.
Thus, we just have to check whether there such a mapping for the address
for which the GOMP_MAP_ATTACH. was requested. And, if there was, the
error diagnostic can be skipped.
Unsurprisingly, this issue occurs in real-world code; it was detected in
a code that distributes work via MPI and for some processes, some bounds
ended up to be zero.
libgomp/ChangeLog:
* target.c (gomp_attach_pointer): Return bool; accept additional
bool to optionally silence the fatal pointee-not-found error.
(gomp_map_vars_internal): If the pointee could not be found,
check whether it was mapped as GOMP_MAP_ZERO_LEN_ARRAY_SECTION.
* libgomp.h (gomp_attach_pointer): Update prototype.
* oacc-mem.c (acc_attach_async, goacc_enter_data_internal): Update
calls.
* testsuite/libgomp.c/target-map-zero-sized.c: New test.
* testsuite/libgomp.c/target-map-zero-sized-2.c: New test.
* testsuite/libgomp.c/target-map-zero-sized-3.c: New test.
(cherry picked from commit 814e29e390b1e9253f9a38e0d84f5ebe5de0c13e)
Diffstat (limited to 'libgomp/libgomp.h')
-rw-r--r-- | libgomp/libgomp.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h index 43e7a06..a60a3d8 100644 --- a/libgomp/libgomp.h +++ b/libgomp/libgomp.h @@ -1487,10 +1487,10 @@ extern void gomp_copy_dev2host (struct gomp_device_descr *, struct goacc_asyncqueue *, void *, const void *, size_t); extern uintptr_t gomp_map_val (struct target_mem_desc *, void **, size_t); -extern void gomp_attach_pointer (struct gomp_device_descr *, +extern bool gomp_attach_pointer (struct gomp_device_descr *, struct goacc_asyncqueue *, splay_tree, splay_tree_key, uintptr_t, size_t, - struct gomp_coalesce_buf *, bool); + struct gomp_coalesce_buf *, bool, bool); extern void gomp_detach_pointer (struct gomp_device_descr *, struct goacc_asyncqueue *, splay_tree_key, uintptr_t, bool, struct gomp_coalesce_buf *); |