55#include <omp_testsuite.h>
66#include <string.h>
77
8- // Note that the device UIDs for the "fake" host devices used by libomptarget
9- // will always be the same as the UID for the initial device (since it *is* the
10- // same device). The other way round, the device number returned for this UID
11- // will always be the initial device.
12-
13- int is_host_device_uid (const char * device_uid ) {
14- return strcmp (device_uid ,
15- omp_get_uid_from_device (omp_get_initial_device ())) == 0 ;
16- }
17-
188int test_omp_device_uid (int device_num ) {
199 const char * device_uid = omp_get_uid_from_device (device_num );
2010 if (device_uid == NULL ) {
@@ -24,9 +14,7 @@ int test_omp_device_uid(int device_num) {
2414 }
2515
2616 int device_num_from_uid = omp_get_device_from_uid (device_uid );
27- if (device_num_from_uid != (is_host_device_uid (device_uid )
28- ? omp_get_initial_device ()
29- : device_num )) {
17+ if (device_num_from_uid != device_num ) {
3018 printf (
3119 "FAIL for device %d: omp_get_device_from_uid returned %d (UID: %s)\n" ,
3220 device_num , device_num_from_uid , device_uid );
@@ -46,21 +34,21 @@ int test_omp_device_uid(int device_num) {
4634
4735 // omp_get_uid_from_device() in the device runtime is a dummy function
4836 // returning NULL
49- const char * device_uid_target = omp_get_uid_from_device (device_num );
37+ const char * device_uid = omp_get_uid_from_device (device_num );
5038
5139 // omp_get_device_from_uid() in the device runtime is a dummy function
5240 // returning omp_invalid_device.
53- device_num_from_uid = omp_get_device_from_uid (device_uid_target );
41+ int device_num_from_uid = omp_get_device_from_uid (device_uid );
5442
5543 // Depending on whether we're executing on the device or the host, we either
5644 // got NULL as the device UID or the correct device UID. Consequently,
5745 // omp_get_device_from_uid() either returned omp_invalid_device or the
5846 // correct device number (aka omp_get_initial_device()).
59- if (device_uid_target ? device_num_from_uid != omp_get_initial_device ()
60- : device_num_from_uid != omp_invalid_device ) {
47+ if (device_uid ? device_num_from_uid != device_num
48+ : device_num_from_uid != omp_invalid_device ) {
6149 printf ("FAIL for device %d (target): omp_get_device_from_uid returned %d "
6250 "(UID: %s)\n" ,
63- device_num , device_num_from_uid , device_uid_target );
51+ device_num , device_num_from_uid , device_uid );
6452 success = 0 ;
6553 }
6654 }
0 commit comments