Skip to content

Commit 944b974

Browse files
committed
adapt tests
1 parent a8b09cf commit 944b974

File tree

2 files changed

+12
-36
lines changed

2 files changed

+12
-36
lines changed

offload/test/api/omp_device_uid.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@
44
#include <stdio.h>
55
#include <string.h>
66

7-
// Note that the device UIDs for the "fake" host devices used by libomptarget
8-
// will always be the same as the UID for the initial device (since it *is* the
9-
// same device). The other way round, the device number returned for this UID
10-
// will always be the initial device.
11-
12-
int is_host_device_uid(const char *device_uid) {
13-
return strcmp(device_uid,
14-
omp_get_uid_from_device(omp_get_initial_device())) == 0;
15-
}
16-
177
int test_omp_device_uid(int device_num) {
188
const char *device_uid = omp_get_uid_from_device(device_num);
199
if (device_uid == NULL) {
@@ -23,9 +13,7 @@ int test_omp_device_uid(int device_num) {
2313
}
2414

2515
int device_num_from_uid = omp_get_device_from_uid(device_uid);
26-
if (device_num_from_uid != (is_host_device_uid(device_uid)
27-
? omp_get_initial_device()
28-
: device_num)) {
16+
if (device_num_from_uid != device_num) {
2917
printf(
3018
"FAIL for device %d: omp_get_device_from_uid returned %d (UID: %s)\n",
3119
device_num, device_num_from_uid, device_uid);
@@ -45,21 +33,21 @@ int test_omp_device_uid(int device_num) {
4533

4634
// omp_get_uid_from_device() in the device runtime is a dummy function
4735
// returning NULL
48-
const char *device_uid_target = omp_get_uid_from_device(device_num);
36+
const char *device_uid = omp_get_uid_from_device(device_num);
4937

5038
// omp_get_device_from_uid() in the device runtime is a dummy function
5139
// returning omp_invalid_device.
52-
device_num_from_uid = omp_get_device_from_uid(device_uid_target);
40+
int device_num_from_uid = omp_get_device_from_uid(device_uid);
5341

5442
// Depending on whether we're executing on the device or the host, we either
5543
// got NULL as the device UID or the correct device UID. Consequently,
5644
// omp_get_device_from_uid() either returned omp_invalid_device or the
5745
// correct device number (aka omp_get_initial_device()).
58-
if (device_uid_target ? device_num_from_uid != omp_get_initial_device()
59-
: device_num_from_uid != omp_invalid_device) {
46+
if (device_uid ? device_num_from_uid != device_num
47+
: device_num_from_uid != omp_invalid_device) {
6048
printf("FAIL for device %d (target): omp_get_device_from_uid returned %d "
6149
"(UID: %s)\n",
62-
device_num, device_num_from_uid, device_uid_target);
50+
device_num, device_num_from_uid, device_uid);
6351
success = 0;
6452
}
6553
}

openmp/runtime/test/api/omp_device_uid.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@
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-
188
int 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

Comments
 (0)