libgomp/testsuite: Improve omp_get_device_num() tests
Related to r12-6208-gebc853deb7cc0487de9ef6e891a007ba853d1933 "libgomp: Fix GOMP_DEVICE_NUM_VAR stringification during offload image load" That commit fixed an issue with omp_get_device_num() on gcn/nvptx that resulted in having always the value 0. This commit modifies the tests to iterate over all devices such that on a multi-nonhost-device system it had detected that always-zero issue. libgomp/ChangeLog: * testsuite/libgomp.c-c++-common/target-45.c: Iterate over all devices. * testsuite/libgomp.fortran/target10.f90: Likewise.
This commit is contained in:
parent
ebc853deb7
commit
be661959a6
@ -14,17 +14,23 @@ int main (void)
|
||||
int device_num;
|
||||
int initial_device;
|
||||
|
||||
#pragma omp target map(from: device_num, initial_device)
|
||||
for (int i = 0; i <= omp_get_num_devices (); i++)
|
||||
{
|
||||
#pragma omp target map(from: device_num, initial_device) device(i)
|
||||
{
|
||||
initial_device = omp_is_initial_device ();
|
||||
device_num = omp_get_device_num ();
|
||||
}
|
||||
|
||||
if (i != device_num)
|
||||
abort ();
|
||||
|
||||
if (initial_device && host_device_num != device_num)
|
||||
abort ();
|
||||
|
||||
if (!initial_device && host_device_num == device_num)
|
||||
abort ();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -4,18 +4,20 @@
|
||||
program main
|
||||
use omp_lib
|
||||
implicit none
|
||||
integer :: device_num, host_device_num
|
||||
integer :: device_num, host_device_num, i
|
||||
logical :: initial_device
|
||||
|
||||
host_device_num = omp_get_device_num ()
|
||||
if (host_device_num .ne. omp_get_initial_device ()) stop 1
|
||||
|
||||
!$omp target map(from: device_num, initial_device)
|
||||
do i = 0, omp_get_num_devices ()
|
||||
!$omp target map(from: device_num, initial_device) device(i)
|
||||
initial_device = omp_is_initial_device ()
|
||||
device_num = omp_get_device_num ()
|
||||
!$omp end target
|
||||
|
||||
if (initial_device .and. (host_device_num .ne. device_num)) stop 2
|
||||
if ((.not. initial_device) .and. (host_device_num .eq. device_num)) stop 3
|
||||
if (i /= device_num) stop 2
|
||||
if (initial_device .and. (host_device_num .ne. device_num)) stop 3
|
||||
if ((.not. initial_device) .and. (host_device_num .eq. device_num)) stop 4
|
||||
end do
|
||||
|
||||
end program main
|
||||
|
Loading…
Reference in New Issue
Block a user