Fix for pntr attri query from a peer device (#2722)
* Fix for pntr attri query from a peer device Signed-off-by: sdashmiz <shadi.dashmiz@amd.com> * SWDEV-577116 : Fix qeury on peer device - if access is disabled query should return error. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Signed-off-by: sdashmiz <shadi.dashmiz@amd.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Tento commit je obsažen v:
@@ -3604,7 +3604,8 @@ hipError_t ihipPointerGetAttributes(void* data, hipPointer_attribute attribute,
|
||||
}
|
||||
case HIP_POINTER_ATTRIBUTE_DEVICE_POINTER: {
|
||||
if (memObj) {
|
||||
device::Memory* devMem = memObj->getDeviceMemory(*hip::getCurrentDevice()->devices()[0]);
|
||||
amd::Device* currentDevice = hip::getCurrentDevice()->devices()[0];
|
||||
device::Memory* devMem = memObj->getDeviceMemory(*currentDevice);
|
||||
|
||||
// getDeviceMemory can fail, hence validate the sanity of the mem obtained
|
||||
if (nullptr == devMem) {
|
||||
@@ -3612,6 +3613,16 @@ hipError_t ihipPointerGetAttributes(void* data, hipPointer_attribute attribute,
|
||||
"getDeviceMemory for ptr failed : %p", ptr);
|
||||
return hipErrorMemoryAllocation;
|
||||
}
|
||||
|
||||
// Check if this is a cross-device access without peer access enabled
|
||||
const std::vector<amd::Device*>& memDevices = memObj->getContext().devices();
|
||||
if (memDevices.size() == 1 && memDevices[0] != currentDevice) {
|
||||
device::Memory* origDevMem = memObj->getDeviceMemory(*memDevices[0]);
|
||||
if (origDevMem != nullptr && !origDevMem->getAllowedPeerAccess()) {
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
}
|
||||
|
||||
*reinterpret_cast<hipDeviceptr_t*>(data) =
|
||||
reinterpret_cast<hipDeviceptr_t*>(devMem->virtualAddress() + offset);
|
||||
} else {
|
||||
|
||||
Odkázat v novém úkolu
Zablokovat Uživatele