Files
clang-p2996/offload/test/mapping/data_member_ref.cpp
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

79 lines
1.8 KiB
C++

// RUN: %libomptarget-compilexx-run-and-check-generic
#include <stdio.h>
struct View {
int Data;
};
struct ViewPtr {
int *Data;
};
template <typename T> struct Foo {
Foo(T &V) : VRef(V) {}
T &VRef;
};
int main() {
View V;
V.Data = 123456;
Foo<View> Bar(V);
ViewPtr V1;
int Data = 123456;
V1.Data = &Data;
Foo<ViewPtr> Baz(V1);
int D1, D2;
// CHECK: Host 123456.
printf("Host %d.\n", Bar.VRef.Data);
#pragma omp target map(Bar.VRef) map(from : D1, D2)
{
// CHECK: Device 123456.
D1 = Bar.VRef.Data;
printf("Device %d.\n", D1);
V.Data = 654321;
// CHECK: Device 654321.
D2 = Bar.VRef.Data;
printf("Device %d.\n", D2);
}
printf("Device %d.\n", D1);
printf("Device %d.\n", D2);
// CHECK: Host 654321 654321.
printf("Host %d %d.\n", Bar.VRef.Data, V.Data);
V.Data = 123456;
// CHECK: Host 123456.
printf("Host %d.\n", Bar.VRef.Data);
#pragma omp target map(Bar) map(Bar.VRef) map(from : D1, D2)
{
// CHECK: Device 123456.
D1 = Bar.VRef.Data;
printf("Device %d.\n", D1);
V.Data = 654321;
// CHECK: Device 654321.
D2 = Bar.VRef.Data;
printf("Device %d.\n", D2);
}
printf("Device %d.\n", D1);
printf("Device %d.\n", D2);
// CHECK: Host 654321 654321.
printf("Host %d %d.\n", Bar.VRef.Data, V.Data);
// CHECK: Host 123456.
printf("Host %d.\n", *Baz.VRef.Data);
#pragma omp target map(*Baz.VRef.Data) map(from : D1, D2)
{
// CHECK: Device 123456.
D1 = *Baz.VRef.Data;
printf("Device %d.\n", D1);
*V1.Data = 654321;
// CHECK: Device 654321.
D2 = *Baz.VRef.Data;
printf("Device %d.\n", D2);
}
printf("Device %d.\n", D1);
printf("Device %d.\n", D2);
// CHECK: Host 654321 654321 654321.
printf("Host %d %d %d.\n", *Baz.VRef.Data, *V1.Data, Data);
return 0;
}