From 941cdc8b6d29f9fe494fdd244e96a5e5aa08ba32 Mon Sep 17 00:00:00 2001 From: Marcel Vollweiler Date: Mon, 2 May 2022 23:56:44 -0700 Subject: OpenMP, libgomp: Add new runtime routine omp_get_mapped_ptr. This patch adds the OpenMP runtime routine "omp_get_mapped_ptr" which was introduced in OpenMP 5.1. gcc/ChangeLog: * omp-low.cc (omp_runtime_api_call): Added get_mapped_ptr to omp_runtime_apis array. libgomp/ChangeLog: * libgomp.map: Added omp_get_mapped_ptr. * libgomp.texi: Tagged omp_get_mapped_ptr as supported. * omp.h.in: Added omp_get_mapped_ptr. * omp_lib.f90.in: Added interface for omp_get_mapped_ptr. * omp_lib.h.in: Likewise. * target.c (omp_get_mapped_ptr): Added implementation of omp_get_mapped_ptr. * testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c: New test. * testsuite/libgomp.c-c++-common/get-mapped-ptr-2.c: New test. * testsuite/libgomp.c-c++-common/get-mapped-ptr-3.c: New test. * testsuite/libgomp.c-c++-common/get-mapped-ptr-4.c: New test. * testsuite/libgomp.fortran/get-mapped-ptr-1.f90: New test. * testsuite/libgomp.fortran/get-mapped-ptr-2.f90: New test. * testsuite/libgomp.fortran/get-mapped-ptr-3.f90: New test. * testsuite/libgomp.fortran/get-mapped-ptr-4.f90: New test. --- .../libgomp.c-c++-common/get-mapped-ptr-4.c | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-4.c (limited to 'libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-4.c') diff --git a/libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-4.c b/libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-4.c new file mode 100644 index 0000000..6f4bd62 --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-4.c @@ -0,0 +1,49 @@ +#include +#include + +int +main () +{ + int d = omp_get_default_device (); + int id = omp_get_initial_device (); + struct s_t { int m1; char m2; } s; + void *p1 = NULL, *p2 = NULL; + + if (d < 0 || d >= omp_get_num_devices ()) + d = id; + + #pragma omp target data map(alloc: s, s.m2) device(d) + { + #pragma omp target map(from: p1, p2) map(alloc: s, s.m2) device(d) + { + p1 = &s; + p2 = &s.m2; + } + if (omp_get_mapped_ptr (&s, d) != (d == id ? &s : p1) + || omp_get_mapped_ptr (&s.m2, d) != (d == id ? &s.m2 : p2)) + abort (); + } + + if (omp_get_mapped_ptr (&s, d) != (d == id ? &s : NULL) + || omp_get_mapped_ptr (&s.m2, d) != (d == id ? &s.m2 : NULL)) + abort (); + + #pragma omp target enter data map(alloc: s, s.m2) device (d) + #pragma omp target map(from: p1, p2) map(alloc: s, s.m2) device(d) + { + p1 = &s; + p2 = &s.m2; + } + + if (omp_get_mapped_ptr (&s, d) != (d == id ? &s : p1) + || omp_get_mapped_ptr (&s.m2, d) != (d == id ? &s.m2 : p2)) + abort (); + + #pragma omp target exit data map (delete: s, s.m2) device (d) + + if (omp_get_mapped_ptr (&s, d) != (d == id ? &s : NULL) + || omp_get_mapped_ptr (&s.m2, d) != (d == id ? &s.m2 : NULL)) + abort (); + + return 0; +} -- cgit v1.1