From 1afc985577a5e9816f4584a82c6c20af881173b4 Mon Sep 17 00:00:00 2001 From: Zbigniew Zdanowicz Date: Mon, 31 Aug 2020 19:50:48 +0200 Subject: [PATCH] Add blitter support to direct submission Related-To: NEO-5010 Change-Id: I084cec54a233e920b2868d2a61c60d1d87d0a91e Signed-off-by: Zbigniew Zdanowicz --- .../command_stream_receiver_hw_tests.cpp | 108 ++++++++++++++++++ .../test/unit_test/test_files/igdrcl.config | 3 + .../command_stream_receiver_hw.h | 2 + .../command_stream_receiver_hw_base.inl | 29 ++++- .../debug_settings/debug_variables_base.inl | 3 + .../dispatchers/blitter_dispatcher.inl | 7 +- .../dispatchers/blitter_dispatcher_tests.cpp | 49 ++++++-- 7 files changed, 189 insertions(+), 12 deletions(-) diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests.cpp index 3008f37b70..f36b75c831 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests.cpp @@ -253,6 +253,114 @@ HWTEST_F(UltCommandStreamReceiverTest, givenPreambleSentAndForceSemaphoreDelayBe EXPECT_EQ(expectedDifference, actualDifferenceWhenSemaphoreDelayReprogrammed); } +HWTEST_F(UltCommandStreamReceiverTest, givenNoBlitterOverrideWhenBlitterNotSupportedThenExpectFalseReturned) { + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + DirectSubmissionProperties properties; + properties.engineSupported = false; + EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS)); +} + +HWTEST_F(UltCommandStreamReceiverTest, givenNoBlitterOverrideWhenBlitterSupportedThenExpectTrueReturned) { + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + DirectSubmissionProperties properties; + properties.engineSupported = true; + EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS)); +} + +HWTEST_F(UltCommandStreamReceiverTest, givenBlitterOverrideEnableWhenBlitterNotSupportedThenExpectTrueReturned) { + DebugManagerStateRestore debugManagerStateRestore; + DebugManager.flags.DirectSubmissionOverrideBlitterSupport.set(1); + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + DirectSubmissionProperties properties; + properties.engineSupported = false; + EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS)); +} + +HWTEST_F(UltCommandStreamReceiverTest, givenBlitterOverrideDisableWhenBlitterSupportedThenExpectFalseReturned) { + DebugManagerStateRestore debugManagerStateRestore; + DebugManager.flags.DirectSubmissionOverrideBlitterSupport.set(0); + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + DirectSubmissionProperties properties; + properties.engineSupported = true; + EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS)); +} + +HWTEST_F(UltCommandStreamReceiverTest, givenNoRenderOverrideWhenRenderNotSupportedThenExpectFalseReturned) { + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + DirectSubmissionProperties properties; + properties.engineSupported = false; + EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS)); +} + +HWTEST_F(UltCommandStreamReceiverTest, givenNoRenderOverrideWhenRenderSupportedThenExpectTrueReturned) { + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + DirectSubmissionProperties properties; + properties.engineSupported = true; + EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS)); +} + +HWTEST_F(UltCommandStreamReceiverTest, givenRenderOverrideEnableWhenRenderNotSupportedThenExpectTrueReturned) { + DebugManagerStateRestore debugManagerStateRestore; + DebugManager.flags.DirectSubmissionOverrideRenderSupport.set(1); + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + DirectSubmissionProperties properties; + properties.engineSupported = false; + EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS)); +} + +HWTEST_F(UltCommandStreamReceiverTest, givenRenderOverrideDisableWhenRenderSupportedThenExpectFalseReturned) { + DebugManagerStateRestore debugManagerStateRestore; + DebugManager.flags.DirectSubmissionOverrideRenderSupport.set(0); + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + DirectSubmissionProperties properties; + properties.engineSupported = true; + EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS)); +} + +HWTEST_F(UltCommandStreamReceiverTest, givenNoComputeOverrideWhenComputeNotSupportedThenExpectFalseReturned) { + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + DirectSubmissionProperties properties; + properties.engineSupported = false; + EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS)); +} + +HWTEST_F(UltCommandStreamReceiverTest, givenNoComputeOverrideWhenComputeSupportedThenExpectTrueReturned) { + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + DirectSubmissionProperties properties; + properties.engineSupported = true; + EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS)); +} + +HWTEST_F(UltCommandStreamReceiverTest, givenComputeOverrideEnableWhenComputeNotSupportedThenExpectTrueReturned) { + DebugManagerStateRestore debugManagerStateRestore; + DebugManager.flags.DirectSubmissionOverrideComputeSupport.set(1); + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + DirectSubmissionProperties properties; + properties.engineSupported = false; + EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS)); +} + +HWTEST_F(UltCommandStreamReceiverTest, givenComputeOverrideDisableWhenComputeSupportedThenExpectFalseReturned) { + DebugManagerStateRestore debugManagerStateRestore; + DebugManager.flags.DirectSubmissionOverrideComputeSupport.set(0); + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + DirectSubmissionProperties properties; + properties.engineSupported = true; + EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS)); +} + typedef UltCommandStreamReceiverTest CommandStreamReceiverFlushTests; HWTEST_F(CommandStreamReceiverFlushTests, WhenAddingBatchBufferEndThenBatchBufferEndIsAppendedCorrectly) { diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index 9289c14344..29a68b7d3a 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -186,3 +186,6 @@ ZebinIgnoreIcbeVersion = 0 LogWaitingForCompletion = 0 ForceUserptrAlignment = -1 UseExternalAllocatorForSshAndDsh = 0 +DirectSubmissionOverrideBlitterSupport = -1 +DirectSubmissionOverrideRenderSupport = -1 +DirectSubmissionOverrideComputeSupport = -1 \ No newline at end of file diff --git a/shared/source/command_stream/command_stream_receiver_hw.h b/shared/source/command_stream/command_stream_receiver_hw.h index 2591b0507a..9570e8b0f0 100644 --- a/shared/source/command_stream/command_stream_receiver_hw.h +++ b/shared/source/command_stream/command_stream_receiver_hw.h @@ -99,6 +99,8 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { } bool initDirectSubmission(Device &device, OsContext &osContext) override; + bool checkDirectSubmissionSupportsEngine(const DirectSubmissionProperties &directSubmissionProperty, + aub_stream::EngineType contextEngineType); protected: void programPreemption(LinearStream &csr, DispatchFlags &dispatchFlags); diff --git a/shared/source/command_stream/command_stream_receiver_hw_base.inl b/shared/source/command_stream/command_stream_receiver_hw_base.inl index 174090c8c5..f85acc1622 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -1070,7 +1070,9 @@ inline bool CommandStreamReceiverHw::initDirectSubmission(Device &dev startDirect = directSubmissionProperty.useRootDevice; } - if (directSubmissionProperty.engineSupported && startDirect) { + bool engineSupported = checkDirectSubmissionSupportsEngine(directSubmissionProperty, + contextEngineType); + if (engineSupported && startDirect) { if (contextEngineType == aub_stream::ENGINE_BCS) { blitterDirectSubmission = DirectSubmissionHw>::create(device, osContext); ret = blitterDirectSubmission->initialize(directSubmissionProperty.submitOnInit); @@ -1084,4 +1086,29 @@ inline bool CommandStreamReceiverHw::initDirectSubmission(Device &dev return ret; } +template +inline bool CommandStreamReceiverHw::checkDirectSubmissionSupportsEngine(const DirectSubmissionProperties &directSubmissionProperty, + aub_stream::EngineType contextEngineType) { + bool supported = directSubmissionProperty.engineSupported; + if (contextEngineType == aub_stream::ENGINE_BCS) { + int32_t blitterOverrideKey = DebugManager.flags.DirectSubmissionOverrideBlitterSupport.get(); + if (blitterOverrideKey != -1) { + supported = blitterOverrideKey == 0 ? false : true; + } + } else if (contextEngineType == aub_stream::ENGINE_RCS) { + int32_t renderOverrideKey = DebugManager.flags.DirectSubmissionOverrideRenderSupport.get(); + if (renderOverrideKey != -1) { + supported = renderOverrideKey == 0 ? false : true; + } + } else { + //assume else is CCS + int32_t computeOverrideKey = DebugManager.flags.DirectSubmissionOverrideComputeSupport.get(); + if (computeOverrideKey != -1) { + supported = computeOverrideKey == 0 ? false : true; + } + } + + return supported; +} + } // namespace NEO diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 3c585be27e..6e3cbb551e 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -115,6 +115,9 @@ DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionSemaphoreAddressing, -1, "-1: do DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionDisableCpuCacheFlush, -1, "-1: do not override, 0: disable, 1: enable") DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionEnableDebugBuffer, 0, "0: diagnostic feature disabled - dispatch regular workload, 1: dispatch diagnostic buffer - mode 1 - single SDI command, 2: dispatch diagnostic buffer - mode 2 - no command") DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionDiagnosticExecutionCount, 30, "Number of executions of EnableDebugBuffer modes within diagnostic run") +DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionOverrideBlitterSupport, -1, "Overrides default blitter support: -1: do not override, 0: disable engine support, 1: enable engine support") +DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionOverrideRenderSupport, -1, "Overrides default render support: -1: do not override, 0: disable engine support, 1: enable engine support") +DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionOverrideComputeSupport, -1, "Overrides default compute support: -1: do not override, 0: disable engine support, 1: enable engine support") DECLARE_DEBUG_VARIABLE(bool, DirectSubmissionDisableCacheFlush, false, "Disable dispatching cache flush commands") DECLARE_DEBUG_VARIABLE(bool, DirectSubmissionDisableMonitorFence, false, "Disable dispatching monitor fence commands") DECLARE_DEBUG_VARIABLE(bool, BindAllAllocations, false, "Bind all allocations during flush") diff --git a/shared/source/direct_submission/dispatchers/blitter_dispatcher.inl b/shared/source/direct_submission/dispatchers/blitter_dispatcher.inl index 68959226f7..0be1a8f9b0 100644 --- a/shared/source/direct_submission/dispatchers/blitter_dispatcher.inl +++ b/shared/source/direct_submission/dispatchers/blitter_dispatcher.inl @@ -5,6 +5,7 @@ * */ +#include "shared/source/command_container/command_encoder.h" #include "shared/source/command_stream/linear_stream.h" #include "shared/source/direct_submission/dispatchers/blitter_dispatcher.h" #include "shared/source/helpers/hw_info.h" @@ -26,21 +27,23 @@ inline void BlitterDispatcher::dispatchMonitorFence(LinearStream &cmd uint64_t gpuAddress, uint64_t immediateData, const HardwareInfo &hwInfo) { + EncodeMiFlushDW::programMiFlushDw(cmdBuffer, gpuAddress, immediateData, false, true); } template inline size_t BlitterDispatcher::getSizeMonitorFence(const HardwareInfo &hwInfo) { - size_t size = 0; + size_t size = EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); return size; } template inline void BlitterDispatcher::dispatchCacheFlush(LinearStream &cmdBuffer, const HardwareInfo &hwInfo) { + EncodeMiFlushDW::programMiFlushDw(cmdBuffer, 0ull, 0ull, false, false); } template inline size_t BlitterDispatcher::getSizeCacheFlush(const HardwareInfo &hwInfo) { - size_t size = 0; + size_t size = EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); return size; } diff --git a/shared/test/unit_test/direct_submission/dispatchers/blitter_dispatcher_tests.cpp b/shared/test/unit_test/direct_submission/dispatchers/blitter_dispatcher_tests.cpp index d8dcad2b55..b402b9d16b 100644 --- a/shared/test/unit_test/direct_submission/dispatchers/blitter_dispatcher_tests.cpp +++ b/shared/test/unit_test/direct_submission/dispatchers/blitter_dispatcher_tests.cpp @@ -5,7 +5,9 @@ * */ +#include "shared/source/command_container/command_encoder.h" #include "shared/source/direct_submission/dispatchers/blitter_dispatcher.h" +#include "shared/test/unit_test/cmd_parse/hw_parse.h" #include "shared/test/unit_test/direct_submission/dispatchers/dispatcher_fixture.h" #include "test.h" @@ -24,21 +26,50 @@ HWTEST_F(BlitterDispatcheTest, givenBlitterWhenDispatchingPreemptionCmdThenDispa EXPECT_EQ(0u, cmdBuffer.getUsed()); } -HWTEST_F(BlitterDispatcheTest, givenBlitterWhenAskingForMonitorFenceCmdSizeThenReturnZero) { - EXPECT_EQ(0u, BlitterDispatcher::getSizeMonitorFence(pDevice->getHardwareInfo())); +HWTEST_F(BlitterDispatcheTest, givenBlitterWhenAskingForMonitorFenceCmdSizeThenReturnExpectedNumberOfMiFlush) { + size_t expectedSize = EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + EXPECT_EQ(expectedSize, BlitterDispatcher::getSizeMonitorFence(pDevice->getHardwareInfo())); } -HWTEST_F(BlitterDispatcheTest, givenBlitterWhenDispatchingMonitorFenceCmdThenDispatchNothing) { - BlitterDispatcher::dispatchMonitorFence(cmdBuffer, MemoryConstants::pageSize64k, 1ull, pDevice->getHardwareInfo()); +HWTEST_F(BlitterDispatcheTest, givenBlitterWhenDispatchingMonitorFenceCmdThenDispatchMiFlushWithPostSync) { + using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW; + size_t expectedSize = EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); - EXPECT_EQ(0u, cmdBuffer.getUsed()); + uint64_t expectedGpuAddress = 0x5100ull; + uint64_t expectedValue = 0x1234ull; + BlitterDispatcher::dispatchMonitorFence(cmdBuffer, expectedGpuAddress, expectedValue, pDevice->getHardwareInfo()); + + EXPECT_EQ(expectedSize, cmdBuffer.getUsed()); + + HardwareParse hwParse; + hwParse.parseCommands(cmdBuffer); + auto commandsList = hwParse.getCommandsList(); + + bool foundPostSync = false; + for (auto &cmd : commandsList) { + MI_FLUSH_DW *miFlush = static_cast(cmd); + if (miFlush->getDestinationAddress() == expectedGpuAddress && + miFlush->getImmediateData() == expectedValue) { + foundPostSync = true; + } + } + EXPECT_TRUE(foundPostSync); } -HWTEST_F(BlitterDispatcheTest, givenBlitterWhenAskingForCacheFlushCmdSizeThenReturnZero) { - EXPECT_EQ(0u, BlitterDispatcher::getSizeCacheFlush(pDevice->getHardwareInfo())); +HWTEST_F(BlitterDispatcheTest, givenBlitterWhenAskingForCacheFlushCmdSizeThenReturnExpetedSize) { + size_t expectedSize = EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + EXPECT_EQ(expectedSize, BlitterDispatcher::getSizeCacheFlush(pDevice->getHardwareInfo())); } -HWTEST_F(BlitterDispatcheTest, givenBlitterWhenDispatchingCacheFlushCmdThenDispatchNothing) { +HWTEST_F(BlitterDispatcheTest, givenBlitterWhenDispatchingCacheFlushCmdThenDispatchMiFlushCommand) { + using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW; + size_t expectedSize = EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); + BlitterDispatcher::dispatchCacheFlush(cmdBuffer, pDevice->getHardwareInfo()); - EXPECT_EQ(0u, cmdBuffer.getUsed()); + EXPECT_EQ(expectedSize, cmdBuffer.getUsed()); + + HardwareParse hwParse; + hwParse.parseCommands(cmdBuffer); + auto commandsList = hwParse.getCommandsList(); + EXPECT_LE(1u, commandsList.size()); }