aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c')
-rw-r--r--libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c b/libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c
new file mode 100644
index 0000000..97a60ca
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c
@@ -0,0 +1,41 @@
+#include <omp.h>
+#include <stdlib.h>
+
+int
+main ()
+{
+ int d = omp_get_default_device ();
+ int id = omp_get_initial_device ();
+ void *p , *q;
+
+ if (d < 0 || d >= omp_get_num_devices ())
+ d = id;
+
+ p = omp_target_alloc (sizeof (int), d);
+ if (p == NULL)
+ return 0;
+
+ if (omp_target_associate_ptr (q, p, sizeof (int), 0, d) != 0)
+ return 0;
+
+ if (omp_get_mapped_ptr (q, -1) != NULL)
+ abort ();
+
+ if (omp_get_mapped_ptr (q, omp_get_num_devices () + 1) != NULL)
+ abort ();
+
+ if (omp_get_mapped_ptr (q, id) != q)
+ abort ();
+
+ if (omp_get_mapped_ptr (q, d) != p)
+ abort ();
+
+ if (omp_target_disassociate_ptr (q, d) != 0)
+ abort ();
+
+ if (omp_get_mapped_ptr (q, d) != NULL)
+ abort ();
+
+ omp_target_free (p, d);
+ return 0;
+}