Fix number of available events in IPC event pools

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz 2022-11-03 11:38:20 +00:00 committed by Compute-Runtime-Automation
parent 29eee35491
commit b284b727e9
2 changed files with 7 additions and 3 deletions

View File

@ -566,6 +566,10 @@ ze_result_t ContextImp::openEventPoolIpcHandle(const ze_ipc_event_pool_handle_t
size_t numEvents = 0;
memcpy_s(&numEvents, sizeof(numEvents), hIpc.data + sizeof(int), sizeof(numEvents));
ze_event_pool_desc_t desc = {ZE_STRUCTURE_TYPE_EVENT_POOL_DESC};
desc.count = static_cast<uint32_t>(numEvents);
auto eventPool = new EventPoolImp(&desc);
uint32_t rootDeviceIndex = std::numeric_limits<uint32_t>::max();
memcpy_s(&rootDeviceIndex, sizeof(rootDeviceIndex),
hIpc.data + sizeof(int) + sizeof(numEvents), sizeof(rootDeviceIndex));
@ -590,11 +594,10 @@ ze_result_t ContextImp::openEventPoolIpcHandle(const ze_ipc_event_pool_handle_t
true);
if (alloc == nullptr) {
delete eventPool;
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
ze_event_pool_desc_t desc = {};
auto eventPool = new EventPoolImp(&desc);
eventPool->context = this;
eventPool->eventPoolAllocations =
std::make_unique<NEO::MultiGraphicsAllocation>(static_cast<uint32_t>(this->rootDeviceIndices.size()));

View File

@ -387,9 +387,10 @@ TEST_F(EventPoolIPCHandleTests, whenOpeningIpcHandleForEventPoolThenEventPoolIsC
res = context->openEventPoolIpcHandle(ipcHandle, &ipcEventPoolHandle);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
L0::EventPool *ipcEventPool = L0::EventPool::fromHandle(ipcEventPoolHandle);
auto ipcEventPool = static_cast<L0::EventPoolImp *>(L0::EventPool::fromHandle(ipcEventPoolHandle));
EXPECT_EQ(ipcEventPool->getEventSize(), eventPool->getEventSize());
EXPECT_EQ(numEvents, static_cast<uint32_t>(ipcEventPool->getNumEvents()));
res = ipcEventPool->closeIpcHandle();
EXPECT_EQ(res, ZE_RESULT_SUCCESS);