fix: support zeEventPool IPC handles from single process

For all execution paths where needed, use `BufferObjectHandleWrapper`
instances for registration of BO-handles and try to obtain shared
ownership. This allows both sides of IPC communication to be implemented
in the same process and avoid the double-free problem on a BufferObject
of the same handle.

Currently there are two pairs of such calls:
* `zeEventPoolGetIpcHandle()` + `zeEventPoolOpenIpcHandle()`
* `zeMemGetIpcHandle()` + `zeMemOpenIpcHandle()`

The capability of executing both sides from the same process is useful
for testing but not only.

Related-To: NEO-9837
Signed-off-by: Maciej Bielski <maciej.bielski@intel.com>
This commit is contained in:
Maciej Bielski
2024-01-16 13:27:23 +00:00
committed by Compute-Runtime-Automation
parent b5f698e0c5
commit 134c718a25
3 changed files with 182 additions and 7 deletions

View File

@@ -257,8 +257,13 @@ ze_result_t EventPool::getIpcHandle(ze_ipc_event_pool_handle_t *ipcHandle) {
poolData.maxEventPackets = this->getEventMaxPackets();
poolData.numDevices = static_cast<uint32_t>(this->devices.size());
int retCode = this->eventPoolAllocations->getDefaultGraphicsAllocation()->peekInternalHandle(this->context->getDriverHandle()->getMemoryManager(), poolData.handle);
return retCode == 0 ? ZE_RESULT_SUCCESS : ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
auto memoryManager = this->context->getDriverHandle()->getMemoryManager();
auto allocation = this->eventPoolAllocations->getDefaultGraphicsAllocation();
if (int retCode = allocation->peekInternalHandle(memoryManager, poolData.handle); retCode != 0) {
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
}
memoryManager->registerIpcExportedAllocation(allocation);
return ZE_RESULT_SUCCESS;
}
ze_result_t EventPool::openEventPoolIpcHandle(const ze_ipc_event_pool_handle_t &ipcEventPoolHandle, ze_event_pool_handle_t *eventPoolHandle,