Skip to content

Commit b6e3817

Browse files
Dont program dcFlush when not allowed
Signed-off-by: Bartosz Dunajski <[email protected]>
1 parent 9dc2581 commit b6e3817

15 files changed

+78
-45
lines changed

level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "shared/source/command_stream/linear_stream.h"
1313
#include "shared/source/device/device.h"
1414
#include "shared/source/helpers/api_specific_config.h"
15+
#include "shared/source/helpers/hw_helper.h"
1516
#include "shared/source/helpers/hw_info.h"
1617
#include "shared/source/helpers/interlocked_max.h"
1718
#include "shared/source/helpers/preamble.h"
@@ -32,16 +33,12 @@ template <GFXCORE_FAMILY gfxCoreFamily>
3233
void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool useLocalMemoryForIndirectHeap, NEO::LinearStream &commandStream) {
3334
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
3435
using STATE_BASE_ADDRESS = typename GfxFamily::STATE_BASE_ADDRESS;
35-
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;
36-
37-
PIPE_CONTROL *pcCmd = commandStream.getSpaceForCmd<PIPE_CONTROL>();
38-
PIPE_CONTROL cmd = GfxFamily::cmdInitPipeControl;
3936

40-
cmd.setTextureCacheInvalidationEnable(true);
41-
cmd.setDcFlushEnable(true);
42-
cmd.setCommandStreamerStallEnable(true);
37+
NEO::PipeControlArgs pcArgs;
38+
pcArgs.dcFlushEnable = true;
39+
pcArgs.textureCacheInvalidationEnable = true;
4340

44-
*pcCmd = cmd;
41+
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControl(commandStream, pcArgs);
4542

4643
NEO::Device *neoDevice = device->getNEODevice();
4744
auto &hwInfo = neoDevice->getHardwareInfo();

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ HWTEST2_F(AppendMemoryCopy, givenCommandListAndHostPointersWhenMemoryCopyRegionC
403403
cmd = genCmdCast<PIPE_CONTROL *>(*itor);
404404
itor = find<PIPE_CONTROL *>(++itor, genCmdList.end());
405405
}
406-
EXPECT_TRUE(cmd->getDcFlushEnable());
406+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), cmd->getDcFlushEnable());
407407
}
408408

409409
HWTEST2_F(AppendMemoryCopy, givenCommandListAndHostPointersWhenMemoryCopyCalledThenPipeControlWithDcFlushAdded, Platforms) {
@@ -426,7 +426,7 @@ HWTEST2_F(AppendMemoryCopy, givenCommandListAndHostPointersWhenMemoryCopyCalledT
426426
cmd = genCmdCast<PIPE_CONTROL *>(*itor);
427427
itor = find<PIPE_CONTROL *>(++itor, genCmdList.end());
428428
}
429-
EXPECT_TRUE(cmd->getDcFlushEnable());
429+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), cmd->getDcFlushEnable());
430430
}
431431

432432
HWTEST2_F(CommandListCreate, givenCommandListAnd2DWhbufferenMemoryCopyRegionCalledThenCopyKernel2DCalled, Platforms) {
@@ -596,7 +596,7 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenMemoryCopyWithSignalEventScopeS
596596

597597
auto it = *(iterator.end() - 1);
598598
auto cmd1 = genCmdCast<PIPE_CONTROL *>(*it);
599-
EXPECT_TRUE(cmd1->getDcFlushEnable());
599+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), cmd1->getDcFlushEnable());
600600
}
601601

602602
using ImageSupport = IsWithinProducts<IGFX_SKYLAKE, IGFX_TIGERLAKE_LP>;
@@ -1234,7 +1234,7 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenTimestampPassedToMemoryCopyThen
12341234
EXPECT_NE(cmdList.end(), itor);
12351235
{
12361236
auto cmd = genCmdCast<PIPE_CONTROL *>(*itor);
1237-
EXPECT_TRUE(cmd->getDcFlushEnable());
1237+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), cmd->getDcFlushEnable());
12381238
}
12391239
}
12401240
} // namespace ult

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ HWTEST2_F(CommandListAppendEventReset, givenEventWithHostScopeUsedInResetThenPip
196196
EXPECT_TRUE(cmd->getCommandStreamerStallEnable());
197197
EXPECT_EQ(cmd->getAddressHigh(), gpuAddress >> 32u);
198198
EXPECT_EQ(cmd->getAddress(), uint32_t(gpuAddress));
199-
EXPECT_TRUE(cmd->getDcFlushEnable());
199+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), cmd->getDcFlushEnable());
200200
postSyncFound = true;
201201
}
202202
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ HWTEST_F(CommandListAppendSignalEvent, givenEventWithScopeFlagDeviceWhenAppendin
132132
if (cmd->getPostSyncOperation() == POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA) {
133133
EXPECT_EQ(cmd->getImmediateData(), Event::STATE_SIGNALED);
134134
EXPECT_TRUE(cmd->getCommandStreamerStallEnable());
135-
EXPECT_TRUE(cmd->getDcFlushEnable());
135+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), cmd->getDcFlushEnable());
136136
postSyncFound = true;
137137
}
138138
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ HWTEST_F(CommandListAppendWaitOnEvent, givenEventWithWaitScopeFlagDeviceWhenAppe
132132
ASSERT_NE(cmd, nullptr);
133133

134134
EXPECT_TRUE(cmd->getCommandStreamerStallEnable());
135-
EXPECT_TRUE(cmd->getDcFlushEnable());
135+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), cmd->getDcFlushEnable());
136136
}
137137
}
138138

@@ -188,4 +188,4 @@ HWTEST2_F(CommandListAppendWaitOnEvent, givenCommandListWhenAppendWriteGlobalTim
188188
}
189189

190190
} // namespace ult
191-
} // namespace L0
191+
} // namespace L0

opencl/test/unit_test/command_queue/dispatch_walker_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ HWTEST_P(DispatchWalkerTestForAuxTranslation, givenKernelWhenAuxToNonAuxWhenTran
13691369
ASSERT_EQ(2u, pipeControls.size());
13701370

13711371
auto beginPipeControl = genCmdCast<typename FamilyType::PIPE_CONTROL *>(*(pipeControls[0]));
1372-
EXPECT_TRUE(beginPipeControl->getDcFlushEnable());
1372+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), beginPipeControl->getDcFlushEnable());
13731373
EXPECT_TRUE(beginPipeControl->getCommandStreamerStallEnable());
13741374

13751375
auto endPipeControl = genCmdCast<typename FamilyType::PIPE_CONTROL *>(*(pipeControls[1]));
@@ -1425,7 +1425,7 @@ HWTEST_P(DispatchWalkerTestForAuxTranslation, givenKernelWhenNonAuxToAuxWhenTran
14251425
bool dcFlushRequired = (pClDevice->getHardwareInfo().platform.eRenderCoreFamily == IGFX_GEN8_CORE);
14261426

14271427
auto beginPipeControl = genCmdCast<typename FamilyType::PIPE_CONTROL *>(*(pipeControls[0]));
1428-
EXPECT_TRUE(beginPipeControl->getDcFlushEnable());
1428+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), beginPipeControl->getDcFlushEnable());
14291429
EXPECT_TRUE(beginPipeControl->getCommandStreamerStallEnable());
14301430

14311431
auto endPipeControl = genCmdCast<typename FamilyType::PIPE_CONTROL *>(*(pipeControls[1]));

opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,16 +1415,19 @@ struct PauseOnGpuTests : public EnqueueKernelTest {
14151415
return false;
14161416
}
14171417

1418-
template <typename PIPE_CONTROL>
1418+
template <typename FamilyType>
14191419
bool verifyPipeControl(const GenCmdList::iterator &iterator, uint64_t debugPauseStateAddress, DebugPauseState requiredDebugPauseState) {
1420+
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
1421+
14201422
auto pipeControlCmd = genCmdCast<PIPE_CONTROL *>(*iterator);
14211423

14221424
if ((static_cast<uint32_t>(requiredDebugPauseState) == pipeControlCmd->getImmediateData()) &&
14231425
(static_cast<uint32_t>(debugPauseStateAddress & 0x0000FFFFFFFFULL) == pipeControlCmd->getAddress()) &&
14241426
(static_cast<uint32_t>(debugPauseStateAddress >> 32) == pipeControlCmd->getAddressHigh())) {
14251427

14261428
EXPECT_TRUE(pipeControlCmd->getCommandStreamerStallEnable());
1427-
EXPECT_TRUE(pipeControlCmd->getDcFlushEnable());
1429+
1430+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), pipeControlCmd->getDcFlushEnable());
14281431

14291432
EXPECT_EQ(PIPE_CONTROL::POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA, pipeControlCmd->getPostSyncOperation());
14301433

@@ -1466,16 +1469,17 @@ struct PauseOnGpuTests : public EnqueueKernelTest {
14661469
}
14671470
}
14681471

1469-
template <typename PIPE_CONTROL>
1472+
template <typename FamilyType>
14701473
void findPipeControls(GenCmdList &cmdList) {
1474+
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
14711475
auto pipeControl = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
14721476

14731477
while (pipeControl != cmdList.end()) {
1474-
if (verifyPipeControl<PIPE_CONTROL>(pipeControl, debugPauseStateAddress, DebugPauseState::waitingForUserStartConfirmation)) {
1478+
if (verifyPipeControl<FamilyType>(pipeControl, debugPauseStateAddress, DebugPauseState::waitingForUserStartConfirmation)) {
14751479
pipeControlBeforeWalkerFound++;
14761480
}
14771481

1478-
if (verifyPipeControl<PIPE_CONTROL>(pipeControl, debugPauseStateAddress, DebugPauseState::waitingForUserEndConfirmation)) {
1482+
if (verifyPipeControl<FamilyType>(pipeControl, debugPauseStateAddress, DebugPauseState::waitingForUserEndConfirmation)) {
14791483
pipeControlAfterWalkerFound++;
14801484
}
14811485

@@ -1530,7 +1534,7 @@ HWTEST_F(PauseOnGpuTests, givenPauseOnEnqueueFlagSetWhenDispatchWalkersThenInser
15301534
EXPECT_EQ(1u, semaphoreBeforeWalkerFound);
15311535
EXPECT_EQ(1u, semaphoreAfterWalkerFound);
15321536

1533-
findPipeControls<PIPE_CONTROL>(hwParser.cmdList);
1537+
findPipeControls<FamilyType>(hwParser.cmdList);
15341538

15351539
EXPECT_EQ(1u, pipeControlBeforeWalkerFound);
15361540
EXPECT_EQ(1u, pipeControlAfterWalkerFound);
@@ -1552,7 +1556,7 @@ HWTEST_F(PauseOnGpuTests, givenPauseOnEnqueueFlagSetToMinusTwoWhenDispatchWalker
15521556

15531557
findSemaphores<MI_SEMAPHORE_WAIT>(hwParser.cmdList);
15541558

1555-
findPipeControls<PIPE_CONTROL>(hwParser.cmdList);
1559+
findPipeControls<FamilyType>(hwParser.cmdList);
15561560

15571561
EXPECT_EQ(2u, semaphoreBeforeWalkerFound);
15581562
EXPECT_EQ(2u, semaphoreAfterWalkerFound);
@@ -1576,7 +1580,7 @@ HWTEST_F(PauseOnGpuTests, givenPauseModeSetToBeforeOnlyWhenDispatchingThenInsert
15761580

15771581
findSemaphores<MI_SEMAPHORE_WAIT>(hwParser.cmdList);
15781582

1579-
findPipeControls<PIPE_CONTROL>(hwParser.cmdList);
1583+
findPipeControls<FamilyType>(hwParser.cmdList);
15801584

15811585
EXPECT_EQ(1u, semaphoreBeforeWalkerFound);
15821586
EXPECT_EQ(0u, semaphoreAfterWalkerFound);
@@ -1600,7 +1604,7 @@ HWTEST_F(PauseOnGpuTests, givenPauseModeSetToAfterOnlyWhenDispatchingThenInsertP
16001604

16011605
findSemaphores<MI_SEMAPHORE_WAIT>(hwParser.cmdList);
16021606

1603-
findPipeControls<PIPE_CONTROL>(hwParser.cmdList);
1607+
findPipeControls<FamilyType>(hwParser.cmdList);
16041608

16051609
EXPECT_EQ(0u, semaphoreBeforeWalkerFound);
16061610
EXPECT_EQ(1u, semaphoreAfterWalkerFound);
@@ -1624,7 +1628,7 @@ HWTEST_F(PauseOnGpuTests, givenPauseModeSetToBeforeAndAfterWhenDispatchingThenIn
16241628

16251629
findSemaphores<MI_SEMAPHORE_WAIT>(hwParser.cmdList);
16261630

1627-
findPipeControls<PIPE_CONTROL>(hwParser.cmdList);
1631+
findPipeControls<FamilyType>(hwParser.cmdList);
16281632

16291633
EXPECT_EQ(1u, semaphoreBeforeWalkerFound);
16301634
EXPECT_EQ(1u, semaphoreAfterWalkerFound);
@@ -1649,7 +1653,7 @@ HWTEST_F(PauseOnGpuTests, givenPauseOnEnqueueFlagSetWhenDispatchWalkersThenDontI
16491653

16501654
findSemaphores<MI_SEMAPHORE_WAIT>(hwParser.cmdList);
16511655

1652-
findPipeControls<PIPE_CONTROL>(hwParser.cmdList);
1656+
findPipeControls<FamilyType>(hwParser.cmdList);
16531657

16541658
EXPECT_EQ(0u, semaphoreBeforeWalkerFound);
16551659
EXPECT_EQ(0u, semaphoreAfterWalkerFound);

opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenStateBaseAddressWhenItIsRequi
545545
EXPECT_NE(stateBaseAddressItor, pipeControlItor);
546546
auto pipeControlCmd = (typename FamilyType::PIPE_CONTROL *)*pipeControlItor;
547547
EXPECT_TRUE(pipeControlCmd->getTextureCacheInvalidationEnable());
548-
EXPECT_TRUE(pipeControlCmd->getDcFlushEnable());
548+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), pipeControlCmd->getDcFlushEnable());
549549
}
550550

551551
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenNotApplicableL3ConfigWhenFlushingTaskThenDontReloadSba) {
@@ -1185,11 +1185,11 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, GivenBlockingWh
11851185

11861186
// Verify that the dcFlushEnabled bit is not set in PC
11871187
auto pCmd = reinterpret_cast<PIPE_CONTROL *>(pipeControlTask);
1188-
EXPECT_TRUE(pCmd->getDcFlushEnable());
1188+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), pCmd->getDcFlushEnable());
11891189
}
11901190
} else {
11911191
auto pCmd = reinterpret_cast<PIPE_CONTROL *>(*itorPC);
1192-
EXPECT_TRUE(pCmd->getDcFlushEnable());
1192+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), pCmd->getDcFlushEnable());
11931193
}
11941194
}
11951195

@@ -1233,7 +1233,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenBlockedKernelRequiringDCFlush
12331233

12341234
// Verify that the dcFlushEnabled bit is set in PC
12351235
auto pCmdWA = reinterpret_cast<PIPE_CONTROL *>(*itorPC);
1236-
EXPECT_TRUE(pCmdWA->getDcFlushEnable());
1236+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), pCmdWA->getDcFlushEnable());
12371237

12381238
buffer->release();
12391239
}

opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenBlockedKernelNotRequiringDCFl
7474

7575
// Verify that the dcFlushEnabled bit is set in PC
7676
auto pCmdWA = reinterpret_cast<PIPE_CONTROL *>(*itorPC);
77-
EXPECT_TRUE(pCmdWA->getDcFlushEnable());
77+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), pCmdWA->getDcFlushEnable());
7878

7979
buffer->release();
8080
}
@@ -347,10 +347,10 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests,
347347
EXPECT_NE(cmdList.end(), itorCmdP);
348348
auto itorCmd2 = find<PIPE_CONTROL *>(itorCmdP, cmdList.end());
349349
cmdPC = (PIPE_CONTROL *)*itorCmd2;
350-
EXPECT_TRUE(cmdPC->getDcFlushEnable());
350+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), cmdPC->getDcFlushEnable());
351351
} else {
352352
// single PIPE_CONTROL following GPGPU_WALKER has DcFlush and Write HwTag
353-
EXPECT_TRUE(cmdPC->getDcFlushEnable());
353+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), cmdPC->getDcFlushEnable());
354354
}
355355

356356
retVal = clReleaseEvent(event);

opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenCommandA
952952
auto pipeControl = genCmdCast<typename FamilyType::PIPE_CONTROL *>(*itorPipeControl);
953953

954954
mockCsr->flushBatchedSubmissions();
955-
EXPECT_TRUE(pipeControl->getDcFlushEnable());
955+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), pipeControl->getDcFlushEnable());
956956
}
957957

958958
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWithOutOfOrderModeFisabledWhenCommandAreSubmittedThenDcFlushIsAdded) {
@@ -984,7 +984,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWithOutOfOrd
984984
auto pipeControl = genCmdCast<typename FamilyType::PIPE_CONTROL *>(*itorPipeControl);
985985

986986
mockCsr->flushBatchedSubmissions();
987-
EXPECT_TRUE(pipeControl->getDcFlushEnable());
987+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), pipeControl->getDcFlushEnable());
988988
}
989989

990990
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenUpdateTaskCountFromWaitSetWhenFlushTaskThenThereIsNoPipeControlForUpdateTaskCount) {
@@ -1136,7 +1136,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenEpiloguePipeControlThenDcFlus
11361136
auto pipeControl = genCmdCast<PIPE_CONTROL *>(cmdBuffer->epiloguePipeControlLocation);
11371137
ASSERT_NE(nullptr, pipeControl);
11381138
mockCsr->flushBatchedSubmissions();
1139-
EXPECT_TRUE(pipeControl->getDcFlushEnable());
1139+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), pipeControl->getDcFlushEnable());
11401140
}
11411141

11421142
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenEpiloguePipeControlWhendDcFlushDisabledByDebugFlagThenDcFlushIsDisabled) {
@@ -1742,7 +1742,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenDcFlushArgumentIsTrueWhenCall
17421742
PIPE_CONTROL *pipeControl = genCmdCast<PIPE_CONTROL *>(buffer.get());
17431743
ASSERT_NE(nullptr, pipeControl);
17441744

1745-
EXPECT_TRUE(pipeControl->getDcFlushEnable());
1745+
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::isDcFlushAllowed(), pipeControl->getDcFlushEnable());
17461746
EXPECT_TRUE(pipeControl->getCommandStreamerStallEnable());
17471747
}
17481748

0 commit comments

Comments
 (0)