performance: Skip already completed events

Resolves: NEO-7587

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2023-05-31 14:07:59 +00:00
committed by Compute-Runtime-Automation
parent 115d6de350
commit b43847e1f8
2 changed files with 39 additions and 0 deletions

View File

@@ -2172,6 +2172,10 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendWaitOnEvents(uint32_t nu
for (uint32_t i = 0; i < numEvents; i++) {
auto event = Event::fromHandle(phEvent[i]);
if (this->cmdListType == TYPE_IMMEDIATE && event->isAlreadyCompleted()) {
continue;
}
commandContainer.addToResidencyContainer(&event->getAllocation(this->device));
gpuAddr = event->getCompletionFieldGpuAddress(this->device);
uint32_t packetsToWait = event->getPacketsInUse();

View File

@@ -818,6 +818,41 @@ HWTEST_F(CommandListCreate, givenFlushTaskFlagEnabledAndAsyncCmdQueueAndCopyOnly
EXPECT_GT(commandContainer.getCommandStream()->getUsed(), used);
}
HWTEST2_F(CommandListCreate, givenImmediateCommandListAndAlreadyCompletedEventWhenAddEventsToCmdListThenProgramSemaphoresOnlyForIncompletedEvents, IsAtLeastSkl) {
DebugManagerStateRestore restorer;
NEO::DebugManager.flags.SignalAllEventPackets.set(0);
using SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
ze_command_queue_desc_t desc = {};
desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
ze_result_t returnValue;
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::Copy, returnValue));
ASSERT_NE(nullptr, commandList);
auto whiteBoxCmdList = static_cast<CommandList *>(commandList.get());
EXPECT_EQ(device, commandList->getDevice());
EXPECT_EQ(1u, commandList->getCmdListType());
EXPECT_NE(nullptr, whiteBoxCmdList->cmdQImmediate);
auto &commandContainer = commandList->getCmdContainer();
MockEvent event, event2;
event.signalScope = 0;
event.waitScope = ZE_EVENT_SCOPE_FLAG_HOST;
event2.waitScope = 0;
ze_event_handle_t events[] = {&event, &event2};
event.isCompleted = Event::State::STATE_SIGNALED;
static_cast<CommandListCoreFamily<gfxCoreFamily> *>(commandList.get())->addEventsToCmdList(2, events, false, false);
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 = find<SEMAPHORE_WAIT *>(itor, cmdList.end());
EXPECT_EQ(cmdList.end(), itor);
}
struct CmdContainerMock : public CommandContainer {
using CommandContainer::secondaryCommandStreamForImmediateCmdList;
};