Skip to content

Commit d20f4d5

Browse files
committed
[OpenMP] Adds omp_target_is_accessible routine
Adds implementation of omp_target_is_accessible routine with 5.1 behaviour, checking if a host pointer is acccessible from a device without running on the device (from the host).
1 parent bf01578 commit d20f4d5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

offload/libomptarget/OpenMP/API.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,18 +220,26 @@ EXTERN int omp_target_is_accessible(const void *Ptr, size_t Size,
220220
return true;
221221
}
222222

223-
// The device number must refer to a valid device
223+
// the device number must refer to a valid device
224224
auto DeviceOrErr = PM->getDevice(DeviceNum);
225225
if (!DeviceOrErr)
226226
FATAL_MESSAGE(DeviceNum, "%s", toString(DeviceOrErr.takeError()).c_str());
227227

228-
// For OpenMP 5.1 the routine checks whether a host pointer is accessible from
228+
// TODO: Add check for openmp version compatability
229+
230+
// for OpenMP 5.1 the routine checks whether a host pointer is accessible from
229231
// the device this requires for the device to support unified shared memory
230232
if (DeviceOrErr->supportsUnifiedMemory()) {
231233
DP("Device %d supports unified memory, returning true\n", DeviceNum);
232234
return true;
233235
}
234236

237+
// TODO: Provide stubs & implementation to check whether a pointer is accessible from a given device
238+
// using hsa_amd_pointer_info for AMDGPU implementation
239+
// for OpenMP 6.x the specification is required to return true if
240+
// the accessibility of the pointer can be determined otherwise it's allowed to return false
241+
// the specification will be clarified from the current wording
242+
235243
// functionality to check whether a device pointer is accessible from a device
236244
// (OpenMP 6.0) from the host might not be possible
237245
DP("Device %d does not support unified memory, returning false\n", DeviceNum);

0 commit comments

Comments
 (0)