mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-10 23:15:15 +08:00
7bfb3f488a
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.
48 lines
1.2 KiB
Fortran
48 lines
1.2 KiB
Fortran
program main
|
|
use omp_lib
|
|
use iso_c_binding
|
|
implicit none (external, type)
|
|
integer :: d, id
|
|
type(c_ptr) :: p
|
|
integer, target :: q
|
|
|
|
d = omp_get_default_device ()
|
|
id = omp_get_initial_device ()
|
|
|
|
if (d < 0 .or. d >= omp_get_num_devices ()) &
|
|
d = id
|
|
|
|
p = omp_target_alloc (c_sizeof (q), d)
|
|
if (.not. c_associated (p)) &
|
|
stop 0 ! okay
|
|
|
|
if (omp_target_associate_ptr (c_loc (q), p, c_sizeof (q), &
|
|
0_c_size_t, d) == 0) then
|
|
|
|
if(c_associated (omp_get_mapped_ptr (c_loc (q), -5))) &
|
|
stop 1
|
|
|
|
if(c_associated (omp_get_mapped_ptr (c_loc (q), &
|
|
omp_get_num_devices () + 1))) &
|
|
stop 2
|
|
|
|
if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), id), c_loc (q))) &
|
|
stop 3
|
|
|
|
if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), omp_initial_device), &
|
|
c_loc (q))) &
|
|
stop 4
|
|
|
|
if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), d), p)) &
|
|
stop 5
|
|
|
|
if (omp_target_disassociate_ptr (c_loc (q), d) /= 0) &
|
|
stop 6
|
|
|
|
if(c_associated (omp_get_mapped_ptr (c_loc (q), d))) &
|
|
stop 7
|
|
end if
|
|
|
|
call omp_target_free (p, d)
|
|
end program main
|