From 3decd4f9755d85544af49a4a364e5a641ecb2947 Mon Sep 17 00:00:00 2001 From: "Huang, AnZhong" Date: Fri, 9 May 2025 17:34:16 +0800 Subject: [PATCH] SWDEV-527299 - Support HIP_POINTER_ATTRIBUTE_CONTEXT (#180) * SWDEV-527299 - Support HIP_POINTER_ATTRIBUTE_CONTEXT As HIP enables UVA by default, it seems we can simply expose the context to support this feature. [ROCm/clr commit: b434fbe2bd4416b09a9932c2ba47823b118e266c] --- projects/clr/hipamd/src/hip_memory.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/projects/clr/hipamd/src/hip_memory.cpp b/projects/clr/hipamd/src/hip_memory.cpp index 6ff0939b2c..a0b6bcf6b7 100644 --- a/projects/clr/hipamd/src/hip_memory.cpp +++ b/projects/clr/hipamd/src/hip_memory.cpp @@ -3454,7 +3454,17 @@ hipError_t ihipPointerGetAttributes(void* data, hipPointer_attribute attribute, switch (attribute) { case HIP_POINTER_ATTRIBUTE_CONTEXT : { - status = hipErrorNotSupported; + if (memObj) { + amd::Context& context = memObj->getContext(); + int devId = getDeviceID(context); + if (devId >= 0) { + *reinterpret_cast(data) = reinterpret_cast(g_devices[devId]); + } else { + return hipErrorInvalidValue; + } + } else { + return hipErrorInvalidValue; + } break; } case HIP_POINTER_ATTRIBUTE_MEMORY_TYPE : {