Skip to content

Commit db82df8

Browse files
Use MiStoreDataImm for event signals
Signed-off-by: Aravind Gopalakrishnan <[email protected]>
1 parent e1f42c2 commit db82df8

File tree

3 files changed

+44
-57
lines changed

3 files changed

+44
-57
lines changed

level_zero/core/source/cmdlist/cmdlist_hw.inl

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,26 @@ void CommandListCoreFamily<gfxCoreFamily>::appendSignalEventPostWalker(ze_event_
14501450
if (event->isEventTimestampFlagSet()) {
14511451
appendEventForProfiling(hEvent, false);
14521452
} else {
1453-
CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent(hEvent);
1453+
using POST_SYNC_OPERATION = typename GfxFamily::PIPE_CONTROL::POST_SYNC_OPERATION;
1454+
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
1455+
auto event = Event::fromHandle(hEvent);
1456+
1457+
commandContainer.addToResidencyContainer(&event->getAllocation(this->device));
1458+
uint64_t baseAddr = event->getGpuAddress(this->device);
1459+
1460+
if (isCopyOnly()) {
1461+
NEO::MiFlushArgs args;
1462+
args.commandWithPostSync = true;
1463+
NEO::EncodeMiFlushDW<GfxFamily>::programMiFlushDw(*commandContainer.getCommandStream(), baseAddr, Event::STATE_SIGNALED, args);
1464+
} else {
1465+
NEO::PipeControlArgs args;
1466+
args.dcFlushEnable = (!event->signalScope) ? false : true;
1467+
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControlAndProgramPostSyncOperation(
1468+
*commandContainer.getCommandStream(), POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA,
1469+
baseAddr, Event::STATE_SIGNALED,
1470+
commandContainer.getDevice()->getHardwareInfo(),
1471+
args);
1472+
}
14541473
}
14551474
}
14561475

@@ -1560,6 +1579,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent(ze_event_han
15601579
using POST_SYNC_OPERATION = typename GfxFamily::PIPE_CONTROL::POST_SYNC_OPERATION;
15611580
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
15621581
auto event = Event::fromHandle(hEvent);
1582+
bool applyScope = false;
15631583

15641584
commandContainer.addToResidencyContainer(&event->getAllocation(this->device));
15651585
uint64_t baseAddr = event->getGpuAddress(this->device);
@@ -1574,12 +1594,23 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent(ze_event_han
15741594
NEO::EncodeMiFlushDW<GfxFamily>::programMiFlushDw(*commandContainer.getCommandStream(), ptrOffset(baseAddr, eventSignalOffset), Event::STATE_SIGNALED, args);
15751595
} else {
15761596
NEO::PipeControlArgs args;
1577-
args.dcFlushEnable = (!event->signalScope) ? false : true;
1578-
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControlAndProgramPostSyncOperation(
1579-
*commandContainer.getCommandStream(), POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA,
1580-
ptrOffset(baseAddr, eventSignalOffset), Event::STATE_SIGNALED,
1581-
commandContainer.getDevice()->getHardwareInfo(),
1582-
args);
1597+
applyScope = (!event->signalScope) ? false : true;
1598+
args.dcFlushEnable = applyScope;
1599+
if (applyScope || event->isEventTimestampFlagSet()) {
1600+
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControlAndProgramPostSyncOperation(
1601+
*commandContainer.getCommandStream(), POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA,
1602+
ptrOffset(baseAddr, eventSignalOffset), Event::STATE_SIGNALED,
1603+
commandContainer.getDevice()->getHardwareInfo(),
1604+
args);
1605+
} else {
1606+
using MI_STORE_DATA_IMM = typename GfxFamily::MI_STORE_DATA_IMM;
1607+
MI_STORE_DATA_IMM storeDataImmediate = GfxFamily::cmdInitStoreDataImm;
1608+
storeDataImmediate.setStoreQword(false);
1609+
storeDataImmediate.setDwordLength(MI_STORE_DATA_IMM::DWORD_LENGTH::DWORD_LENGTH_STORE_QWORD);
1610+
storeDataImmediate.setDataDword0(Event::STATE_SIGNALED);
1611+
auto buffer = commandContainer.getCommandStream()->template getSpaceForCmd<MI_STORE_DATA_IMM>();
1612+
*buffer = storeDataImmediate;
1613+
}
15831614
}
15841615
return ZE_RESULT_SUCCESS;
15851616
}
@@ -1752,7 +1783,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendWriteGlobalTimestamp(
17521783
}
17531784

17541785
if (hSignalEvent) {
1755-
CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent(hSignalEvent);
1786+
CommandListCoreFamily<gfxCoreFamily>::appendSignalEventPostWalker(hSignalEvent);
17561787
}
17571788

17581789
auto allocationStruct = getAlignedAllocation(this->device, dstptr, sizeof(uint64_t));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,7 @@ HWTEST_F(CommandListCreate, givenCommandListWithCopyOnlyWhenAppendSignalEventThe
15151515
EXPECT_NE(cmdList.end(), itor);
15161516
}
15171517

1518-
HWTEST_F(CommandListCreate, givenCommandListWhenAppendSignalEventThenPipeControlIsProgrammed) {
1518+
HWTEST_F(CommandListCreate, givenCommandListWhenAppendSignalEventWithScopeThenPipeControlIsProgrammed) {
15191519
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
15201520
ze_result_t returnValue;
15211521
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, returnValue));

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

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ namespace L0 {
2020
namespace ult {
2121

2222
using CommandListAppendSignalEvent = Test<CommandListFixture>;
23-
HWTEST_F(CommandListAppendSignalEvent, WhenAppendingSignalEventThenPipeControlIsGenerated) {
23+
HWTEST_F(CommandListAppendSignalEvent, WhenAppendingSignalEventWithoutScopeThenMiStoreImmIsGenerated) {
2424
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
2525
using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION;
26+
using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM;
2627

2728
auto usedSpaceBefore = commandList->commandContainer.getCommandStream()->getUsed();
2829
auto result = commandList->appendSignalEvent(event->toHandle());
@@ -35,22 +36,8 @@ HWTEST_F(CommandListAppendSignalEvent, WhenAppendingSignalEventThenPipeControlIs
3536
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
3637
cmdList, ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0), usedSpaceAfter));
3738

38-
// Find a PC w/ a WriteImmediateData and CS stall
39-
auto itorPC = findAll<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
40-
ASSERT_NE(0u, itorPC.size());
41-
bool postSyncFound = false;
42-
for (auto it : itorPC) {
43-
auto cmd = genCmdCast<PIPE_CONTROL *>(*it);
44-
if (cmd->getPostSyncOperation() == POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA) {
45-
EXPECT_TRUE(cmd->getCommandStreamerStallEnable());
46-
EXPECT_EQ(cmd->getImmediateData(), Event::STATE_SIGNALED);
47-
auto gpuAddress = event->getGpuAddress(device);
48-
EXPECT_EQ(cmd->getAddressHigh(), gpuAddress >> 32u);
49-
EXPECT_EQ(cmd->getAddress(), uint32_t(gpuAddress));
50-
postSyncFound = true;
51-
}
52-
}
53-
ASSERT_TRUE(postSyncFound);
39+
auto itor = findAll<MI_STORE_DATA_IMM *>(cmdList.begin(), cmdList.end());
40+
ASSERT_NE(0u, itor.size());
5441
}
5542

5643
HWTEST_F(CommandListAppendSignalEvent, givenCmdlistWhenAppendingSignalEventThenEventPoolGraphicsAllocationIsAddedToResidencyContainer) {
@@ -66,37 +53,6 @@ HWTEST_F(CommandListAppendSignalEvent, givenCmdlistWhenAppendingSignalEventThenE
6653
}
6754
}
6855

69-
HWTEST_F(CommandListAppendSignalEvent, givenEventWithScopeFlagNoneWhenAppendingSignalEventThenPipeControlHasNoDcFlush) {
70-
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
71-
using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION;
72-
73-
auto usedSpaceBefore = commandList->commandContainer.getCommandStream()->getUsed();
74-
auto result = commandList->appendSignalEvent(event->toHandle());
75-
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
76-
77-
auto usedSpaceAfter = commandList->commandContainer.getCommandStream()->getUsed();
78-
ASSERT_GT(usedSpaceAfter, usedSpaceBefore);
79-
80-
GenCmdList cmdList;
81-
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(cmdList,
82-
ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0),
83-
usedSpaceAfter));
84-
85-
auto itorPC = findAll<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
86-
ASSERT_NE(0u, itorPC.size());
87-
bool postSyncFound = false;
88-
for (auto it : itorPC) {
89-
auto cmd = genCmdCast<PIPE_CONTROL *>(*it);
90-
if (cmd->getPostSyncOperation() == POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA) {
91-
EXPECT_EQ(cmd->getImmediateData(), Event::STATE_SIGNALED);
92-
EXPECT_TRUE(cmd->getCommandStreamerStallEnable());
93-
EXPECT_FALSE(cmd->getDcFlushEnable());
94-
postSyncFound = true;
95-
}
96-
}
97-
ASSERT_TRUE(postSyncFound);
98-
}
99-
10056
HWTEST_F(CommandListAppendSignalEvent, givenEventWithScopeFlagDeviceWhenAppendingSignalEventThenPipeControlHasNoDcFlush) {
10157
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
10258
using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION;

0 commit comments

Comments
 (0)