Add blitter support to direct submission

Related-To: NEO-5010

Change-Id: I084cec54a233e920b2868d2a61c60d1d87d0a91e
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2020-08-31 19:50:48 +02:00
parent c7e92738c6
commit 1afc985577
7 changed files with 189 additions and 12 deletions

View File

@@ -253,6 +253,114 @@ HWTEST_F(UltCommandStreamReceiverTest, givenPreambleSentAndForceSemaphoreDelayBe
EXPECT_EQ(expectedDifference, actualDifferenceWhenSemaphoreDelayReprogrammed);
}
HWTEST_F(UltCommandStreamReceiverTest, givenNoBlitterOverrideWhenBlitterNotSupportedThenExpectFalseReturned) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
DirectSubmissionProperties properties;
properties.engineSupported = false;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS));
}
HWTEST_F(UltCommandStreamReceiverTest, givenNoBlitterOverrideWhenBlitterSupportedThenExpectTrueReturned) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
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<FamilyType>();
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<FamilyType>();
DirectSubmissionProperties properties;
properties.engineSupported = true;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS));
}
HWTEST_F(UltCommandStreamReceiverTest, givenNoRenderOverrideWhenRenderNotSupportedThenExpectFalseReturned) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
DirectSubmissionProperties properties;
properties.engineSupported = false;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS));
}
HWTEST_F(UltCommandStreamReceiverTest, givenNoRenderOverrideWhenRenderSupportedThenExpectTrueReturned) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
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<FamilyType>();
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<FamilyType>();
DirectSubmissionProperties properties;
properties.engineSupported = true;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS));
}
HWTEST_F(UltCommandStreamReceiverTest, givenNoComputeOverrideWhenComputeNotSupportedThenExpectFalseReturned) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
DirectSubmissionProperties properties;
properties.engineSupported = false;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS));
}
HWTEST_F(UltCommandStreamReceiverTest, givenNoComputeOverrideWhenComputeSupportedThenExpectTrueReturned) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
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<FamilyType>();
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<FamilyType>();
DirectSubmissionProperties properties;
properties.engineSupported = true;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS));
}
typedef UltCommandStreamReceiverTest CommandStreamReceiverFlushTests;
HWTEST_F(CommandStreamReceiverFlushTests, WhenAddingBatchBufferEndThenBatchBufferEndIsAppendedCorrectly) {

View File

@@ -186,3 +186,6 @@ ZebinIgnoreIcbeVersion = 0
LogWaitingForCompletion = 0
ForceUserptrAlignment = -1
UseExternalAllocatorForSshAndDsh = 0
DirectSubmissionOverrideBlitterSupport = -1
DirectSubmissionOverrideRenderSupport = -1
DirectSubmissionOverrideComputeSupport = -1

View File

@@ -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);

View File

@@ -1070,7 +1070,9 @@ inline bool CommandStreamReceiverHw<GfxFamily>::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<GfxFamily, BlitterDispatcher<GfxFamily>>::create(device, osContext);
ret = blitterDirectSubmission->initialize(directSubmissionProperty.submitOnInit);
@@ -1084,4 +1086,29 @@ inline bool CommandStreamReceiverHw<GfxFamily>::initDirectSubmission(Device &dev
return ret;
}
template <typename GfxFamily>
inline bool CommandStreamReceiverHw<GfxFamily>::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

View File

@@ -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")

View File

@@ -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<GfxFamily>::dispatchMonitorFence(LinearStream &cmd
uint64_t gpuAddress,
uint64_t immediateData,
const HardwareInfo &hwInfo) {
EncodeMiFlushDW<GfxFamily>::programMiFlushDw(cmdBuffer, gpuAddress, immediateData, false, true);
}
template <typename GfxFamily>
inline size_t BlitterDispatcher<GfxFamily>::getSizeMonitorFence(const HardwareInfo &hwInfo) {
size_t size = 0;
size_t size = EncodeMiFlushDW<GfxFamily>::getMiFlushDwCmdSizeForDataWrite();
return size;
}
template <typename GfxFamily>
inline void BlitterDispatcher<GfxFamily>::dispatchCacheFlush(LinearStream &cmdBuffer, const HardwareInfo &hwInfo) {
EncodeMiFlushDW<GfxFamily>::programMiFlushDw(cmdBuffer, 0ull, 0ull, false, false);
}
template <typename GfxFamily>
inline size_t BlitterDispatcher<GfxFamily>::getSizeCacheFlush(const HardwareInfo &hwInfo) {
size_t size = 0;
size_t size = EncodeMiFlushDW<GfxFamily>::getMiFlushDwCmdSizeForDataWrite();
return size;
}

View File

@@ -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<FamilyType>::getSizeMonitorFence(pDevice->getHardwareInfo()));
HWTEST_F(BlitterDispatcheTest, givenBlitterWhenAskingForMonitorFenceCmdSizeThenReturnExpectedNumberOfMiFlush) {
size_t expectedSize = EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite();
EXPECT_EQ(expectedSize, BlitterDispatcher<FamilyType>::getSizeMonitorFence(pDevice->getHardwareInfo()));
}
HWTEST_F(BlitterDispatcheTest, givenBlitterWhenDispatchingMonitorFenceCmdThenDispatchNothing) {
BlitterDispatcher<FamilyType>::dispatchMonitorFence(cmdBuffer, MemoryConstants::pageSize64k, 1ull, pDevice->getHardwareInfo());
HWTEST_F(BlitterDispatcheTest, givenBlitterWhenDispatchingMonitorFenceCmdThenDispatchMiFlushWithPostSync) {
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
size_t expectedSize = EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite();
EXPECT_EQ(0u, cmdBuffer.getUsed());
uint64_t expectedGpuAddress = 0x5100ull;
uint64_t expectedValue = 0x1234ull;
BlitterDispatcher<FamilyType>::dispatchMonitorFence(cmdBuffer, expectedGpuAddress, expectedValue, pDevice->getHardwareInfo());
EXPECT_EQ(expectedSize, cmdBuffer.getUsed());
HardwareParse hwParse;
hwParse.parseCommands<FamilyType>(cmdBuffer);
auto commandsList = hwParse.getCommandsList<MI_FLUSH_DW>();
bool foundPostSync = false;
for (auto &cmd : commandsList) {
MI_FLUSH_DW *miFlush = static_cast<MI_FLUSH_DW *>(cmd);
if (miFlush->getDestinationAddress() == expectedGpuAddress &&
miFlush->getImmediateData() == expectedValue) {
foundPostSync = true;
}
}
EXPECT_TRUE(foundPostSync);
}
HWTEST_F(BlitterDispatcheTest, givenBlitterWhenAskingForCacheFlushCmdSizeThenReturnZero) {
EXPECT_EQ(0u, BlitterDispatcher<FamilyType>::getSizeCacheFlush(pDevice->getHardwareInfo()));
HWTEST_F(BlitterDispatcheTest, givenBlitterWhenAskingForCacheFlushCmdSizeThenReturnExpetedSize) {
size_t expectedSize = EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite();
EXPECT_EQ(expectedSize, BlitterDispatcher<FamilyType>::getSizeCacheFlush(pDevice->getHardwareInfo()));
}
HWTEST_F(BlitterDispatcheTest, givenBlitterWhenDispatchingCacheFlushCmdThenDispatchNothing) {
HWTEST_F(BlitterDispatcheTest, givenBlitterWhenDispatchingCacheFlushCmdThenDispatchMiFlushCommand) {
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
size_t expectedSize = EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite();
BlitterDispatcher<FamilyType>::dispatchCacheFlush(cmdBuffer, pDevice->getHardwareInfo());
EXPECT_EQ(0u, cmdBuffer.getUsed());
EXPECT_EQ(expectedSize, cmdBuffer.getUsed());
HardwareParse hwParse;
hwParse.parseCommands<FamilyType>(cmdBuffer);
auto commandsList = hwParse.getCommandsList<MI_FLUSH_DW>();
EXPECT_LE(1u, commandsList.size());
}