Skip to content

Commit f790512

Browse files
Dont inject commands between blits
Signed-off-by: Bartosz Dunajski <[email protected]>
1 parent a068a61 commit f790512

File tree

5 files changed

+32
-53
lines changed

5 files changed

+32
-53
lines changed

level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_2.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,6 @@ using BlitBlockCopyPlatforms = IsWithinProducts<IGFX_SKYLAKE, IGFX_TIGERLAKE_LP>
846846
HWTEST2_F(CommandListCreate, givenCopyCommandListWhenCopyRegionWithinMaxBlitSizeThenOneBlitCommandHasBeenSpown, BlitBlockCopyPlatforms) {
847847
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
848848
using XY_COPY_BLT = typename GfxFamily::XY_COPY_BLT;
849-
using MI_ARB_CHECK = typename GfxFamily::MI_ARB_CHECK;
850849

851850
auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>>();
852851
commandList->initialize(device, NEO::EngineGroupType::Copy);
@@ -872,9 +871,8 @@ HWTEST2_F(CommandListCreate, givenCopyCommandListWhenCopyRegionWithinMaxBlitSize
872871
cmdList, ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0), commandList->commandContainer.getCommandStream()->getUsed()));
873872
auto itor = find<XY_COPY_BLT *>(cmdList.begin(), cmdList.end());
874873
EXPECT_NE(cmdList.end(), itor);
875-
itor = find<MI_ARB_CHECK *>(cmdList.begin(), cmdList.end());
876-
EXPECT_NE(cmdList.end(), itor);
877874
itor++;
875+
itor = find<XY_COPY_BLT *>(itor, cmdList.end());
878876
EXPECT_EQ(cmdList.end(), itor);
879877
}
880878

@@ -1094,10 +1092,15 @@ HWTEST_F(CommandListCreate, GivenCommandListWhenUnalignedPtrThenLeftMiddleAndRig
10941092

10951093
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
10961094
cmdList, ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0), commandList->commandContainer.getCommandStream()->getUsed()));
1095+
10971096
auto itor = find<XY_COPY_BLT *>(cmdList.begin(), cmdList.end());
1098-
for (uint32_t i = 0; i < 3u; i++, itor++) {
1099-
EXPECT_NE(itor++, cmdList.end());
1100-
}
1097+
EXPECT_NE(cmdList.end(), itor);
1098+
1099+
itor = find<XY_COPY_BLT *>(++itor, cmdList.end());
1100+
EXPECT_NE(cmdList.end(), itor);
1101+
1102+
itor = find<XY_COPY_BLT *>(++itor, cmdList.end());
1103+
EXPECT_NE(cmdList.end(), itor);
11011104
}
11021105
} // namespace ult
11031106
} // namespace L0

opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenEstimatingCommandsSizeThenCal
612612
const uint32_t numberOfBlitOperations = 4;
613613

614614
auto baseSize = EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite() + sizeof(typename FamilyType::MI_BATCH_BUFFER_END);
615-
constexpr size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK);
615+
constexpr size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT);
616616
auto expectedBlitInstructionsSize = cmdsSizePerBlit * numberOfBlts;
617617

618618
auto expectedAlignedSize = baseSize + MemorySynchronizationCommands<FamilyType>::getSizeForAdditonalSynchronization(pDevice->getHardwareInfo());
@@ -641,7 +641,7 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenDirectsubmissionEnabledEstima
641641
const uint32_t numberOfBlitOperations = 4;
642642

643643
auto baseSize = EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite() + sizeof(typename FamilyType::MI_BATCH_BUFFER_START);
644-
constexpr size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK);
644+
constexpr size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT);
645645
auto expectedBlitInstructionsSize = cmdsSizePerBlit * numberOfBlts;
646646

647647
auto expectedAlignedSize = baseSize + MemorySynchronizationCommands<FamilyType>::getSizeForAdditonalSynchronization(pDevice->getHardwareInfo());
@@ -668,7 +668,7 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenEstimatingCommandsSizeForWrit
668668
const Vec3<size_t> bltSize = {(3 * max2DBlitSize), 4, 2};
669669
const size_t numberOfBlts = 3 * bltSize.y * bltSize.z;
670670
const size_t numberOfBlitOperations = 4 * bltSize.y * bltSize.z;
671-
const size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK);
671+
const size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT);
672672

673673
auto baseSize = EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite() + sizeof(typename FamilyType::MI_BATCH_BUFFER_END);
674674
auto expectedBlitInstructionsSize = cmdsSizePerBlit * numberOfBlts;
@@ -697,7 +697,7 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenDirectSubmissionEnabledEstima
697697
const Vec3<size_t> bltSize = {(3 * max2DBlitSize), 4, 2};
698698
const size_t numberOfBlts = 3 * bltSize.y * bltSize.z;
699699
const size_t numberOfBlitOperations = 4 * bltSize.y * bltSize.z;
700-
const size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK);
700+
const size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT);
701701

702702
auto baseSize = EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite() + sizeof(typename FamilyType::MI_BATCH_BUFFER_START);
703703
auto expectedBlitInstructionsSize = cmdsSizePerBlit * numberOfBlts;
@@ -722,7 +722,7 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenDirectSubmissionEnabledEstima
722722
}
723723

724724
HWTEST_F(BcsTests, givenTimestampPacketWriteRequestWhenEstimatingSizeForCommandsThenAddMiFlushDw) {
725-
constexpr size_t expectedBaseSize = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK);
725+
constexpr size_t expectedBaseSize = sizeof(typename FamilyType::XY_COPY_BLT);
726726

727727
auto expectedSizeWithTimestampPacketWrite = expectedBaseSize + EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite();
728728
auto expectedSizeWithoutTimestampPacketWrite = expectedBaseSize;
@@ -737,7 +737,7 @@ HWTEST_F(BcsTests, givenTimestampPacketWriteRequestWhenEstimatingSizeForCommands
737737
}
738738

739739
HWTEST_F(BcsTests, givenTimestampPacketWriteRequestWhenEstimatingSizeForCommandsWithProfilingThenAddMiFlushDw) {
740-
size_t expectedBaseSize = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK) + EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite();
740+
size_t expectedBaseSize = sizeof(typename FamilyType::XY_COPY_BLT) + EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite();
741741

742742
auto expectedSizeWithTimestampPacketWriteAndProfiling = expectedBaseSize + 4 * sizeof(typename FamilyType::MI_STORE_REGISTER_MEM);
743743

@@ -760,7 +760,7 @@ HWTEST_F(BcsTests, givenBltSizeAndCsrDependenciesWhenEstimatingCommandSizeThenAd
760760
csrDependencies.push_back(&timestamp0);
761761
csrDependencies.push_back(&timestamp1);
762762

763-
constexpr size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK);
763+
constexpr size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT);
764764
size_t expectedSize = (cmdsSizePerBlit * numberOfBlts) +
765765
TimestampPacketHelper::getRequiredCmdStreamSize<FamilyType>(csrDependencies);
766766

@@ -822,10 +822,6 @@ HWTEST_F(BcsTests, givenBltSizeWithLeftoverWhenDispatchedThenProgramAllRequiredC
822822
EXPECT_EQ(expectedHeight, bltCmd->getTransferHeight());
823823
EXPECT_EQ(expectedWidth, bltCmd->getDestinationPitch());
824824
EXPECT_EQ(expectedWidth, bltCmd->getSourcePitch());
825-
826-
auto miArbCheckCmd = genCmdCast<typename FamilyType::MI_ARB_CHECK *>(*(cmdIterator++));
827-
EXPECT_NE(nullptr, miArbCheckCmd);
828-
EXPECT_TRUE(memcmp(&FamilyType::cmdInitArbCheck, miArbCheckCmd, sizeof(typename FamilyType::MI_ARB_CHECK)) == 0);
829825
}
830826

831827
if (UnitTestHelper<FamilyType>::isAdditionalSynchronizationRequired(pDevice->getHardwareInfo())) {
@@ -1045,10 +1041,6 @@ HWTEST_P(BcsDetaliedTestsWithParams, givenBltSizeWithLeftoverWhenDispatchedThenP
10451041
EXPECT_EQ(srcAddr, expectedSrcAddr);
10461042

10471043
offset += (expectedWidth * expectedHeight);
1048-
1049-
auto miArbCheckCmd = genCmdCast<typename FamilyType::MI_ARB_CHECK *>(*(cmdIterator++));
1050-
EXPECT_NE(nullptr, miArbCheckCmd);
1051-
EXPECT_TRUE(memcmp(&FamilyType::cmdInitArbCheck, miArbCheckCmd, sizeof(typename FamilyType::MI_ARB_CHECK)) == 0);
10521044
}
10531045
}
10541046

@@ -1128,10 +1120,6 @@ HWTEST_P(BcsDetaliedTestsWithParams, givenBltSizeWithLeftoverWhenDispatchedThenP
11281120
EXPECT_EQ(srcAddr, bltCmd->getSourceBaseAddress());
11291121

11301122
offset += (expectedWidth * expectedHeight);
1131-
1132-
auto miArbCheckCmd = genCmdCast<typename FamilyType::MI_ARB_CHECK *>(*(cmdIterator++));
1133-
EXPECT_NE(nullptr, miArbCheckCmd);
1134-
EXPECT_TRUE(memcmp(&FamilyType::cmdInitArbCheck, miArbCheckCmd, sizeof(typename FamilyType::MI_ARB_CHECK)) == 0);
11351123
}
11361124
}
11371125

@@ -1206,10 +1194,6 @@ HWTEST_P(BcsDetaliedTestsWithParams, givenBltSizeWithLeftoverWhenDispatchedThenP
12061194
EXPECT_EQ(srcAddr, bltCmd->getSourceBaseAddress());
12071195

12081196
offset += (expectedWidth * expectedHeight);
1209-
1210-
auto miArbCheckCmd = genCmdCast<typename FamilyType::MI_ARB_CHECK *>(*(cmdIterator++));
1211-
EXPECT_NE(nullptr, miArbCheckCmd);
1212-
EXPECT_TRUE(memcmp(&FamilyType::cmdInitArbCheck, miArbCheckCmd, sizeof(typename FamilyType::MI_ARB_CHECK)) == 0);
12131197
}
12141198
}
12151199

opencl/test/unit_test/command_stream/command_stream_receiver_hw_2_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ using namespace NEO;
3131

3232
HWTEST_F(BcsTests, givenBltSizeWhenEstimatingCommandSizeThenAddAllRequiredCommands) {
3333
constexpr auto max2DBlitSize = BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight;
34-
constexpr auto cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK);
34+
constexpr auto cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT);
3535
size_t notAlignedBltSize = (3 * max2DBlitSize) + 1;
3636
size_t alignedBltSize = (3 * max2DBlitSize);
3737
uint32_t alignedNumberOfBlts = 3;
@@ -55,7 +55,7 @@ HWTEST_F(BcsTests, givenBltSizeWhenEstimatingCommandSizeThenAddAllRequiredComman
5555

5656
HWTEST_F(BcsTests, givenDebugCapabilityWhenEstimatingCommandSizeThenAddAllRequiredCommands) {
5757
constexpr auto max2DBlitSize = BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight;
58-
constexpr auto cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK);
58+
constexpr auto cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT);
5959
const size_t debugCommandsSize = (EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite() + EncodeSempahore<FamilyType>::getSizeMiSemaphoreWait()) * 2;
6060

6161
constexpr uint32_t numberOfBlts = 3;
@@ -79,7 +79,7 @@ HWTEST_F(BcsTests, givenDebugCapabilityWhenEstimatingCommandSizeThenAddAllRequir
7979

8080
HWTEST_F(BcsTests, givenBltSizeWhenEstimatingCommandSizeForReadBufferRectThenAddAllRequiredCommands) {
8181
constexpr auto max2DBlitSize = BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight;
82-
constexpr auto cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK);
82+
constexpr auto cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT);
8383
Vec3<size_t> notAlignedBltSize = {(3 * max2DBlitSize) + 1, 4, 2};
8484
Vec3<size_t> alignedBltSize = {(3 * max2DBlitSize), 4, 2};
8585
size_t alignedNumberOfBlts = 3 * alignedBltSize.y * alignedBltSize.z;
@@ -104,7 +104,7 @@ HWTEST_F(BcsTests, givenBltWithBigCopySizeWhenEstimatingCommandSizeForReadBuffer
104104
auto maxWidthToCopy = static_cast<size_t>(BlitCommandsHelper<FamilyType>::getMaxBlitWidth(rootDeviceEnvironment));
105105
auto maxHeightToCopy = static_cast<size_t>(BlitCommandsHelper<FamilyType>::getMaxBlitHeight(rootDeviceEnvironment));
106106

107-
constexpr auto cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK);
107+
constexpr auto cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT);
108108
Vec3<size_t> alignedBltSize = {(3 * maxWidthToCopy), (4 * maxHeightToCopy), 2};
109109
Vec3<size_t> notAlignedBltSize = {(3 * maxWidthToCopy + 1), (4 * maxHeightToCopy), 2};
110110

shared/source/helpers/blit_commands_helper_base.inl

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,23 @@ uint64_t BlitCommandsHelper<GfxFamily>::getMaxBlitHeight(const RootDeviceEnviron
4242

4343
template <typename GfxFamily>
4444
void BlitCommandsHelper<GfxFamily>::dispatchPostBlitCommand(LinearStream &linearStream) {
45-
switch (DebugManager.flags.PostBlitCommand.get()) {
46-
case 1:
47-
EncodeMiFlushDW<GfxFamily>::programMiFlushDw(linearStream, 0, 0, false, false);
48-
break;
49-
case 2:
50-
break;
51-
default: {
45+
if (DebugManager.flags.PostBlitCommand.get() == 0) {
5246
auto miArbCheckStream = linearStream.getSpaceForCmd<typename GfxFamily::MI_ARB_CHECK>();
5347
*miArbCheckStream = GfxFamily::cmdInitArbCheck;
54-
break;
55-
}
48+
} else if (DebugManager.flags.PostBlitCommand.get() == 1) {
49+
EncodeMiFlushDW<GfxFamily>::programMiFlushDw(linearStream, 0, 0, false, false);
5650
}
5751
}
5852

5953
template <typename GfxFamily>
6054
size_t BlitCommandsHelper<GfxFamily>::estimatePostBlitCommandSize() {
61-
switch (DebugManager.flags.PostBlitCommand.get()) {
62-
case 1:
63-
return sizeof(typename GfxFamily::MI_FLUSH_DW);
64-
case 2:
65-
return 0;
66-
default:
55+
if (DebugManager.flags.PostBlitCommand.get() == 0) {
6756
return sizeof(typename GfxFamily::MI_ARB_CHECK);
57+
} else if (DebugManager.flags.PostBlitCommand.get() == 1) {
58+
return sizeof(typename GfxFamily::MI_FLUSH_DW);
6859
}
60+
61+
return 0;
6962
}
7063

7164
template <typename GfxFamily>

shared/test/unit_test/helpers/blit_commands_helper_tests.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ HWTEST_F(BlitTests, givenDebugVariableWhenEstimatingPostBlitsCommandSizeThenRetu
9696

9797
DebugManagerStateRestore restore{};
9898

99-
EXPECT_EQ(arbCheckSize, BlitCommandsHelper<FamilyType>::estimatePostBlitCommandSize());
99+
EXPECT_EQ(0u, BlitCommandsHelper<FamilyType>::estimatePostBlitCommandSize());
100+
100101
DebugManager.flags.PostBlitCommand.set(0);
101102
EXPECT_EQ(arbCheckSize, BlitCommandsHelper<FamilyType>::estimatePostBlitCommandSize());
102103

@@ -117,9 +118,7 @@ HWTEST_F(BlitTests, givenDebugVariableWhenDispatchingPostBlitsCommandThenUseCorr
117118

118119
// -1: default
119120
BlitCommandsHelper<FamilyType>::dispatchPostBlitCommand(linearStream);
120-
CmdParse<FamilyType>::parseCommandBuffer(commands, linearStream.getCpuBase(), linearStream.getUsed());
121-
auto arbCheck = find<MI_ARB_CHECK *>(commands.begin(), commands.end());
122-
EXPECT_NE(commands.end(), arbCheck);
121+
EXPECT_EQ(0u, linearStream.getUsed());
123122

124123
// 0: MI_ARB_CHECK
125124
memset(streamBuffer, 0, sizeof(streamBuffer));
@@ -128,7 +127,7 @@ HWTEST_F(BlitTests, givenDebugVariableWhenDispatchingPostBlitsCommandThenUseCorr
128127
DebugManager.flags.PostBlitCommand.set(0);
129128
BlitCommandsHelper<FamilyType>::dispatchPostBlitCommand(linearStream);
130129
CmdParse<FamilyType>::parseCommandBuffer(commands, linearStream.getCpuBase(), linearStream.getUsed());
131-
arbCheck = find<MI_ARB_CHECK *>(commands.begin(), commands.end());
130+
auto arbCheck = find<MI_ARB_CHECK *>(commands.begin(), commands.end());
132131
EXPECT_NE(commands.end(), arbCheck);
133132

134133
// 1: MI_FLUSH_DW

0 commit comments

Comments
 (0)