llvm-project/offload/test/mapping/data_absent_at_exit.c
Johannes Doerfert 330d8983d2
[Offload] Move /openmp/libomptarget to /offload (#75125)
In a nutshell, this moves our libomptarget code to populate the offload
subproject.

With this commit, users need to enable the new LLVM/Offload subproject
as a runtime in their cmake configuration.
No further changes are expected for downstream code.

Tests and other components still depend on OpenMP and have also not been
renamed. The results below are for a build in which OpenMP and Offload
are enabled runtimes. In addition to the pure `git mv`, we needed to
adjust some CMake files. Nothing is intended to change semantics.

```
ninja check-offload
```
Works with the X86 and AMDGPU offload tests

```
ninja check-openmp
```
Still works but doesn't build offload tests anymore.

```
ls install/lib
```
Shows all expected libraries, incl.
- `libomptarget.devicertl.a`
- `libomptarget-nvptx-sm_90.bc`
- `libomptarget.rtl.amdgpu.so` -> `libomptarget.rtl.amdgpu.so.18git`
- `libomptarget.so` -> `libomptarget.so.18git`

Fixes: https://github.com/llvm/llvm-project/issues/75124

---------

Co-authored-by: Saiyedul Islam <Saiyedul.Islam@amd.com>
2024-04-22 09:51:33 -07:00

29 lines
905 B
C

// RUN: %libomptarget-compile-run-and-check-generic
#include <stdio.h>
// OpenMP 5.1, sec. 2.21.7.1 "map Clause", p. 351 L14-16:
// "If the map clause appears on a target, target data, or target exit data
// construct and a corresponding list item of the original list item is not
// present in the device data environment on exit from the region then the
// list item is ignored."
int main(void) {
int f = 5, r = 6, d = 7, af = 8;
// Check exit from omp target data.
// CHECK: f = 5, af = 8
#pragma omp target data map(from : f) map(always, from : af)
{
#pragma omp target exit data map(delete : f, af)
} printf("f = %d, af = %d\n", f, af);
// Check omp target exit data.
// CHECK: f = 5, r = 6, d = 7, af = 8
#pragma omp target exit data map(from : f) map(release : r) map(delete : d) \
map(always, from : af)
printf("f = %d, r = %d, d = %d, af = %d\n", f, r, d, af);
return 0;
}