From 36ca1bbe2d04ba23042fc764ea5f6277ef0eb396 Mon Sep 17 00:00:00 2001 From: Zbigniew Zdanowicz Date: Fri, 23 Feb 2024 14:31:21 +0000 Subject: [PATCH] feature: store post sync command in out postsync command pointer Related-To: NEO-10064 Signed-off-by: Zbigniew Zdanowicz --- level_zero/core/source/cmdlist/cmdlist_hw.inl | 4 ++ .../cmdlist/test_cmdlist_xehp_and_later.cpp | 54 +++++++++++++++++-- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index c60a781941..3991ee2d62 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -3593,6 +3593,10 @@ void CommandListCoreFamily::dispatchPostSyncCommands(const CmdLis value, device->getNEODevice()->getRootDeviceEnvironment(), pipeControlArgs); + + if (syncCmdBuffer != nullptr) { + *syncCmdBuffer = pipeControlArgs.postSyncCmd; + } } if (eventOperations.isTimestmapEvent && !skipPartitionOffsetProgramming) { 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 33afe5e44f..1de267bd59 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 @@ -2398,9 +2398,13 @@ HWTEST2_F(CommandListCreate, givenPlatformSupportsHdcUntypedCacheFlushWhenAppend } HWTEST2_F(CommandListCreate, givenAppendSignalEventWhenSkipAddToResidencyTrueThenEventAllocationNotAddedToResidency, IsAtLeastXeHpCore) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION; + auto commandList = std::make_unique>>(); auto result = commandList->initialize(device, NEO::EngineGroupType::compute, 0u); ASSERT_EQ(ZE_RESULT_SUCCESS, result); + auto &commandContainer = commandList->getCmdContainer(); ze_event_pool_desc_t eventPoolDesc = {}; eventPoolDesc.count = 1; @@ -2415,20 +2419,62 @@ HWTEST2_F(CommandListCreate, givenAppendSignalEventWhenSkipAddToResidencyTrueThe auto event = std::unique_ptr(L0::Event::create(eventPool.get(), &eventDesc, device)); ASSERT_NE(nullptr, event.get()); - auto &residencyContainer = commandList->getCmdContainer().getResidencyContainer(); + auto &residencyContainer = commandContainer.getResidencyContainer(); auto eventAllocation = event->getPoolAllocation(device); + void *pipeControlBuffer = nullptr; + + auto commandStreamOffset = commandContainer.getCommandStream()->getUsed(); bool skipAdd = true; - commandList->appendEventForProfilingAllWalkers(event.get(), nullptr, false, true, skipAdd); + commandList->appendEventForProfilingAllWalkers(event.get(), &pipeControlBuffer, false, true, skipAdd); auto eventAllocIt = std::find(residencyContainer.begin(), residencyContainer.end(), eventAllocation); EXPECT_EQ(residencyContainer.end(), eventAllocIt); - skipAdd = false; + ASSERT_NE(nullptr, pipeControlBuffer); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, + ptrOffset(commandContainer.getCommandStream()->getCpuBase(), commandStreamOffset), + commandContainer.getCommandStream()->getUsed() - commandStreamOffset)); - commandList->appendEventForProfilingAllWalkers(event.get(), nullptr, false, true, skipAdd); + auto pcList = findAll(cmdList.begin(), cmdList.end()); + ASSERT_NE(0u, pcList.size()); + + PIPE_CONTROL *postSyncPipeControl = nullptr; + for (const auto it : pcList) { + postSyncPipeControl = genCmdCast(*it); + if (postSyncPipeControl->getPostSyncOperation() == POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA) { + break; + } + } + ASSERT_NE(nullptr, postSyncPipeControl); + ASSERT_EQ(postSyncPipeControl, pipeControlBuffer); + + commandStreamOffset = commandContainer.getCommandStream()->getUsed(); + skipAdd = false; + commandList->appendEventForProfilingAllWalkers(event.get(), &pipeControlBuffer, false, true, skipAdd); eventAllocIt = std::find(residencyContainer.begin(), residencyContainer.end(), eventAllocation); EXPECT_NE(residencyContainer.end(), eventAllocIt); + + cmdList.clear(); + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, + ptrOffset(commandContainer.getCommandStream()->getCpuBase(), commandStreamOffset), + commandContainer.getCommandStream()->getUsed() - commandStreamOffset)); + + pcList = findAll(cmdList.begin(), cmdList.end()); + ASSERT_NE(0u, pcList.size()); + + postSyncPipeControl = nullptr; + for (const auto it : pcList) { + postSyncPipeControl = genCmdCast(*it); + if (postSyncPipeControl->getPostSyncOperation() == POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA) { + break; + } + } + ASSERT_NE(nullptr, postSyncPipeControl); + ASSERT_EQ(postSyncPipeControl, pipeControlBuffer); } } // namespace ult