Skip to content

Commit b434fbe

Browse files
authored
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.
1 parent 2f73e13 commit b434fbe

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

hipamd/src/hip_memory.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3454,7 +3454,17 @@ hipError_t ihipPointerGetAttributes(void* data, hipPointer_attribute attribute,
34543454

34553455
switch (attribute) {
34563456
case HIP_POINTER_ATTRIBUTE_CONTEXT : {
3457-
status = hipErrorNotSupported;
3457+
if (memObj) {
3458+
amd::Context& context = memObj->getContext();
3459+
int devId = getDeviceID(context);
3460+
if (devId >= 0) {
3461+
*reinterpret_cast<hipCtx_t*>(data) = reinterpret_cast<hipCtx_t>(g_devices[devId]);
3462+
} else {
3463+
return hipErrorInvalidValue;
3464+
}
3465+
} else {
3466+
return hipErrorInvalidValue;
3467+
}
34583468
break;
34593469
}
34603470
case HIP_POINTER_ATTRIBUTE_MEMORY_TYPE : {

0 commit comments

Comments
 (0)