diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index da87e3a8b5..d9f14d0cf6 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -565,7 +565,7 @@ ze_result_t CommandListCoreFamily::appendEventReset(ze_event_hand event->resetPackets(false); event->disableHostCaching(!isImmediateType()); - commandContainer.addToResidencyContainer(event->getPoolAllocation(this->device)); + commandContainer.addToResidencyContainer(event->getAllocation(this->device)); // default state of event is single packet, handle case when reset is used 1st, launchkernel 2nd - just reset all packets then, use max bool useMaxPackets = event->isEventTimestampFlagSet() || (event->getPacketsInUse() < this->partitionCount); @@ -2260,7 +2260,7 @@ ze_result_t CommandListCoreFamily::appendBlitFill(void *ptr, template void CommandListCoreFamily::appendSignalEventPostWalker(Event *event, void **syncCmdBuffer, CommandToPatchContainer *outTimeStampSyncCmds, bool skipBarrierForEndProfiling, bool skipAddingEventToResidency, bool copyOperation) { - if (event == nullptr || !event->getPoolAllocation(this->device)) { + if (event == nullptr || !event->getAllocation(this->device)) { return; } if (event->isEventTimestampFlagSet()) { @@ -2268,7 +2268,7 @@ void CommandListCoreFamily::appendSignalEventPostWalker(Event *ev } else { event->resetKernelCountAndPacketUsedCount(); if (!skipAddingEventToResidency) { - commandContainer.addToResidencyContainer(event->getPoolAllocation(this->device)); + commandContainer.addToResidencyContainer(event->getAllocation(this->device)); } event->setPacketsInUse(copyOperation ? 1 : this->partitionCount); @@ -2281,7 +2281,7 @@ void CommandListCoreFamily::appendEventForProfilingCopyCommand(Ev if (!event->isEventTimestampFlagSet()) { return; } - commandContainer.addToResidencyContainer(event->getPoolAllocation(this->device)); + commandContainer.addToResidencyContainer(event->getAllocation(this->device)); if (beforeWalker) { event->resetKernelCountAndPacketUsedCount(); @@ -2468,7 +2468,7 @@ ze_result_t CommandListCoreFamily::appendSignalEvent(ze_event_han return ZE_RESULT_ERROR_INVALID_ARGUMENT; } - commandContainer.addToResidencyContainer(event->getPoolAllocation(this->device)); + commandContainer.addToResidencyContainer(event->getAllocation(this->device)); NEO::Device *neoDevice = device->getNEODevice(); uint32_t callId = 0; if (NEO::debugManager.flags.EnableSWTags.get()) { @@ -2669,7 +2669,7 @@ ze_result_t CommandListCoreFamily::appendWaitOnEvents(uint32_t nu } if (!skipAddingWaitEventsToResidency) { - commandContainer.addToResidencyContainer(event->getPoolAllocation(this->device)); + commandContainer.addToResidencyContainer(event->getAllocation(this->device)); } appendWaitOnSingleEvent(event, outWaitCmds, relaxedOrderingAllowed, CommandToPatch::WaitEventSemaphoreWait); @@ -2854,7 +2854,7 @@ void CommandListCoreFamily::appendEventForProfiling(Event *event, } if (!skipAddingEventToResidency) { - commandContainer.addToResidencyContainer(event->getPoolAllocation(this->device)); + commandContainer.addToResidencyContainer(event->getAllocation(this->device)); } bool workloadPartition = isTimestampEventForMultiTile(event); @@ -2971,7 +2971,7 @@ ze_result_t CommandListCoreFamily::appendQueryKernelTimestamps( for (uint32_t i = 0u; i < numEvents; ++i) { auto event = Event::fromHandle(phEvents[i]); - commandContainer.addToResidencyContainer(event->getPoolAllocation(this->device)); + commandContainer.addToResidencyContainer(event->getAllocation(this->device)); timestampsData[i].address = event->getGpuAddress(this->device); timestampsData[i].packetsInUse = event->getPacketsInUse(); timestampsData[i].timestampSizeInDw = event->getTimestampSizeInDw(); diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl b/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl index 4b40089d61..46de98ed4c 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl @@ -218,7 +218,7 @@ ze_result_t CommandListCoreFamily::appendLaunchKernelWithParams(K compactEvent = event; event = nullptr; } else { - NEO::GraphicsAllocation *eventPoolAlloc = event->getPoolAllocation(this->device); + NEO::GraphicsAllocation *eventPoolAlloc = event->getAllocation(this->device); if (eventPoolAlloc) { if (!launchParams.omitAddingEventResidency) { diff --git a/level_zero/core/source/event/event.cpp b/level_zero/core/source/event/event.cpp index 840f5975fb..c28ebbd9f9 100644 --- a/level_zero/core/source/event/event.cpp +++ b/level_zero/core/source/event/event.cpp @@ -407,11 +407,19 @@ void Event::disableImplicitCounterBasedMode() { } uint64_t Event::getGpuAddress(Device *device) const { - return getPoolAllocation(device)->getGpuAddress() + this->eventPoolOffset; + return getAllocation(device)->getGpuAddress() + this->eventPoolOffset; } -NEO::GraphicsAllocation *Event::getPoolAllocation(Device *device) const { - return this->eventPoolAllocation ? this->eventPoolAllocation->getGraphicsAllocation(device->getNEODevice()->getRootDeviceIndex()) : nullptr; +NEO::GraphicsAllocation *Event::getAllocation(Device *device) const { + auto rootDeviceIndex = device->getNEODevice()->getRootDeviceIndex(); + + if (inOrderTimestampNode) { + return inOrderTimestampNode->getBaseGraphicsAllocation()->getGraphicsAllocation(rootDeviceIndex); + } else if (eventPoolAllocation) { + return eventPoolAllocation->getGraphicsAllocation(rootDeviceIndex); + } + + return nullptr; } void Event::setGpuStartTimestamp() { diff --git a/level_zero/core/source/event/event.h b/level_zero/core/source/event/event.h index b7ef2a142c..233545b5c6 100644 --- a/level_zero/core/source/event/event.h +++ b/level_zero/core/source/event/event.h @@ -122,7 +122,7 @@ struct Event : _ze_event_handle_t { inline ze_event_handle_t toHandle() { return this; } - MOCKABLE_VIRTUAL NEO::GraphicsAllocation *getPoolAllocation(Device *device) const; + MOCKABLE_VIRTUAL NEO::GraphicsAllocation *getAllocation(Device *device) const; void setEventPool(EventPool *eventPool) { this->eventPool = eventPool; } EventPool *peekEventPool() { return this->eventPool; } diff --git a/level_zero/core/source/event/event_impl.inl b/level_zero/core/source/event/event_impl.inl index c1f7d7b775..e81916f677 100644 --- a/level_zero/core/source/event/event_impl.inl +++ b/level_zero/core/source/event/event_impl.inl @@ -254,7 +254,7 @@ template TaskCountType EventImp::getTaskCount(const NEO::CommandStreamReceiver &csr) const { auto contextId = csr.getOsContext().getContextId(); - TaskCountType taskCount = getPoolAllocation(this->device) ? getPoolAllocation(this->device)->getTaskCount(contextId) : 0; + TaskCountType taskCount = getAllocation(this->device) ? getAllocation(this->device)->getTaskCount(contextId) : 0; if (inOrderExecInfo) { if (inOrderExecInfo->getDeviceCounterAllocation()) { @@ -355,7 +355,7 @@ ze_result_t EventImp::queryStatusEventPackets() { template bool EventImp::tbxDownload(NEO::CommandStreamReceiver &csr, bool &downloadedAllocation, bool &downloadedInOrdedAllocation) { if (!downloadedAllocation) { - if (auto &alloc = *this->getPoolAllocation(this->device); alloc.isUsedByOsContext(csr.getOsContext().getContextId())) { + if (auto &alloc = *this->getAllocation(this->device); alloc.isUsedByOsContext(csr.getOsContext().getContextId())) { csr.downloadAllocation(alloc); downloadedAllocation = true; } @@ -488,7 +488,7 @@ ze_result_t EventImp::hostEventSetValueTimestamps(TagSizeT eventVal) { template void EventImp::copyTbxData(uint64_t dstGpuVa, size_t copySize) { - auto alloc = getPoolAllocation(device); + auto alloc = getAllocation(device); if (!alloc) { DEBUG_BREAK_IF(true); return; diff --git a/level_zero/core/test/unit_tests/fixtures/in_order_cmd_list_fixture.h b/level_zero/core/test/unit_tests/fixtures/in_order_cmd_list_fixture.h index 12cc9b37d7..524bc793ff 100644 --- a/level_zero/core/test/unit_tests/fixtures/in_order_cmd_list_fixture.h +++ b/level_zero/core/test/unit_tests/fixtures/in_order_cmd_list_fixture.h @@ -25,6 +25,7 @@ struct InOrderCmdListFixture : public ::Test { struct FixtureMockEvent : public EventImp { using EventImp::Event::counterBasedMode; using EventImp::Event::counterBasedFlags; + using EventImp::eventPoolAllocation; using EventImp::maxPacketCount; using EventImp::inOrderExecInfo; using EventImp::inOrderExecSignalValue; diff --git a/level_zero/core/test/unit_tests/mocks/mock_event.h b/level_zero/core/test/unit_tests/mocks/mock_event.h index 390c45fe20..1adee6b110 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_event.h +++ b/level_zero/core/test/unit_tests/mocks/mock_event.h @@ -134,7 +134,7 @@ class MockEvent : public ::L0::Event { this->maxKernelCount = EventPacketsCount::maxKernelSplit; this->maxPacketCount = EventPacketsCount::eventPackets; } - NEO::GraphicsAllocation *getPoolAllocation(L0::Device *device) const override { + NEO::GraphicsAllocation *getAllocation(L0::Device *device) const override { return mockAllocation.get(); } diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp index 4dfd104001..279dc728f9 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp @@ -1001,7 +1001,7 @@ HWTEST2_F(CommandListAppendLaunchKernel, givenTimestampEventsWhenAppendingKernel { auto itorEvent = std::find(std::begin(commandList->getCmdContainer().getResidencyContainer()), std::end(commandList->getCmdContainer().getResidencyContainer()), - event->getPoolAllocation(device)); + event->getAllocation(device)); EXPECT_NE(itorEvent, std::end(commandList->getCmdContainer().getResidencyContainer())); } } @@ -1663,7 +1663,7 @@ HWTEST2_F(CommandListAppendLaunchKernelMockModule, ASSERT_EQ(ZE_RESULT_SUCCESS, eventPool->createEvent(&eventDesc, &event)); std::unique_ptr eventObject(L0::Event::fromHandle(event)); - auto eventAllocation = eventObject->getPoolAllocation(device); + auto eventAllocation = eventObject->getAllocation(device); ASSERT_NE(nullptr, eventAllocation); ze_group_count_t groupCount{1, 1, 1}; diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp index a97c49a8ec..a5eaa068ca 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp @@ -132,7 +132,7 @@ HWCMDTEST_F(IGFX_GEN12LP_CORE, CommandListAppendLaunchKernel, givenEventsWhenApp { auto itorEvent = std::find(std::begin(commandList->getCmdContainer().getResidencyContainer()), std::end(commandList->getCmdContainer().getResidencyContainer()), - event->getPoolAllocation(device)); + event->getAllocation(device)); EXPECT_NE(itorEvent, std::end(commandList->getCmdContainer().getResidencyContainer())); } } diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_xehp_and_later.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_xehp_and_later.cpp index 1a0839bebe..4a77d0a6b2 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_xehp_and_later.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_xehp_and_later.cpp @@ -2564,7 +2564,7 @@ HWTEST2_F(CommandListCreate, givenAppendSignalEventWhenSkipAddToResidencyTrueThe ASSERT_NE(nullptr, event.get()); auto &residencyContainer = commandContainer.getResidencyContainer(); - auto eventAllocation = event->getPoolAllocation(device); + auto eventAllocation = event->getAllocation(device); void *pipeControlBuffer = nullptr; @@ -2645,7 +2645,7 @@ HWTEST2_F(CommandListCreate, ASSERT_NE(nullptr, event.get()); auto &residencyContainer = commandContainer.getResidencyContainer(); - auto eventAllocation = event->getPoolAllocation(device); + auto eventAllocation = event->getAllocation(device); auto eventBaseAddress = event->getGpuAddress(device); CommandToPatchContainer outStoreRegMemCmdList; @@ -3115,7 +3115,7 @@ HWTEST2_F(CommandListAppendLaunchKernel, ASSERT_NE(nullptr, event.get()); auto eventBaseAddress = event->getGpuAddress(device); - auto eventAlloaction = event->getPoolAllocation(device); + auto eventAlloaction = event->getAllocation(device); uint8_t computeWalkerHostBuffer[512]; uint8_t payloadHostBuffer[256]; diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist.cpp index e1acdf438e..820420979c 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist.cpp @@ -6545,6 +6545,22 @@ struct StandaloneInOrderTimestampAllocationTests : public InOrderCmdListTests { } }; +HWTEST2_F(StandaloneInOrderTimestampAllocationTests, givenTimestampEventWhenAskingForAllocationOrGpuAddressThenReturnNodeAllocation, MatchAny) { + auto eventPool = createEvents(1, true); + + auto cmdList = createImmCmdList(); + + cmdList->appendLaunchKernel(kernel->toHandle(), groupCount, events[0]->toHandle(), 0, nullptr, launchParams, false); + + EXPECT_NE(events[0]->inOrderTimestampNode->getBaseGraphicsAllocation(), events[0]->eventPoolAllocation); + EXPECT_NE(nullptr, events[0]->inOrderTimestampNode->getBaseGraphicsAllocation()); + EXPECT_NE(nullptr, events[0]->eventPoolAllocation); + + EXPECT_EQ(events[0]->inOrderTimestampNode->getBaseGraphicsAllocation()->getGraphicsAllocation(0), events[0]->getAllocation(device)); + EXPECT_EQ(events[0]->inOrderTimestampNode->getBaseGraphicsAllocation()->getGraphicsAllocation(0)->getGpuAddress(), events[0]->getGpuAddress(device)); + EXPECT_EQ(events[0]->getGpuAddress(device) + events[0]->getCompletionFieldOffset(), events[0]->getCompletionFieldGpuAddress(device)); +} + HWTEST2_F(StandaloneInOrderTimestampAllocationTests, givenTimestampEventWhenDispatchingThenAssignNewNode, MatchAny) { auto eventPool = createEvents(1, true); auto eventHandle = events[0]->toHandle(); diff --git a/level_zero/core/test/unit_tests/sources/event/test_event.cpp b/level_zero/core/test/unit_tests/sources/event/test_event.cpp index b79786cc6f..927508550d 100644 --- a/level_zero/core/test/unit_tests/sources/event/test_event.cpp +++ b/level_zero/core/test/unit_tests/sources/event/test_event.cpp @@ -3273,7 +3273,7 @@ HWTEST_F(EventTests, GivenEventWhenHostSynchronizeCalledThenExpectDownloadEventA downloadAllocationTrack[&gfxAllocation]++; }; - auto eventAllocation = event->getPoolAllocation(device); + auto eventAllocation = event->getAllocation(device); constexpr uint64_t timeout = std::numeric_limits::max(); auto result = event->hostSynchronize(timeout); EXPECT_EQ(ZE_RESULT_SUCCESS, result); @@ -3357,7 +3357,7 @@ HWTEST_F(EventContextGroupTests, givenSecondaryCsrWhenDownloadingAllocationThenU downloadCounter++; }; - auto eventAllocation = event->getPoolAllocation(device); + auto eventAllocation = event->getAllocation(device); ultCsr->makeResident(*eventAllocation); event->hostSynchronize(1); @@ -3397,7 +3397,7 @@ HWTEST_F(EventTests, GivenEventUsedOnNonDefaultCsrWhenHostSynchronizeCalledThenA downloadAllocationTrack[&gfxAllocation]++; }; - auto eventAllocation = event->getPoolAllocation(device); + auto eventAllocation = event->getAllocation(device); constexpr uint64_t timeout = 0; auto result = event->hostSynchronize(timeout); EXPECT_EQ(ZE_RESULT_SUCCESS, result); @@ -3653,7 +3653,7 @@ HWTEST_F(EventTests, GivenCsrTbxModeWhenEventCreatedAndSignaledThenEventAllocati EXPECT_EQ(0u, ultCsr.writeMemoryParams.chunkWriteCallCount); auto event = whiteboxCast(getHelper().createEvent(eventPool.get(), &eventDesc, device)); - auto eventAllocation = event->getPoolAllocation(device); + auto eventAllocation = event->getAllocation(device); EXPECT_TRUE(eventAllocation->getAubInfo().writeMemoryOnly); @@ -4340,7 +4340,7 @@ HWTEST2_F(EventMultiTileDynamicPacketUseTest, givenEventUsedCreatedOnSubDeviceBu downloadCounter1++; }; - auto eventAllocation = event->getPoolAllocation(device); + auto eventAllocation = event->getAllocation(device); ultCsr0->makeResident(*eventAllocation); rootCsr->makeResident(*eventAllocation);