aboutsummaryrefslogtreecommitdiff
path: root/offload/plugins-nextgen/amdgpu/src
diff options
context:
space:
mode:
Diffstat (limited to 'offload/plugins-nextgen/amdgpu/src')
-rw-r--r--offload/plugins-nextgen/amdgpu/src/rtl.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/offload/plugins-nextgen/amdgpu/src/rtl.cpp b/offload/plugins-nextgen/amdgpu/src/rtl.cpp
index 20d16fa..0b03ef5 100644
--- a/offload/plugins-nextgen/amdgpu/src/rtl.cpp
+++ b/offload/plugins-nextgen/amdgpu/src/rtl.cpp
@@ -3062,6 +3062,30 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
return ((IsAPU || OMPX_ApuMaps) && IsXnackEnabled);
}
+ Expected<bool> isAccessiblePtrImpl(const void *Ptr, size_t Size) override {
+ hsa_amd_pointer_info_t Info;
+ Info.size = sizeof(hsa_amd_pointer_info_t);
+
+ hsa_agent_t *Agents = nullptr;
+ uint32_t Count = 0;
+ hsa_status_t Status =
+ hsa_amd_pointer_info(Ptr, &Info, malloc, &Count, &Agents);
+
+ if (auto Err = Plugin::check(Status, "error in hsa_amd_pointer_info: %s"))
+ return std::move(Err);
+
+ // Checks if the pointer is known by HSA and accessible by the device
+ for (uint32_t i = 0; i < Count; i++) {
+ if (Agents[i].handle == getAgent().handle)
+ return Info.sizeInBytes >= Size;
+ }
+
+ // If the pointer is unknown to HSA it's assumed a host pointer
+ // in that case the device can access it on unified memory support is
+ // enabled
+ return IsXnackEnabled;
+ }
+
/// Getters and setters for stack and heap sizes.
Error getDeviceStackSize(uint64_t &Value) override {
Value = StackSize;