From 30cc712eb6f23a5c7beaae669bf2ab6beede7f20 Mon Sep 17 00:00:00 2001 From: Jennifer Yu Date: Thu, 22 Sep 2022 20:05:15 -0700 Subject: [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 --- .../libomptarget/test/mapping/target_use_device_addr.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 openmp/libomptarget/test/mapping/target_use_device_addr.c (limited to 'openmp') 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 +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]); +} -- cgit v1.1