summaryrefslogtreecommitdiff
path: root/offload/test/mapping/array_section_use_device_ptr.c
diff options
context:
space:
mode:
Diffstat (limited to 'offload/test/mapping/array_section_use_device_ptr.c')
-rw-r--r--offload/test/mapping/array_section_use_device_ptr.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/offload/test/mapping/array_section_use_device_ptr.c b/offload/test/mapping/array_section_use_device_ptr.c
new file mode 100644
index 000000000000..86e2875c35c4
--- /dev/null
+++ b/offload/test/mapping/array_section_use_device_ptr.c
@@ -0,0 +1,35 @@
+// RUN: %libomptarget-compile-generic
+// RUN: %libomptarget-run-generic 2>&1 \
+// RUN: | %fcheck-generic
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define N 1024
+#define FROM 64
+#define LENGTH 128
+
+int main() {
+ float *A = (float *)malloc(N * sizeof(float));
+
+#pragma omp target enter data map(to : A[FROM : LENGTH])
+
+ // A, has been mapped starting at index FROM, but inside the use_device_ptr
+ // clause it is captured by base so the library must look it up using the
+ // base address.
+
+ float *A_dev = NULL;
+#pragma omp target data use_device_ptr(A)
+ { A_dev = A; }
+#pragma omp target exit data map(delete : A[FROM : LENGTH])
+
+ // CHECK: Success
+ if (A_dev == NULL || A_dev == A)
+ fprintf(stderr, "Failure\n");
+ else
+ fprintf(stderr, "Success\n");
+
+ free(A);
+
+ return 0;
+}