Use MiStoreDataImm for event signals

Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@intel.com>
This commit is contained in:
Aravind Gopalakrishnan
2021-06-01 01:51:11 +00:00
committed by Compute-Runtime-Automation
parent e1f42c2ae1
commit db82df80e7
3 changed files with 44 additions and 57 deletions

View File

@@ -1450,7 +1450,26 @@ void CommandListCoreFamily<gfxCoreFamily>::appendSignalEventPostWalker(ze_event_
if (event->isEventTimestampFlagSet()) {
appendEventForProfiling(hEvent, false);
} else {
CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent(hEvent);
using POST_SYNC_OPERATION = typename GfxFamily::PIPE_CONTROL::POST_SYNC_OPERATION;
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
auto event = Event::fromHandle(hEvent);
commandContainer.addToResidencyContainer(&event->getAllocation(this->device));
uint64_t baseAddr = event->getGpuAddress(this->device);
if (isCopyOnly()) {
NEO::MiFlushArgs args;
args.commandWithPostSync = true;
NEO::EncodeMiFlushDW<GfxFamily>::programMiFlushDw(*commandContainer.getCommandStream(), baseAddr, Event::STATE_SIGNALED, args);
} else {
NEO::PipeControlArgs args;
args.dcFlushEnable = (!event->signalScope) ? false : true;
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControlAndProgramPostSyncOperation(
*commandContainer.getCommandStream(), POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA,
baseAddr, Event::STATE_SIGNALED,
commandContainer.getDevice()->getHardwareInfo(),
args);
}
}
}
@@ -1560,6 +1579,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent(ze_event_han
using POST_SYNC_OPERATION = typename GfxFamily::PIPE_CONTROL::POST_SYNC_OPERATION;
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
auto event = Event::fromHandle(hEvent);
bool applyScope = false;
commandContainer.addToResidencyContainer(&event->getAllocation(this->device));
uint64_t baseAddr = event->getGpuAddress(this->device);
@@ -1574,12 +1594,23 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent(ze_event_han
NEO::EncodeMiFlushDW<GfxFamily>::programMiFlushDw(*commandContainer.getCommandStream(), ptrOffset(baseAddr, eventSignalOffset), Event::STATE_SIGNALED, args);
} else {
NEO::PipeControlArgs args;
args.dcFlushEnable = (!event->signalScope) ? false : true;
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControlAndProgramPostSyncOperation(
*commandContainer.getCommandStream(), POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA,
ptrOffset(baseAddr, eventSignalOffset), Event::STATE_SIGNALED,
commandContainer.getDevice()->getHardwareInfo(),
args);
applyScope = (!event->signalScope) ? false : true;
args.dcFlushEnable = applyScope;
if (applyScope || event->isEventTimestampFlagSet()) {
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControlAndProgramPostSyncOperation(
*commandContainer.getCommandStream(), POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA,
ptrOffset(baseAddr, eventSignalOffset), Event::STATE_SIGNALED,
commandContainer.getDevice()->getHardwareInfo(),
args);
} else {
using MI_STORE_DATA_IMM = typename GfxFamily::MI_STORE_DATA_IMM;
MI_STORE_DATA_IMM storeDataImmediate = GfxFamily::cmdInitStoreDataImm;
storeDataImmediate.setStoreQword(false);
storeDataImmediate.setDwordLength(MI_STORE_DATA_IMM::DWORD_LENGTH::DWORD_LENGTH_STORE_QWORD);
storeDataImmediate.setDataDword0(Event::STATE_SIGNALED);
auto buffer = commandContainer.getCommandStream()->template getSpaceForCmd<MI_STORE_DATA_IMM>();
*buffer = storeDataImmediate;
}
}
return ZE_RESULT_SUCCESS;
}
@@ -1752,7 +1783,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendWriteGlobalTimestamp(
}
if (hSignalEvent) {
CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent(hSignalEvent);
CommandListCoreFamily<gfxCoreFamily>::appendSignalEventPostWalker(hSignalEvent);
}
auto allocationStruct = getAlignedAllocation(this->device, dstptr, sizeof(uint64_t));

View File

@@ -1515,7 +1515,7 @@ HWTEST_F(CommandListCreate, givenCommandListWithCopyOnlyWhenAppendSignalEventThe
EXPECT_NE(cmdList.end(), itor);
}
HWTEST_F(CommandListCreate, givenCommandListWhenAppendSignalEventThenPipeControlIsProgrammed) {
HWTEST_F(CommandListCreate, givenCommandListWhenAppendSignalEventWithScopeThenPipeControlIsProgrammed) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
ze_result_t returnValue;
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, returnValue));

View File

@@ -20,9 +20,10 @@ namespace L0 {
namespace ult {
using CommandListAppendSignalEvent = Test<CommandListFixture>;
HWTEST_F(CommandListAppendSignalEvent, WhenAppendingSignalEventThenPipeControlIsGenerated) {
HWTEST_F(CommandListAppendSignalEvent, WhenAppendingSignalEventWithoutScopeThenMiStoreImmIsGenerated) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION;
using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM;
auto usedSpaceBefore = commandList->commandContainer.getCommandStream()->getUsed();
auto result = commandList->appendSignalEvent(event->toHandle());
@@ -35,22 +36,8 @@ HWTEST_F(CommandListAppendSignalEvent, WhenAppendingSignalEventThenPipeControlIs
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
cmdList, ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0), usedSpaceAfter));
// Find a PC w/ a WriteImmediateData and CS stall
auto itorPC = findAll<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
ASSERT_NE(0u, itorPC.size());
bool postSyncFound = false;
for (auto it : itorPC) {
auto cmd = genCmdCast<PIPE_CONTROL *>(*it);
if (cmd->getPostSyncOperation() == POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA) {
EXPECT_TRUE(cmd->getCommandStreamerStallEnable());
EXPECT_EQ(cmd->getImmediateData(), Event::STATE_SIGNALED);
auto gpuAddress = event->getGpuAddress(device);
EXPECT_EQ(cmd->getAddressHigh(), gpuAddress >> 32u);
EXPECT_EQ(cmd->getAddress(), uint32_t(gpuAddress));
postSyncFound = true;
}
}
ASSERT_TRUE(postSyncFound);
auto itor = findAll<MI_STORE_DATA_IMM *>(cmdList.begin(), cmdList.end());
ASSERT_NE(0u, itor.size());
}
HWTEST_F(CommandListAppendSignalEvent, givenCmdlistWhenAppendingSignalEventThenEventPoolGraphicsAllocationIsAddedToResidencyContainer) {
@@ -66,37 +53,6 @@ HWTEST_F(CommandListAppendSignalEvent, givenCmdlistWhenAppendingSignalEventThenE
}
}
HWTEST_F(CommandListAppendSignalEvent, givenEventWithScopeFlagNoneWhenAppendingSignalEventThenPipeControlHasNoDcFlush) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION;
auto usedSpaceBefore = commandList->commandContainer.getCommandStream()->getUsed();
auto result = commandList->appendSignalEvent(event->toHandle());
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
auto usedSpaceAfter = commandList->commandContainer.getCommandStream()->getUsed();
ASSERT_GT(usedSpaceAfter, usedSpaceBefore);
GenCmdList cmdList;
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(cmdList,
ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0),
usedSpaceAfter));
auto itorPC = findAll<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
ASSERT_NE(0u, itorPC.size());
bool postSyncFound = false;
for (auto it : itorPC) {
auto cmd = genCmdCast<PIPE_CONTROL *>(*it);
if (cmd->getPostSyncOperation() == POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA) {
EXPECT_EQ(cmd->getImmediateData(), Event::STATE_SIGNALED);
EXPECT_TRUE(cmd->getCommandStreamerStallEnable());
EXPECT_FALSE(cmd->getDcFlushEnable());
postSyncFound = true;
}
}
ASSERT_TRUE(postSyncFound);
}
HWTEST_F(CommandListAppendSignalEvent, givenEventWithScopeFlagDeviceWhenAppendingSignalEventThenPipeControlHasNoDcFlush) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION;