diff --git a/shared/source/command_container/command_encoder_xehp_and_later.inl b/shared/source/command_container/command_encoder_xehp_and_later.inl index 5fe34367c0..7065946ceb 100644 --- a/shared/source/command_container/command_encoder_xehp_and_later.inl +++ b/shared/source/command_container/command_encoder_xehp_and_later.inl @@ -274,6 +274,9 @@ void EncodeDispatchKernel::encode(CommandContainer &container, if (ImplicitScalingHelper::isImplicitScalingEnabled(device->getDeviceBitfield(), !isCooperative) && !isInternal) { const uint64_t workPartitionAllocationGpuVa = device->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocationGpuAddress(); + if (eventAddress != 0) { + postSync.setOperation(POSTSYNC_DATA::OPERATION_WRITE_TIMESTAMP); + } ImplicitScalingDispatch::dispatchCommands(*listCmdBufferStream, walkerCmd, device->getDeviceBitfield(), diff --git a/shared/test/unit_test/encoders/test_encode_dispatch_kernel_xehp_and_later.cpp b/shared/test/unit_test/encoders/test_encode_dispatch_kernel_xehp_and_later.cpp index 82300426e2..82c0c46b5d 100644 --- a/shared/test/unit_test/encoders/test_encode_dispatch_kernel_xehp_and_later.cpp +++ b/shared/test/unit_test/encoders/test_encode_dispatch_kernel_xehp_and_later.cpp @@ -887,6 +887,7 @@ struct CommandEncodeStatesImplicitScalingFixture : public CommandEncodeStatesFix DebugManager.flags.CreateMultipleSubDevices.set(2); osLocalMemoryBackup = std::make_unique>(&OSInterface::osEnableLocalMemory, true); mockDeviceBackup = std::make_unique>(&MockDevice::createSingleDevice, false); + apiSupportBackup = std::make_unique>(&ImplicitScaling::apiSupport, true); CommandEncodeStatesFixture::SetUp(); } @@ -898,27 +899,62 @@ struct CommandEncodeStatesImplicitScalingFixture : public CommandEncodeStatesFix DebugManagerStateRestore restorer; std::unique_ptr> osLocalMemoryBackup; std::unique_ptr> mockDeviceBackup; + std::unique_ptr> apiSupportBackup; }; -struct CommandEncodeStatesDynamicImplicitScaling : ::testing::Test, CommandEncodeStatesImplicitScalingFixture { - void SetUp() override { +using CommandEncodeStatesImplicitScaling = Test; + +HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesImplicitScaling, + givenStaticPartitioningWhenNonTimestampEventProvidedThenExpectTimestampComputeWalkerPostSync) { + using WALKER_TYPE = typename FamilyType::WALKER_TYPE; + using POSTSYNC_DATA = typename FamilyType::POSTSYNC_DATA; + + uint32_t dims[] = {16, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + + uint32_t partitionCount = 0; + bool requiresUncachedMocs = false; + uint64_t eventAddress = 0xFF112233000; + constexpr bool timestampEvent = false; + + EncodeDispatchKernel::encode(*cmdContainer.get(), dims, false, false, dispatchInterface.get(), eventAddress, timestampEvent, false, pDevice, + NEO::PreemptionMode::Disabled, requiresUncachedMocs, false, partitionCount, false, false); + size_t usedBuffer = cmdContainer->getCommandStream()->getUsed(); + EXPECT_EQ(2u, partitionCount); + + GenCmdList partitionedWalkerList; + CmdParse::parseCommandBuffer( + partitionedWalkerList, + cmdContainer->getCommandStream()->getCpuBase(), + usedBuffer); + + auto itor = find(partitionedWalkerList.begin(), partitionedWalkerList.end()); + ASSERT_NE(itor, partitionedWalkerList.end()); + auto partitionWalkerCmd = genCmdCast(*itor); + auto &postSync = partitionWalkerCmd->getPostSync(); + EXPECT_EQ(POSTSYNC_DATA::OPERATION_WRITE_TIMESTAMP, postSync.getOperation()); + EXPECT_EQ(eventAddress, postSync.getDestinationAddress()); +} + +struct CommandEncodeStatesDynamicImplicitScalingFixture : CommandEncodeStatesImplicitScalingFixture { + void SetUp() { DebugManager.flags.EnableStaticPartitioning.set(0); CommandEncodeStatesImplicitScalingFixture::SetUp(); } - void TearDown() override { + void TearDown() { CommandEncodeStatesImplicitScalingFixture::TearDown(); } DebugManagerStateRestore restore{}; }; +using CommandEncodeStatesDynamicImplicitScaling = Test; + HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesDynamicImplicitScaling, givenImplicitScalingWhenEncodingDispatchKernelThenExpectPartitionCommandBuffer) { using WALKER_TYPE = typename FamilyType::WALKER_TYPE; using BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START; - VariableBackup backup(&ImplicitScaling::apiSupport, true); - uint32_t dims[] = {16, 1, 1}; std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); @@ -986,7 +1022,6 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesDynamicImplicitScaling, givenImp using MI_ATOMIC = typename FamilyType::MI_ATOMIC; using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; - VariableBackup backup(&ImplicitScaling::apiSupport, true); VariableBackup pipeControlConfigBackup(&ImplicitScalingDispatch::getPipeControlStallRequired(), true); uint32_t dims[] = {16, 1, 1}; @@ -1093,7 +1128,6 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesDynamicImplicitScaling, using MI_ATOMIC = typename FamilyType::MI_ATOMIC; using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; - VariableBackup backup(&ImplicitScaling::apiSupport, true); VariableBackup pipeControlConfigBackup(&ImplicitScalingDispatch::getPipeControlStallRequired(), false); uint32_t dims[] = {16, 1, 1}; @@ -1161,7 +1195,6 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesDynamicImplicitScaling, givenImp using WALKER_TYPE = typename FamilyType::WALKER_TYPE; using BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START; using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM; - VariableBackup backup(&ImplicitScaling::apiSupport, true); uint32_t dims[] = {16, 1, 1}; std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder());