From 39e6548ef6a027d2952d4dc5fbd4a3627b03680e Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Mon, 16 Nov 2020 17:12:08 +0000 Subject: [PATCH] Add mi_arb_check between blit commands Signed-off-by: Bartosz Dunajski --- .../command_stream_receiver_hw_1_tests.cpp | 98 +++++++++++++++++-- .../command_stream_receiver_hw_2_tests.cpp | 28 +++++- .../unit_test/mem_obj/buffer_bcs_tests.cpp | 35 +++---- .../command_container/command_encoder.h | 8 ++ .../command_container/command_encoder.inl | 9 ++ shared/source/gen11/command_encoder_gen11.cpp | 1 + .../gen12lp/command_encoder_gen12lp.cpp | 1 + shared/source/gen8/command_encoder_gen8.cpp | 1 + shared/source/gen9/command_encoder_gen9.cpp | 1 + shared/source/helpers/blit_commands_helper.h | 1 + .../helpers/blit_commands_helper_base.inl | 39 ++++++-- .../helpers/blit_commands_helper_bdw_plus.inl | 5 + shared/source/helpers/constants.h | 7 ++ .../gen11/command_encoder_tests_gen11.cpp | 5 + .../gen12lp/test_command_encoder_gen12lp.cpp | 6 ++ .../gen8/command_encoder_tests_gen8.cpp | 5 + .../gen9/test_command_encoder_gen9.cpp | 6 ++ .../helpers/blit_commands_helper_tests.cpp | 48 ++++++--- 18 files changed, 252 insertions(+), 52 deletions(-) diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp index a41d94c750..c2833aa51f 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp @@ -612,7 +612,12 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenEstimatingCommandsSizeThenCal const uint32_t numberOfBlitOperations = 4; auto baseSize = EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite() + sizeof(typename FamilyType::MI_BATCH_BUFFER_END); - constexpr size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT); + size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + cmdsSizePerBlit += EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + } + auto expectedBlitInstructionsSize = cmdsSizePerBlit * numberOfBlts; auto expectedAlignedSize = baseSize + MemorySynchronizationCommands::getSizeForAdditonalSynchronization(pDevice->getHardwareInfo()); @@ -641,7 +646,12 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenDirectsubmissionEnabledEstima const uint32_t numberOfBlitOperations = 4; auto baseSize = EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite() + sizeof(typename FamilyType::MI_BATCH_BUFFER_START); - constexpr size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT); + size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + cmdsSizePerBlit += EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + } + auto expectedBlitInstructionsSize = cmdsSizePerBlit * numberOfBlts; auto expectedAlignedSize = baseSize + MemorySynchronizationCommands::getSizeForAdditonalSynchronization(pDevice->getHardwareInfo()); @@ -668,7 +678,11 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenEstimatingCommandsSizeForWrit const Vec3 bltSize = {(3 * max2DBlitSize), 4, 2}; const size_t numberOfBlts = 3 * bltSize.y * bltSize.z; const size_t numberOfBlitOperations = 4 * bltSize.y * bltSize.z; - const size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT); + size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + cmdsSizePerBlit += EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + } auto baseSize = EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite() + sizeof(typename FamilyType::MI_BATCH_BUFFER_END); auto expectedBlitInstructionsSize = cmdsSizePerBlit * numberOfBlts; @@ -697,7 +711,11 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenDirectSubmissionEnabledEstima const Vec3 bltSize = {(3 * max2DBlitSize), 4, 2}; const size_t numberOfBlts = 3 * bltSize.y * bltSize.z; const size_t numberOfBlitOperations = 4 * bltSize.y * bltSize.z; - const size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT); + size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + cmdsSizePerBlit += EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + } auto baseSize = EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite() + sizeof(typename FamilyType::MI_BATCH_BUFFER_START); auto expectedBlitInstructionsSize = cmdsSizePerBlit * numberOfBlts; @@ -722,7 +740,11 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenDirectSubmissionEnabledEstima } HWTEST_F(BcsTests, givenTimestampPacketWriteRequestWhenEstimatingSizeForCommandsThenAddMiFlushDw) { - constexpr size_t expectedBaseSize = sizeof(typename FamilyType::XY_COPY_BLT); + size_t expectedBaseSize = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + expectedBaseSize += EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + } auto expectedSizeWithTimestampPacketWrite = expectedBaseSize + EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); auto expectedSizeWithoutTimestampPacketWrite = expectedBaseSize; @@ -737,7 +759,12 @@ HWTEST_F(BcsTests, givenTimestampPacketWriteRequestWhenEstimatingSizeForCommands } HWTEST_F(BcsTests, givenTimestampPacketWriteRequestWhenEstimatingSizeForCommandsWithProfilingThenAddMiFlushDw) { - size_t expectedBaseSize = sizeof(typename FamilyType::XY_COPY_BLT) + EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + size_t expectedBaseSize = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK) + + EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + expectedBaseSize += EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + } auto expectedSizeWithTimestampPacketWriteAndProfiling = expectedBaseSize + 4 * sizeof(typename FamilyType::MI_STORE_REGISTER_MEM); @@ -760,7 +787,12 @@ HWTEST_F(BcsTests, givenBltSizeAndCsrDependenciesWhenEstimatingCommandSizeThenAd csrDependencies.push_back(×tamp0); csrDependencies.push_back(×tamp1); - constexpr size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT); + size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + cmdsSizePerBlit += EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + } + size_t expectedSize = (cmdsSizePerBlit * numberOfBlts) + TimestampPacketHelper::getRequiredCmdStreamSize(csrDependencies); @@ -822,6 +854,19 @@ HWTEST_F(BcsTests, givenBltSizeWithLeftoverWhenDispatchedThenProgramAllRequiredC EXPECT_EQ(expectedHeight, bltCmd->getTransferHeight()); EXPECT_EQ(expectedWidth, bltCmd->getDestinationPitch()); EXPECT_EQ(expectedWidth, bltCmd->getSourcePitch()); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + auto miFlush = genCmdCast(*(cmdIterator++)); + EXPECT_NE(nullptr, miFlush); + if (EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite() == 2 * sizeof(typename FamilyType::MI_FLUSH_DW)) { + miFlush = genCmdCast(*(cmdIterator++)); + EXPECT_NE(nullptr, miFlush); + } + } + + auto miArbCheckCmd = genCmdCast(*(cmdIterator++)); + EXPECT_NE(nullptr, miArbCheckCmd); + EXPECT_TRUE(memcmp(&FamilyType::cmdInitArbCheck, miArbCheckCmd, sizeof(typename FamilyType::MI_ARB_CHECK)) == 0); } if (UnitTestHelper::isAdditionalSynchronizationRequired(pDevice->getHardwareInfo())) { @@ -1041,6 +1086,19 @@ HWTEST_P(BcsDetaliedTestsWithParams, givenBltSizeWithLeftoverWhenDispatchedThenP EXPECT_EQ(srcAddr, expectedSrcAddr); offset += (expectedWidth * expectedHeight); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + auto miFlush = genCmdCast(*(cmdIterator++)); + EXPECT_NE(nullptr, miFlush); + if (EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite() == 2 * sizeof(typename FamilyType::MI_FLUSH_DW)) { + miFlush = genCmdCast(*(cmdIterator++)); + EXPECT_NE(nullptr, miFlush); + } + } + + auto miArbCheckCmd = genCmdCast(*(cmdIterator++)); + EXPECT_NE(nullptr, miArbCheckCmd); + EXPECT_TRUE(memcmp(&FamilyType::cmdInitArbCheck, miArbCheckCmd, sizeof(typename FamilyType::MI_ARB_CHECK)) == 0); } } @@ -1120,6 +1178,19 @@ HWTEST_P(BcsDetaliedTestsWithParams, givenBltSizeWithLeftoverWhenDispatchedThenP EXPECT_EQ(srcAddr, bltCmd->getSourceBaseAddress()); offset += (expectedWidth * expectedHeight); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + auto miFlush = genCmdCast(*(cmdIterator++)); + EXPECT_NE(nullptr, miFlush); + if (EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite() == 2 * sizeof(typename FamilyType::MI_FLUSH_DW)) { + miFlush = genCmdCast(*(cmdIterator++)); + EXPECT_NE(nullptr, miFlush); + } + } + + auto miArbCheckCmd = genCmdCast(*(cmdIterator++)); + EXPECT_NE(nullptr, miArbCheckCmd); + EXPECT_TRUE(memcmp(&FamilyType::cmdInitArbCheck, miArbCheckCmd, sizeof(typename FamilyType::MI_ARB_CHECK)) == 0); } } @@ -1194,6 +1265,19 @@ HWTEST_P(BcsDetaliedTestsWithParams, givenBltSizeWithLeftoverWhenDispatchedThenP EXPECT_EQ(srcAddr, bltCmd->getSourceBaseAddress()); offset += (expectedWidth * expectedHeight); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + auto miFlush = genCmdCast(*(cmdIterator++)); + EXPECT_NE(nullptr, miFlush); + if (EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite() == 2 * sizeof(typename FamilyType::MI_FLUSH_DW)) { + miFlush = genCmdCast(*(cmdIterator++)); + EXPECT_NE(nullptr, miFlush); + } + } + + auto miArbCheckCmd = genCmdCast(*(cmdIterator++)); + EXPECT_NE(nullptr, miArbCheckCmd); + EXPECT_TRUE(memcmp(&FamilyType::cmdInitArbCheck, miArbCheckCmd, sizeof(typename FamilyType::MI_ARB_CHECK)) == 0); } } diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_2_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_2_tests.cpp index d24f7cc436..29daa16c00 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_2_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_2_tests.cpp @@ -31,7 +31,12 @@ using namespace NEO; HWTEST_F(BcsTests, givenBltSizeWhenEstimatingCommandSizeThenAddAllRequiredCommands) { constexpr auto max2DBlitSize = BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight; - constexpr auto cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT); + size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + cmdsSizePerBlit += EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + } + size_t notAlignedBltSize = (3 * max2DBlitSize) + 1; size_t alignedBltSize = (3 * max2DBlitSize); uint32_t alignedNumberOfBlts = 3; @@ -55,7 +60,12 @@ HWTEST_F(BcsTests, givenBltSizeWhenEstimatingCommandSizeThenAddAllRequiredComman HWTEST_F(BcsTests, givenDebugCapabilityWhenEstimatingCommandSizeThenAddAllRequiredCommands) { constexpr auto max2DBlitSize = BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight; - constexpr auto cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT); + size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + cmdsSizePerBlit += EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + } + const size_t debugCommandsSize = (EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite() + EncodeSempahore::getSizeMiSemaphoreWait()) * 2; constexpr uint32_t numberOfBlts = 3; @@ -79,7 +89,12 @@ HWTEST_F(BcsTests, givenDebugCapabilityWhenEstimatingCommandSizeThenAddAllRequir HWTEST_F(BcsTests, givenBltSizeWhenEstimatingCommandSizeForReadBufferRectThenAddAllRequiredCommands) { constexpr auto max2DBlitSize = BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight; - constexpr auto cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT); + size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + cmdsSizePerBlit += EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + } + Vec3 notAlignedBltSize = {(3 * max2DBlitSize) + 1, 4, 2}; Vec3 alignedBltSize = {(3 * max2DBlitSize), 4, 2}; size_t alignedNumberOfBlts = 3 * alignedBltSize.y * alignedBltSize.z; @@ -104,7 +119,12 @@ HWTEST_F(BcsTests, givenBltWithBigCopySizeWhenEstimatingCommandSizeForReadBuffer auto maxWidthToCopy = static_cast(BlitCommandsHelper::getMaxBlitWidth(rootDeviceEnvironment)); auto maxHeightToCopy = static_cast(BlitCommandsHelper::getMaxBlitHeight(rootDeviceEnvironment)); - constexpr auto cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT); + size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + cmdsSizePerBlit += EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + } + Vec3 alignedBltSize = {(3 * maxWidthToCopy), (4 * maxHeightToCopy), 2}; Vec3 notAlignedBltSize = {(3 * maxWidthToCopy + 1), (4 * maxHeightToCopy), 2}; diff --git a/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp index 02bd1fb1f9..3aa9935189 100644 --- a/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp @@ -823,36 +823,29 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenOutputTimestampPacketWhenBlitCalledThenP HardwareParse hwParser; hwParser.parseCommands(csr->commandStream); - uint32_t miFlushDwCmdsCount = 0; + uint32_t miFlushDwCmdsWithOutputCount = 0; bool blitCmdFound = false; for (auto &cmd : hwParser.cmdList) { if (auto miFlushDwCmd = genCmdCast(cmd)) { EXPECT_TRUE(blitCmdFound); - if (UnitTestHelper::additionalMiFlushDwRequired) { - miFlushDwCmd++; - if (miFlushDwCmdsCount % 2 == 0) { - EXPECT_EQ(miFlushDwCmdsCount == 0, - timestampPacketGpuWriteAddress == miFlushDwCmd->getDestinationAddress()); - EXPECT_EQ(miFlushDwCmdsCount == 0, - 0u == miFlushDwCmd->getImmediateData()); - } - } else { - EXPECT_EQ(miFlushDwCmdsCount == 0, - timestampPacketGpuWriteAddress == miFlushDwCmd->getDestinationAddress()); - EXPECT_EQ(miFlushDwCmdsCount == 0, - 0u == miFlushDwCmd->getImmediateData()); + if (miFlushDwCmd->getDestinationAddress() == 0) { + continue; } - miFlushDwCmdsCount++; + + EXPECT_EQ(miFlushDwCmdsWithOutputCount == 0, + timestampPacketGpuWriteAddress == miFlushDwCmd->getDestinationAddress()); + EXPECT_EQ(miFlushDwCmdsWithOutputCount == 0, + 0u == miFlushDwCmd->getImmediateData()); + + miFlushDwCmdsWithOutputCount++; } else if (genCmdCast(cmd)) { blitCmdFound = true; - EXPECT_EQ(0u, miFlushDwCmdsCount); + EXPECT_EQ(0u, miFlushDwCmdsWithOutputCount); } } - if (UnitTestHelper::additionalMiFlushDwRequired) { - EXPECT_EQ(4u, miFlushDwCmdsCount); - } else { - EXPECT_EQ(2u, miFlushDwCmdsCount); - } + + EXPECT_EQ(2u, miFlushDwCmdsWithOutputCount); // TimestampPacket + taskCount + EXPECT_TRUE(blitCmdFound); } diff --git a/shared/source/command_container/command_encoder.h b/shared/source/command_container/command_encoder.h index d128f9cd0a..af111eb4d4 100644 --- a/shared/source/command_container/command_encoder.h +++ b/shared/source/command_container/command_encoder.h @@ -309,4 +309,12 @@ struct EncodeMemoryPrefetch { static void programMemoryPrefetch(LinearStream &commandStream, const GraphicsAllocation &graphicsAllocation, uint32_t size, const HardwareInfo &hwInfo); static size_t getSizeForMemoryPrefetch(); }; + +template +struct EncodeMiArbCheck { + using MI_ARB_CHECK = typename GfxFamily::MI_ARB_CHECK; + + static void program(LinearStream &commandStream); + static size_t getCommandSize(); +}; } // namespace NEO diff --git a/shared/source/command_container/command_encoder.inl b/shared/source/command_container/command_encoder.inl index 2aec3fbe42..cff40b0a61 100644 --- a/shared/source/command_container/command_encoder.inl +++ b/shared/source/command_container/command_encoder.inl @@ -569,4 +569,13 @@ void EncodeMemoryPrefetch::programMemoryPrefetch(LinearStream &comman template size_t EncodeMemoryPrefetch::getSizeForMemoryPrefetch() { return 0; } +template +void EncodeMiArbCheck::program(LinearStream &commandStream) { + auto miArbCheckStream = commandStream.getSpaceForCmd(); + *miArbCheckStream = Family::cmdInitArbCheck; +} + +template +size_t EncodeMiArbCheck::getCommandSize() { return sizeof(MI_ARB_CHECK); } + } // namespace NEO diff --git a/shared/source/gen11/command_encoder_gen11.cpp b/shared/source/gen11/command_encoder_gen11.cpp index 15da2f596a..d93a72e212 100644 --- a/shared/source/gen11/command_encoder_gen11.cpp +++ b/shared/source/gen11/command_encoder_gen11.cpp @@ -39,4 +39,5 @@ template struct EncodeBatchBufferStartOrEnd; template struct EncodeMiFlushDW; template struct EncodeMemoryPrefetch; template struct EncodeWA; +template struct EncodeMiArbCheck; } // namespace NEO diff --git a/shared/source/gen12lp/command_encoder_gen12lp.cpp b/shared/source/gen12lp/command_encoder_gen12lp.cpp index 64fe790326..424d9ab83c 100644 --- a/shared/source/gen12lp/command_encoder_gen12lp.cpp +++ b/shared/source/gen12lp/command_encoder_gen12lp.cpp @@ -92,4 +92,5 @@ template struct EncodeBatchBufferStartOrEnd; template struct EncodeMiFlushDW; template struct EncodeWA; template struct EncodeMemoryPrefetch; +template struct EncodeMiArbCheck; } // namespace NEO diff --git a/shared/source/gen8/command_encoder_gen8.cpp b/shared/source/gen8/command_encoder_gen8.cpp index d95277d8c7..bc66560ab6 100644 --- a/shared/source/gen8/command_encoder_gen8.cpp +++ b/shared/source/gen8/command_encoder_gen8.cpp @@ -33,4 +33,5 @@ template struct EncodeBatchBufferStartOrEnd; template struct EncodeMiFlushDW; template struct EncodeMemoryPrefetch; template struct EncodeWA; +template struct EncodeMiArbCheck; } // namespace NEO diff --git a/shared/source/gen9/command_encoder_gen9.cpp b/shared/source/gen9/command_encoder_gen9.cpp index eda87d15f0..8ef0fd4034 100644 --- a/shared/source/gen9/command_encoder_gen9.cpp +++ b/shared/source/gen9/command_encoder_gen9.cpp @@ -33,4 +33,5 @@ template struct EncodeBatchBufferStartOrEnd; template struct EncodeMiFlushDW; template struct EncodeMemoryPrefetch; template struct EncodeWA; +template struct EncodeMiArbCheck; } // namespace NEO diff --git a/shared/source/helpers/blit_commands_helper.h b/shared/source/helpers/blit_commands_helper.h index 10a91d85e4..0cbe7eaf98 100644 --- a/shared/source/helpers/blit_commands_helper.h +++ b/shared/source/helpers/blit_commands_helper.h @@ -144,5 +144,6 @@ struct BlitCommandsHelper { static bool isCopyRegionPreferred(const Vec3 ©Size, const RootDeviceEnvironment &rootDeviceEnvironment); static void programGlobalSequencerFlush(LinearStream &commandStream); static size_t getSizeForGlobalSequencerFlush(); + static bool miArbCheckWaRequired(); }; } // namespace NEO diff --git a/shared/source/helpers/blit_commands_helper_base.inl b/shared/source/helpers/blit_commands_helper_base.inl index 6db2894c1a..adfa03e4a7 100644 --- a/shared/source/helpers/blit_commands_helper_base.inl +++ b/shared/source/helpers/blit_commands_helper_base.inl @@ -42,23 +42,44 @@ uint64_t BlitCommandsHelper::getMaxBlitHeight(const RootDeviceEnviron template void BlitCommandsHelper::dispatchPostBlitCommand(LinearStream &linearStream) { - if (DebugManager.flags.PostBlitCommand.get() == 0) { - auto miArbCheckStream = linearStream.getSpaceForCmd(); - *miArbCheckStream = GfxFamily::cmdInitArbCheck; - } else if (DebugManager.flags.PostBlitCommand.get() == 1) { + if (DebugManager.flags.PostBlitCommand.get() != BlitterConstants::PostBlitMode::Default) { + switch (DebugManager.flags.PostBlitCommand.get()) { + case BlitterConstants::PostBlitMode::MiArbCheck: + EncodeMiArbCheck::program(linearStream); + return; + case BlitterConstants::PostBlitMode::MiFlush: + EncodeMiFlushDW::programMiFlushDw(linearStream, 0, 0, false, false); + return; + default: + return; + } + } + + if (BlitCommandsHelper::miArbCheckWaRequired()) { EncodeMiFlushDW::programMiFlushDw(linearStream, 0, 0, false, false); } + + EncodeMiArbCheck::program(linearStream); } template size_t BlitCommandsHelper::estimatePostBlitCommandSize() { - if (DebugManager.flags.PostBlitCommand.get() == 0) { - return sizeof(typename GfxFamily::MI_ARB_CHECK); - } else if (DebugManager.flags.PostBlitCommand.get() == 1) { - return sizeof(typename GfxFamily::MI_FLUSH_DW); + if (DebugManager.flags.PostBlitCommand.get() != BlitterConstants::PostBlitMode::Default) { + switch (DebugManager.flags.PostBlitCommand.get()) { + case BlitterConstants::PostBlitMode::MiArbCheck: + return EncodeMiArbCheck::getCommandSize(); + case BlitterConstants::PostBlitMode::MiFlush: + return EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + default: + return 0; + } } - return 0; + if (BlitCommandsHelper::miArbCheckWaRequired()) { + return (EncodeMiArbCheck::getCommandSize() + EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite()); + } + + return EncodeMiArbCheck::getCommandSize(); } template diff --git a/shared/source/helpers/blit_commands_helper_bdw_plus.inl b/shared/source/helpers/blit_commands_helper_bdw_plus.inl index 090cf512dd..b9f500349a 100644 --- a/shared/source/helpers/blit_commands_helper_bdw_plus.inl +++ b/shared/source/helpers/blit_commands_helper_bdw_plus.inl @@ -82,4 +82,9 @@ size_t BlitCommandsHelper::getSizeForGlobalSequencerFlush() { return 0u; } +template +bool BlitCommandsHelper::miArbCheckWaRequired() { + return false; +} + } // namespace NEO diff --git a/shared/source/helpers/constants.h b/shared/source/helpers/constants.h index e0c0ecd8ac..6316d71925 100644 --- a/shared/source/helpers/constants.h +++ b/shared/source/helpers/constants.h @@ -71,6 +71,13 @@ enum class BlitDirection : uint32_t { HostPtrToImage, ImageToHostPtr }; + +enum PostBlitMode : int32_t { + Default = -1, + MiArbCheck = 0, + MiFlush = 1, + None = 2 +}; } // namespace BlitterConstants namespace CommonConstants { diff --git a/shared/test/unit_test/gen11/command_encoder_tests_gen11.cpp b/shared/test/unit_test/gen11/command_encoder_tests_gen11.cpp index e61f04b875..9f6a3dba7a 100644 --- a/shared/test/unit_test/gen11/command_encoder_tests_gen11.cpp +++ b/shared/test/unit_test/gen11/command_encoder_tests_gen11.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/command_container/command_encoder.h" +#include "shared/source/helpers/blit_commands_helper.h" #include "test.h" @@ -15,3 +16,7 @@ using Gen11CommandEncodeTest = testing::Test; GEN11TEST_F(Gen11CommandEncodeTest, givenGen11PlatformWhenDoBindingTablePrefetchIsCalledThenReturnsFalse) { EXPECT_FALSE(EncodeSurfaceState::doBindingTablePrefetch()); } + +GEN11TEST_F(Gen11CommandEncodeTest, givenBcsCommandsHelperWhenMiArbCheckWaRequiredThenReturnTrue) { + EXPECT_FALSE(BlitCommandsHelper::miArbCheckWaRequired()); +} diff --git a/shared/test/unit_test/gen12lp/test_command_encoder_gen12lp.cpp b/shared/test/unit_test/gen12lp/test_command_encoder_gen12lp.cpp index 4543ed3f0a..cf32942d6a 100644 --- a/shared/test/unit_test/gen12lp/test_command_encoder_gen12lp.cpp +++ b/shared/test/unit_test/gen12lp/test_command_encoder_gen12lp.cpp @@ -143,3 +143,9 @@ GEN12LPTEST_F(CommandEncoderTest, GivenGen12LpWhenProgrammingL3StateOffThenExpec auto itorLRI = find(commands.begin(), commands.end()); EXPECT_EQ(itorLRI, commands.end()); } + +using Gen12lpCommandEncodeTest = testing::Test; + +GEN12LPTEST_F(Gen12lpCommandEncodeTest, givenBcsCommandsHelperWhenMiArbCheckWaRequiredThenReturnTrue) { + EXPECT_FALSE(BlitCommandsHelper::miArbCheckWaRequired()); +} diff --git a/shared/test/unit_test/gen8/command_encoder_tests_gen8.cpp b/shared/test/unit_test/gen8/command_encoder_tests_gen8.cpp index 658796537e..12ba5563ab 100644 --- a/shared/test/unit_test/gen8/command_encoder_tests_gen8.cpp +++ b/shared/test/unit_test/gen8/command_encoder_tests_gen8.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/command_container/command_encoder.h" +#include "shared/source/helpers/blit_commands_helper.h" #include "test.h" @@ -15,3 +16,7 @@ using Gen8CommandEncodeTest = testing::Test; GEN8TEST_F(Gen8CommandEncodeTest, givenGen8PlatformWhenDoBindingTablePrefetchIsCalledThenReturnsTrue) { EXPECT_TRUE(EncodeSurfaceState::doBindingTablePrefetch()); } + +GEN8TEST_F(Gen8CommandEncodeTest, givenBcsCommandsHelperWhenMiArbCheckWaRequiredThenReturnTrue) { + EXPECT_FALSE(BlitCommandsHelper::miArbCheckWaRequired()); +} diff --git a/shared/test/unit_test/gen9/test_command_encoder_gen9.cpp b/shared/test/unit_test/gen9/test_command_encoder_gen9.cpp index a4aada49a5..9de3208e46 100644 --- a/shared/test/unit_test/gen9/test_command_encoder_gen9.cpp +++ b/shared/test/unit_test/gen9/test_command_encoder_gen9.cpp @@ -63,3 +63,9 @@ GEN9TEST_F(CommandEncoderTest, givenSLMSetCorrectMMIO) { EXPECT_EQ(cmd->getRegisterOffset(), 0x7034u); EXPECT_EQ(cmd->getDataDword(), 0x60000321u); } + +using Gen9CommandEncodeTest = testing::Test; + +GEN9TEST_F(Gen9CommandEncodeTest, givenBcsCommandsHelperWhenMiArbCheckWaRequiredThenReturnTrue) { + EXPECT_FALSE(BlitCommandsHelper::miArbCheckWaRequired()); +} diff --git a/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp b/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp index bdcade1745..377048d700 100644 --- a/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp +++ b/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp @@ -7,6 +7,7 @@ #include "shared/test/unit_test/helpers/blit_commands_helper_tests.inl" +#include "shared/source/command_container/command_encoder.h" #include "shared/source/helpers/blit_commands_helper.h" #include "shared/test/unit_test/fixtures/device_fixture.h" #include "shared/test/unit_test/helpers/debug_manager_state_restore.h" @@ -92,19 +93,24 @@ HWTEST_F(BlitTests, givenDebugVariablesWhenGettingMaxBlitSizeThenHonorUseProvide HWTEST_F(BlitTests, givenDebugVariableWhenEstimatingPostBlitsCommandSizeThenReturnCorrectResult) { const size_t arbCheckSize = sizeof(typename FamilyType::MI_ARB_CHECK); - const size_t flushSize = sizeof(typename FamilyType::MI_FLUSH_DW); DebugManagerStateRestore restore{}; - EXPECT_EQ(0u, BlitCommandsHelper::estimatePostBlitCommandSize()); + size_t expectedDefaultSize = arbCheckSize; - DebugManager.flags.PostBlitCommand.set(0); + if (BlitCommandsHelper::miArbCheckWaRequired()) { + expectedDefaultSize += EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + } + + EXPECT_EQ(expectedDefaultSize, BlitCommandsHelper::estimatePostBlitCommandSize()); + + DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::MiArbCheck); EXPECT_EQ(arbCheckSize, BlitCommandsHelper::estimatePostBlitCommandSize()); - DebugManager.flags.PostBlitCommand.set(1); - EXPECT_EQ(flushSize, BlitCommandsHelper::estimatePostBlitCommandSize()); + DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::MiFlush); + EXPECT_EQ(EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(), BlitCommandsHelper::estimatePostBlitCommandSize()); - DebugManager.flags.PostBlitCommand.set(2); + DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::None); EXPECT_EQ(0u, BlitCommandsHelper::estimatePostBlitCommandSize()); } @@ -116,25 +122,45 @@ HWTEST_F(BlitTests, givenDebugVariableWhenDispatchingPostBlitsCommandThenUseCorr LinearStream linearStream{streamBuffer, sizeof(streamBuffer)}; GenCmdList commands{}; + size_t expectedDefaultSize = sizeof(MI_ARB_CHECK); + + if (BlitCommandsHelper::miArbCheckWaRequired()) { + expectedDefaultSize += EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + } + // -1: default BlitCommandsHelper::dispatchPostBlitCommand(linearStream); - EXPECT_EQ(0u, linearStream.getUsed()); + EXPECT_EQ(expectedDefaultSize, linearStream.getUsed()); + CmdParse::parseCommandBuffer(commands, linearStream.getCpuBase(), linearStream.getUsed()); + + auto iterator = commands.begin(); + if (BlitCommandsHelper::miArbCheckWaRequired()) { + iterator = find(commands.begin(), commands.end()); + EXPECT_NE(commands.end(), iterator); + if (EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite() == 2 * sizeof(MI_FLUSH_DW)) { + iterator = find(++iterator, commands.end()); + EXPECT_NE(commands.end(), iterator); + } + } + + auto arbCheck = find(iterator, commands.end()); + EXPECT_NE(commands.end(), arbCheck); // 0: MI_ARB_CHECK memset(streamBuffer, 0, sizeof(streamBuffer)); linearStream.replaceBuffer(streamBuffer, sizeof(streamBuffer)); commands.clear(); - DebugManager.flags.PostBlitCommand.set(0); + DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::MiArbCheck); BlitCommandsHelper::dispatchPostBlitCommand(linearStream); CmdParse::parseCommandBuffer(commands, linearStream.getCpuBase(), linearStream.getUsed()); - auto arbCheck = find(commands.begin(), commands.end()); + arbCheck = find(commands.begin(), commands.end()); EXPECT_NE(commands.end(), arbCheck); // 1: MI_FLUSH_DW memset(streamBuffer, 0, sizeof(streamBuffer)); linearStream.replaceBuffer(streamBuffer, sizeof(streamBuffer)); commands.clear(); - DebugManager.flags.PostBlitCommand.set(1); + DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::MiFlush); BlitCommandsHelper::dispatchPostBlitCommand(linearStream); CmdParse::parseCommandBuffer(commands, linearStream.getCpuBase(), linearStream.getUsed()); auto miFlush = find(commands.begin(), commands.end()); @@ -144,7 +170,7 @@ HWTEST_F(BlitTests, givenDebugVariableWhenDispatchingPostBlitsCommandThenUseCorr memset(streamBuffer, 0, sizeof(streamBuffer)); linearStream.replaceBuffer(streamBuffer, sizeof(streamBuffer)); commands.clear(); - DebugManager.flags.PostBlitCommand.set(2); + DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::None); BlitCommandsHelper::dispatchPostBlitCommand(linearStream); EXPECT_EQ(0u, linearStream.getUsed()); }