
On Tue, Jun 14, 2022 at 06:41:37PM +0200, Thomas Schwinge wrote: > In an offloading configuration, I'm seeing: > > PASS: libgomp.fortran/get-mapped-ptr-1.f90 -O (test for excess errors) > [-PASS:-]{+FAIL:+} libgomp.fortran/get-mapped-ptr-1.f90 -O execution test > > Does that one need similar treatment? I assume not just that but libgomp.c-c++-common/get-mapped-ptr-1.c too? It both needs the same treatment, and in the get-mapped-ptr-1.c case there is even UB, while the Fortran version was using c_loc (q) as the host pointer, in C/C++ it was using q which was value of uninitialized pointer. 2022-06-15 Jakub Jelinek <jakub@redhat.com> * testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c (main): Initialize q to ddress of an automatic variable. Use -5 instead of -1 in omp_get_mapped_ptr call. Add test with omp_initial_device. * testsuite/libgomp.fortran/get-mapped-ptr-1.f90 (main): Use -5 instead of -1 in omp_get_mapped_ptr call. Add test with omp_initial_device. Renumber stop arguments afterwards.
47 lines
855 B
C
47 lines
855 B
C
#include <omp.h>
|
|
#include <stdlib.h>
|
|
|
|
int
|
|
main ()
|
|
{
|
|
int d = omp_get_default_device ();
|
|
int id = omp_get_initial_device ();
|
|
int x;
|
|
void *p, *q;
|
|
|
|
q = (void *) &x;
|
|
|
|
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, -5) != 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, omp_initial_device) != 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;
|
|
}
|