[all-commits] [llvm/llvm-project] 12769a: [Offload] Introduce ATTACH map-type support for po...
Abhinav Gaba via All-commits
all-commits at lists.llvm.org
Sun Aug 17 15:17:26 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 12769aa7283b385a0695372ff13063189a9d1686
https://github.com/llvm/llvm-project/commit/12769aa7283b385a0695372ff13063189a9d1686
Author: Abhinav Gaba <abhinav.gaba at intel.com>
Date: 2025-08-17 (Sun, 17 Aug 2025)
Changed paths:
M offload/include/OpenMP/Mapping.h
M offload/include/device.h
M offload/include/omptarget.h
M offload/libomptarget/device.cpp
M offload/libomptarget/interface.cpp
M offload/libomptarget/omptarget.cpp
Log Message:
-----------
[Offload] Introduce ATTACH map-type support for pointer attachment. (#149036)
This patch introduces libomptarget support for the ATTACH map-type,
which can be used to implement OpenMP conditional compliant pointer
attachment, based on whether the pointer/pointee is newly mapped on a
given construct.
For example, for the following:
```c
int *p;
#pragma omp target enter data map(p[1:10])
```
The following maps can be emitted by clang:
```
(A)
&p[0], &p[1], 10 * sizeof(p[1]), TO | FROM
&p, &p[1], sizeof(p), ATTACH
```
Without this map-type, these two possible maps could be emitted by
clang:
```
(B)
&p[0], &p[1], 10 * sizeof(p[1]), TO | FROM
(C)
&p, &p[1], 10 * sizeof(p[1]), TO | FROM | PTR_AND_OBJ
````
(B) does not perform any pointer attachment, while (C) also maps the
pointer p, which are both incorrect.
In terms of implementation, maps with the ATTACH map-type are handled
after all other maps have been processed, as it requires knowledge of
which new allocations happened as part of the construct. As per OpenMP
5.0, an attachment should happen only when either the pointer or the
pointee was newly mapped while handling the construct.
Maps with ATTACH map-type-bit do not increase/decrease the ref-count.
With OpenMP 6.1, `attach(always/never)` can be used to force/prevent
attachment. For `attach(always)`, the compiler will insert the ALWAYS
map-type, which would let libomptarget bypass the check about one of the
pointer/pointee being new. With `attach(never)`, the ATTACH map will not
be emitted at all.
The size argument of the ATTACH map-type can specify values greater than
`sizeof(void*)` which can be used to support pointer attachment on
Fortran descriptors. Note that this also requires shadow-pointer
tracking to also support them. That has not been implemented in this
patch.
This was worked upon in coordination with Ravi Narayanaswamy, who has
since retired. Happy retirement, Ravi!
---------
Co-authored-by: Alex Duran <alejandro.duran at intel.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list