aboutsummaryrefslogtreecommitdiff
path: root/openmp
diff options
context:
space:
mode:
authorJennifer Yu <jennifer.yu@intel.com>2022-09-22 20:05:15 -0700
committerJennifer Yu <jennifer.yu@intel.com>2022-09-27 11:53:57 -0700
commit30cc712eb6f23a5c7beaae669bf2ab6beede7f20 (patch)
treeedc5369aed0a0f847c094ae3d9c4287f14fb13fb /openmp
parent86cd3535206d6db611260aae6f2869202eae4bb4 (diff)
downloadllvm-30cc712eb6f23a5c7beaae669bf2ab6beede7f20.zip
llvm-30cc712eb6f23a5c7beaae669bf2ab6beede7f20.tar.gz
llvm-30cc712eb6f23a5c7beaae669bf2ab6beede7f20.tar.bz2
[Clang][OpenMP] Fix run time crash when use_device_addr is used.
It is data mapping ordering problem. According omp spec If one or more map clauses are present, the list item conversions that are performed for any use_device_ptr or use_device_addr clause occur after all variables are mapped on entry to the region according to those map clauses. The change is to put mapping data for use_device_addr at end of data mapping array. Differential Revision: https://reviews.llvm.org/D134556
Diffstat (limited to 'openmp')
-rw-r--r--openmp/libomptarget/test/mapping/target_use_device_addr.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/openmp/libomptarget/test/mapping/target_use_device_addr.c b/openmp/libomptarget/test/mapping/target_use_device_addr.c
new file mode 100644
index 0000000..05a5aea
--- /dev/null
+++ b/openmp/libomptarget/test/mapping/target_use_device_addr.c
@@ -0,0 +1,18 @@
+// RUN: %libomptarget-compile-generic -fopenmp-version=51
+// RUN: %libomptarget-run-generic 2>&1 \
+// RUN: | %fcheck-generic
+
+#include <stdio.h>
+int main() {
+ short x[10];
+ short *xp = &x[0];
+
+ x[1] = 111;
+
+ printf("%d, %p\n", xp[1], &xp[1]);
+#pragma omp target data use_device_addr(xp [1:3]) map(tofrom : x)
+#pragma omp target is_device_ptr(xp)
+ { xp[1] = 222; }
+ // CHECK: 222
+ printf("%d, %p\n", xp[1], &xp[1]);
+}