Skip to content

Commit 79dd36f

Browse files
committed
[OpenMP] Fixes check for host device number
The implemetation is allowed to return -1 for the host device number. To be complient with the spec both the device number needs to be checked against both -1 as well as the value returned by omp_get_initial_device.
1 parent 0ef2e79 commit 79dd36f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

offload/libomptarget/OpenMP/API.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ EXTERN int omp_target_is_present(const void *Ptr, int DeviceNum) {
197197
}
198198

199199
/// Check whether a pointer is accessible from a device.
200-
/// Returns true when accessibility is guaranteed otherwise returns false.
200+
/// Returns true when accessibility is guaranteed otherwise returns false.
201201
EXTERN int omp_target_is_accessible(const void *Ptr, size_t Size,
202202
int DeviceNum) {
203203
TIMESCOPE();
@@ -211,7 +211,7 @@ EXTERN int omp_target_is_accessible(const void *Ptr, size_t Size,
211211
return false;
212212
}
213213

214-
if (DeviceNum == omp_get_initial_device()) {
214+
if (DeviceNum == omp_get_initial_device() || DeviceNum == -1) {
215215
DP("Call to omp_target_is_accessible on host, returning true\n");
216216
return true;
217217
}

0 commit comments

Comments
 (0)