
gcc/ChangeLog: * omp-low.cc (omp_runtime_api_call): Added target_is_accessible to omp_runtime_apis array. libgomp/ChangeLog: * libgomp.map: Added omp_target_is_accessible. * libgomp.texi: Tagged omp_target_is_accessible as supported. * omp.h.in: Added omp_target_is_accessible. * omp_lib.f90.in: Added interface for omp_target_is_accessible. * omp_lib.h.in: Likewise. * target.c (omp_target_is_accessible): Added implementation of omp_target_is_accessible. * testsuite/libgomp.c-c++-common/target-is-accessible-1.c: New test. * testsuite/libgomp.fortran/target-is-accessible-1.f90: New test.
47 lines
1.2 KiB
C
47 lines
1.2 KiB
C
#include <omp.h>
|
|
|
|
int
|
|
main ()
|
|
{
|
|
int d = omp_get_default_device ();
|
|
int id = omp_get_initial_device ();
|
|
int n = omp_get_num_devices ();
|
|
void *p;
|
|
|
|
if (d < 0 || d >= n)
|
|
d = id;
|
|
|
|
if (!omp_target_is_accessible (p, sizeof (int), n))
|
|
__builtin_abort ();
|
|
|
|
if (!omp_target_is_accessible (p, sizeof (int), id))
|
|
__builtin_abort ();
|
|
|
|
if (omp_target_is_accessible (p, sizeof (int), -1))
|
|
__builtin_abort ();
|
|
|
|
if (omp_target_is_accessible (p, sizeof (int), n + 1))
|
|
__builtin_abort ();
|
|
|
|
/* Currently, a host pointer is accessible if the device supports shared
|
|
memory or omp_target_is_accessible is executed on the host. This
|
|
test case must be adapted when unified shared memory is avialable. */
|
|
int a[128];
|
|
for (int d = 0; d <= omp_get_num_devices (); d++)
|
|
{
|
|
int shared_mem = 0;
|
|
#pragma omp target map (alloc: shared_mem) device (d)
|
|
shared_mem = 1;
|
|
if (omp_target_is_accessible (p, sizeof (int), d) != shared_mem)
|
|
__builtin_abort ();
|
|
|
|
if (omp_target_is_accessible (a, 128 * sizeof (int), d) != shared_mem)
|
|
__builtin_abort ();
|
|
|
|
for (int i = 0; i < 128; i++)
|
|
if (omp_target_is_accessible (&a[i], sizeof (int), d) != shared_mem)
|
|
__builtin_abort ();
|
|
}
|
|
|
|
return 0;
|
|
}
|