summaryrefslogtreecommitdiff
path: root/offload/test/mapping/declare_mapper_nested_default_mappers_array_subscript.cpp
diff options
context:
space:
mode:
authorJohannes Doerfert <johannes@jdoerfert.de>2024-04-22 09:51:33 -0700
committerGitHub <noreply@github.com>2024-04-22 09:51:33 -0700
commit330d8983d25d08580fc1642fea48b2473f47a9da (patch)
tree25994a04a5acd171f41e2ab7dd9780016f22237a /offload/test/mapping/declare_mapper_nested_default_mappers_array_subscript.cpp
parentb6628c24ef017138b8d6eb288e94c141e7c846b0 (diff)
[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>
Diffstat (limited to 'offload/test/mapping/declare_mapper_nested_default_mappers_array_subscript.cpp')
-rw-r--r--offload/test/mapping/declare_mapper_nested_default_mappers_array_subscript.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/offload/test/mapping/declare_mapper_nested_default_mappers_array_subscript.cpp b/offload/test/mapping/declare_mapper_nested_default_mappers_array_subscript.cpp
new file mode 100644
index 000000000000..bf510763526f
--- /dev/null
+++ b/offload/test/mapping/declare_mapper_nested_default_mappers_array_subscript.cpp
@@ -0,0 +1,60 @@
+// RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-x86_64-pc-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda
+
+#include <cstdio>
+#include <cstdlib>
+
+typedef struct {
+ int a;
+ double *b;
+} C1;
+#pragma omp declare mapper(C1 s) map(to : s.a) map(from : s.b[0 : 2])
+
+typedef struct {
+ int a;
+ double *b;
+ C1 c;
+} C;
+#pragma omp declare mapper(C s) map(to : s.a, s.c) map(from : s.b[0 : 2])
+
+typedef struct {
+ int e;
+ C f;
+ int h;
+} D;
+
+int main() {
+ constexpr int N = 10;
+ D sa[10];
+ sa[1].e = 111;
+ sa[1].f.a = 222;
+ sa[1].f.c.a = 777;
+ double x[2];
+ double x1[2];
+ x[1] = 20;
+ sa[1].f.b = &x[0];
+ sa[1].f.c.b = &x1[0];
+ sa[1].h = N;
+
+ printf("%d %d %d %4.5f %d\n", sa[1].e, sa[1].f.a, sa[1].f.c.a, sa[1].f.b[1],
+ sa[1].f.b == &x[0] ? 1 : 0);
+ // CHECK: 111 222 777 20.00000 1
+
+ __intptr_t p = reinterpret_cast<__intptr_t>(&x[0]);
+#pragma omp target map(tofrom : sa[1]) firstprivate(p)
+ {
+ printf("%d %d %d\n", sa[1].f.a, sa[1].f.c.a,
+ sa[1].f.b == reinterpret_cast<void *>(p) ? 1 : 0);
+ // CHECK: 222 777 0
+ sa[1].e = 333;
+ sa[1].f.a = 444;
+ sa[1].f.c.a = 555;
+ sa[1].f.b[1] = 40;
+ }
+ printf("%d %d %d %4.5f %d\n", sa[1].e, sa[1].f.a, sa[1].f.c.a, sa[1].f.b[1],
+ sa[1].f.b == &x[0] ? 1 : 0);
+ // CHECK: 333 222 777 40.00000 1
+}