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: b434fbe2bd]
This commit is contained in:
Huang, AnZhong
2025-05-09 17:34:16 +08:00
committad av GitHub
förälder a8630e866d
incheckning 3decd4f975
+11 -1
Visa fil
@@ -3454,7 +3454,17 @@ hipError_t ihipPointerGetAttributes(void* data, hipPointer_attribute attribute,
switch (attribute) { switch (attribute) {
case HIP_POINTER_ATTRIBUTE_CONTEXT : { case HIP_POINTER_ATTRIBUTE_CONTEXT : {
status = hipErrorNotSupported; if (memObj) {
amd::Context& context = memObj->getContext();
int devId = getDeviceID(context);
if (devId >= 0) {
*reinterpret_cast<hipCtx_t*>(data) = reinterpret_cast<hipCtx_t>(g_devices[devId]);
} else {
return hipErrorInvalidValue;
}
} else {
return hipErrorInvalidValue;
}
break; break;
} }
case HIP_POINTER_ATTRIBUTE_MEMORY_TYPE : { case HIP_POINTER_ATTRIBUTE_MEMORY_TYPE : {