[L0] Optimize cache flush while waiting on events.

- do it only once

Change-Id: I0822b4f2acd9e281132447da65f563a635967905
Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
Michal Mrozek
2020-10-05 12:33:03 +02:00
committed by sys_ocldev
parent 155578568b
commit 5386f8be86
2 changed files with 37 additions and 8 deletions

View File

@@ -1363,6 +1363,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendWaitOnEvents(uint32_t nu
uint64_t gpuAddr = 0;
constexpr uint32_t eventStateClear = static_cast<uint32_t>(-1);
bool dcFlushRequired = false;
for (uint32_t i = 0; i < numEvents; i++) {
auto event = Event::fromHandle(phEvent[i]);
@@ -1377,14 +1378,15 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendWaitOnEvents(uint32_t nu
eventStateClear,
COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD);
bool dcFlushEnable = (!event->waitScope) ? false : true;
if (dcFlushEnable) {
if (isCopyOnly()) {
NEO::EncodeMiFlushDW<GfxFamily>::programMiFlushDw(*commandContainer.getCommandStream(), 0, 0, false, false);
} else {
NEO::PipeControlArgs args(true);
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControl(*commandContainer.getCommandStream(), args);
}
dcFlushRequired |= (!event->waitScope) ? false : true;
}
if (dcFlushRequired) {
if (isCopyOnly()) {
NEO::EncodeMiFlushDW<GfxFamily>::programMiFlushDw(*commandContainer.getCommandStream(), 0, 0, false, false);
} else {
NEO::PipeControlArgs args(true);
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControl(*commandContainer.getCommandStream(), args);
}
}

View File

@@ -843,6 +843,33 @@ HWTEST_F(CommandListCreate, givenCommandListyWhenAppendWaitEventsWithDcFlushTheP
EXPECT_NE(cmdList.end(), itor);
}
HWTEST_F(CommandListCreate, givenCommandListyWhenAppendWaitEventsWithDcFlushThePipeControlIsProgrammedOnlyOnce) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
ze_result_t returnValue;
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, returnValue));
auto &commandContainer = commandList->commandContainer;
MockEvent event, event2;
event.signalScope = 0;
event.waitScope = ZE_EVENT_SCOPE_FLAG_HOST;
event2.waitScope = ZE_EVENT_SCOPE_FLAG_HOST;
ze_event_handle_t events[] = {&event, &event2};
commandList->appendWaitOnEvents(2, events);
GenCmdList cmdList;
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
cmdList, ptrOffset(commandContainer.getCommandStream()->getCpuBase(), 0), commandContainer.getCommandStream()->getUsed()));
auto itor = find<SEMAPHORE_WAIT *>(cmdList.begin(), cmdList.end());
EXPECT_NE(cmdList.end(), itor);
itor++;
auto itor2 = find<PIPE_CONTROL *>(itor, cmdList.end());
EXPECT_NE(cmdList.end(), itor2);
itor2++;
auto itor3 = find<PIPE_CONTROL *>(itor2, cmdList.end());
EXPECT_EQ(cmdList.end(), itor3);
}
using Platforms = IsAtLeastProduct<IGFX_SKYLAKE>;
HWTEST2_F(CommandListCreate, givenCopyCommandListWhenProfilingBeforeCommandForCopyOnlyThenCommandsHaveCorrectEventOffsets, Platforms) {