Skip to content

Commit 2792290

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 d4ecaf6 commit 2792290

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

offload/libomptarget/OpenMP/API.cpp

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

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

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

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

0 commit comments

Comments
 (0)