Allow signals for event of timestamp type

While at it, fix event of timestamp type failing
to correctly report completion

Change-Id: I3ed6e804ab81dc3c3758093fe04e696decb3d82f
Signed-off-by: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@intel.com>
This commit is contained in:
Aravind Gopalakrishnan
2020-08-24 20:21:34 -07:00
parent fea75ec3d6
commit 78824a3be1
4 changed files with 53 additions and 6 deletions

View File

@@ -1314,14 +1314,20 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent(ze_event_han
auto event = Event::fromHandle(hEvent);
commandContainer.addToResidencyContainer(&event->getAllocation());
uint64_t baseAddr = event->getGpuAddress();
size_t eventSignalOffset = 0;
if (event->isTimestampEvent) {
eventSignalOffset = offsetof(KernelTimestampEvent, contextEnd);
}
if (isCopyOnlyCmdList) {
NEO::EncodeMiFlushDW<GfxFamily>::programMiFlushDw(*commandContainer.getCommandStream(), event->getGpuAddress(), Event::STATE_SIGNALED, false, true);
NEO::EncodeMiFlushDW<GfxFamily>::programMiFlushDw(*commandContainer.getCommandStream(), ptrOffset(baseAddr, eventSignalOffset), Event::STATE_SIGNALED, false, true);
} 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,
event->getGpuAddress(), Event::STATE_SIGNALED,
ptrOffset(baseAddr, eventSignalOffset), Event::STATE_SIGNALED,
commandContainer.getDevice()->getHardwareInfo(),
args);
}
@@ -1397,7 +1403,7 @@ void CommandListCoreFamily<gfxCoreFamily>::appendEventForProfiling(ze_event_hand
auto contextEndAddr = baseAddr + offsetof(KernelTimestampEvent, contextEnd);
auto globalEndAddr = baseAddr + offsetof(KernelTimestampEvent, globalEnd);
NEO::PipeControlArgs args;
args.dcFlushEnable = false;
args.dcFlushEnable = true;
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControl(*commandContainer.getCommandStream(), args);

View File

@@ -50,8 +50,8 @@ struct Event : _ze_event_handle_t {
void *hostAddress = nullptr;
uint64_t gpuAddress;
ze_event_scope_flags_t signalScope; // Saving scope for use later
ze_event_scope_flags_t waitScope;
ze_event_scope_flags_t signalScope = 0u;
ze_event_scope_flags_t waitScope = 0u;
bool isTimestampEvent = false;

View File

@@ -316,7 +316,7 @@ HWTEST2_F(CommandListAppendLaunchKernel, givenTimestampEventsWhenAppendingKernel
{
auto cmd = genCmdCast<PIPE_CONTROL *>(*itor);
EXPECT_TRUE(cmd->getCommandStreamerStallEnable());
EXPECT_FALSE(cmd->getDcFlushEnable());
EXPECT_TRUE(cmd->getDcFlushEnable());
}
itor++;

View File

@@ -183,5 +183,46 @@ HWTEST2_F(CommandListAppendSignalEvent, givenCommandListWhenAppendWriteGlobalTim
EXPECT_FALSE(cmd->getDcFlushEnable());
}
HWTEST2_F(CommandListAppendSignalEvent, givenTimestampEventUsedInSignalThenPipeControlAppendedCorrectly, Platforms) {
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION;
auto &commandContainer = commandList->commandContainer;
ze_event_pool_desc_t eventPoolDesc = {};
eventPoolDesc.count = 1;
eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP;
ze_event_desc_t eventDesc = {};
eventDesc.index = 0;
auto eventPool = std::unique_ptr<L0::EventPool>(L0::EventPool::create(driverHandle.get(), 0, nullptr, &eventPoolDesc));
auto event = std::unique_ptr<L0::Event>(L0::Event::create(eventPool.get(), &eventDesc, device));
commandList->appendSignalEvent(event->toHandle());
auto contextOffset = offsetof(KernelTimestampEvent, contextEnd);
auto baseAddr = event->getGpuAddress();
auto gpuAddress = ptrOffset(baseAddr, contextOffset);
GenCmdList cmdList;
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
cmdList, ptrOffset(commandContainer.getCommandStream()->getCpuBase(), 0), commandContainer.getCommandStream()->getUsed()));
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_EQ(cmd->getAddressHigh(), gpuAddress >> 32u);
EXPECT_EQ(cmd->getAddress(), uint32_t(gpuAddress));
EXPECT_FALSE(cmd->getDcFlushEnable());
postSyncFound = true;
}
}
ASSERT_TRUE(postSyncFound);
}
} // namespace ult
} // namespace L0