Skip to content

Commit b284b72

Browse files
Fix number of available events in IPC event pools
Signed-off-by: Zbigniew Zdanowicz <[email protected]>
1 parent 29eee35 commit b284b72

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

level_zero/core/source/context/context_imp.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,10 @@ ze_result_t ContextImp::openEventPoolIpcHandle(const ze_ipc_event_pool_handle_t
566566
size_t numEvents = 0;
567567
memcpy_s(&numEvents, sizeof(numEvents), hIpc.data + sizeof(int), sizeof(numEvents));
568568

569+
ze_event_pool_desc_t desc = {ZE_STRUCTURE_TYPE_EVENT_POOL_DESC};
570+
desc.count = static_cast<uint32_t>(numEvents);
571+
auto eventPool = new EventPoolImp(&desc);
572+
569573
uint32_t rootDeviceIndex = std::numeric_limits<uint32_t>::max();
570574
memcpy_s(&rootDeviceIndex, sizeof(rootDeviceIndex),
571575
hIpc.data + sizeof(int) + sizeof(numEvents), sizeof(rootDeviceIndex));
@@ -590,11 +594,10 @@ ze_result_t ContextImp::openEventPoolIpcHandle(const ze_ipc_event_pool_handle_t
590594
true);
591595

592596
if (alloc == nullptr) {
597+
delete eventPool;
593598
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
594599
}
595600

596-
ze_event_pool_desc_t desc = {};
597-
auto eventPool = new EventPoolImp(&desc);
598601
eventPool->context = this;
599602
eventPool->eventPoolAllocations =
600603
std::make_unique<NEO::MultiGraphicsAllocation>(static_cast<uint32_t>(this->rootDeviceIndices.size()));

level_zero/core/test/unit_tests/sources/event/test_event.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,10 @@ TEST_F(EventPoolIPCHandleTests, whenOpeningIpcHandleForEventPoolThenEventPoolIsC
387387
res = context->openEventPoolIpcHandle(ipcHandle, &ipcEventPoolHandle);
388388
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
389389

390-
L0::EventPool *ipcEventPool = L0::EventPool::fromHandle(ipcEventPoolHandle);
390+
auto ipcEventPool = static_cast<L0::EventPoolImp *>(L0::EventPool::fromHandle(ipcEventPoolHandle));
391391

392392
EXPECT_EQ(ipcEventPool->getEventSize(), eventPool->getEventSize());
393+
EXPECT_EQ(numEvents, static_cast<uint32_t>(ipcEventPool->getNumEvents()));
393394

394395
res = ipcEventPool->closeIpcHandle();
395396
EXPECT_EQ(res, ZE_RESULT_SUCCESS);

0 commit comments

Comments
 (0)