SWDEV-333557 - 1.Add support for IPC memory to enable hipIpcGetMemHandle() and hipIpcOpenMemHandle() in PAL path. Set interprocess flag for device allocations in HIP PAL. 2.Fix PAL IPC path with ResourceCache and SubAllocation 3.Minor fixes for IpcBuffer constructor and IpcAttach 4.Remove redundant checks that may go wrong

Change-Id: Ie9d99847c7c2c7b3b2aaefaaf60d23bf71b68635
Tá an tiomantas seo le fáil i:
Todd tiantuo Li
2023-06-30 03:33:21 -07:00
tuismitheoir 6b89980fb2
tiomantas 8434feed16
D'athraigh 5 comhad le 25 breiseanna agus 13 scriosta
+4 -11
Féach ar an gComhad
@@ -844,16 +844,12 @@ bool Device::IpcCreate(void* dev_ptr, size_t* mem_size, void* handle, size_t* me
}
// Calculate the memory offset from the original base ptr
*mem_offset = reinterpret_cast<address>(dev_ptr) - reinterpret_cast<address>(orig_dev_ptr);
*mem_offset = reinterpret_cast<address>(dev_ptr)
- reinterpret_cast<address>(orig_dev_ptr)
+ amd_mem_obj->getOffset();
*mem_size = amd_mem_obj->getSize();
// Check if the dev_ptr is greater than memory allocated
if (*mem_offset > *mem_size) {
DevLogPrintfError(
"Memory offset: %u cannot be greater than size of original memory allocated: %u", *mem_size,
*mem_offset);
return false;
}
auto dev_mem = static_cast<device::Memory*>(amd_mem_obj->getDeviceMemory(*this));
auto result = dev_mem->ExportHandle(handle);
@@ -882,9 +878,6 @@ bool Device::IpcAttach(const void* handle, size_t mem_size, size_t mem_offset, u
if (mem_obj_exist == nullptr) {
// Add the original mem_ptr to the MemObjMap with newly created amd_mem_obj
amd::MemObjMap::AddMemObj(amd_mem_obj->getSvmPtr(), amd_mem_obj);
// Make sure the mem_offset doesnt overflow the allocated memory
guarantee((mem_offset < mem_size), "IPC mem offset greater than allocated size");
} else {
amd_mem_obj->release();
amd_mem_obj = mem_obj_exist;