fix: Move event reference time tracking into event class

This would avoid recalculating reference timestamps
when event is used with different command lists.

Related-To: LOCI-4563

Signed-off-by: Joshua Santosh Ranjan <joshua.santosh.ranjan@intel.com>
This commit is contained in:
Joshua Santosh Ranjan
2023-07-06 08:35:07 +00:00
committed by Compute-Runtime-Automation
parent 175ceb9bd1
commit b6e76b9118
11 changed files with 126 additions and 65 deletions

View File

@@ -394,7 +394,6 @@ struct CommandList : _ze_command_list_handle_t {
uint32_t commandListPerThreadPrivateScratchSize = 0u;
uint32_t partitionCount = 1;
uint32_t defaultMocsIndex = 0;
uint64_t timestampRefreshIntervalInNanoSec = 0;
bool isFlushTaskSubmissionEnabled = false;
bool isSyncModeQueue = false;

View File

@@ -134,8 +134,6 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::reset() {
cmdListCurrentStartOffset = 0;
mappedTsEventList.clear();
previousSynchronizedTimestamp = {};
return ZE_RESULT_SUCCESS;
}
@@ -236,20 +234,6 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::initialize(Device *device, NEO
}
createLogicalStateHelper();
const auto frequency = device->getNEODevice()->getDeviceInfo().profilingTimerResolution;
const auto maxKernelTsValue = maxNBitValue(hwInfo.capabilityTable.kernelTimestampValidBits);
if (hwInfo.capabilityTable.kernelTimestampValidBits < 64u) {
this->timestampRefreshIntervalInNanoSec = static_cast<uint64_t>(maxKernelTsValue * frequency);
} else {
this->timestampRefreshIntervalInNanoSec = maxKernelTsValue;
}
if (NEO::DebugManager.flags.CommandListTimestampRefreshIntervalInMilliSec.get() != -1) {
constexpr uint32_t milliSecondsToNanoSeconds = 1000000u;
const uint32_t refreshTime = NEO::DebugManager.flags.CommandListTimestampRefreshIntervalInMilliSec.get();
this->timestampRefreshIntervalInNanoSec = refreshTime * milliSecondsToNanoSeconds;
}
return returnType;
}

View File

@@ -246,14 +246,8 @@ void CommandListImp::storeReferenceTsToMappedEvents(bool isClearEnabled) {
if (mappedTsEventList.size()) {
uint64_t currentCpuTimeStamp = 0;
device->getNEODevice()->getOSTime()->getCpuTime(&currentCpuTimeStamp);
const auto recalculate =
(currentCpuTimeStamp - previousSynchronizedTimestamp.cpuTimeinNS) > timestampRefreshIntervalInNanoSec;
if (previousSynchronizedTimestamp.cpuTimeinNS == 0 || recalculate) {
device->getNEODevice()->getOSTime()->getCpuGpuTime(&previousSynchronizedTimestamp);
}
for (auto &event : mappedTsEventList) {
event->setReferenceTs(previousSynchronizedTimestamp);
event->setReferenceTs(currentCpuTimeStamp);
}
if (isClearEnabled) {

View File

@@ -56,7 +56,6 @@ struct CommandListImp : CommandList {
static constexpr bool cmdListDefaultMediaSamplerClockGate = false;
static constexpr bool cmdListDefaultGlobalAtomics = false;
std::vector<Event *> mappedTsEventList{};
NEO::TimeStampData previousSynchronizedTimestamp{};
};
} // namespace L0

View File

@@ -410,4 +410,12 @@ void Event::unsetCmdQueue(bool unregisterClient) {
latestUsedCmdQueue = nullptr;
}
void Event::setReferenceTs(uint64_t currentCpuTimeStamp) {
const auto recalculate =
(currentCpuTimeStamp - referenceTs.cpuTimeinNS) > timestampRefreshIntervalInNanoSec;
if (referenceTs.cpuTimeinNS == 0 || recalculate) {
device->getNEODevice()->getOSTime()->getCpuGpuTime(&referenceTs);
}
}
} // namespace L0

View File

@@ -221,9 +221,10 @@ struct Event : _ze_event_handle_t {
uint32_t getInOrderExecSignalValue() const { return inOrderExecSignalValue; }
uint32_t getInOrderAllocationOffset() const { return inOrderAllocationOffset; }
void setLatestUsedCmdQueue(CommandQueue *newCmdQ);
void setReferenceTs(NEO::TimeStampData &timestamp) {
referenceTs = timestamp;
NEO::TimeStampData *peekReferenceTs() {
return &referenceTs;
}
void setReferenceTs(uint64_t currentCpuTimeStamp);
bool hasKerneMappedTsCapability = false;
protected:
@@ -282,6 +283,7 @@ struct Event : _ze_event_handle_t {
bool signalAllEventPackets = false;
bool isFromIpcPool = false;
bool inOrderExecEvent = false;
uint64_t timestampRefreshIntervalInNanoSec = 0;
};
struct EventPool : _ze_event_pool_handle_t {

View File

@@ -67,6 +67,19 @@ Event *Event::create(EventPool *eventPool, const ze_event_desc_t *desc, Device *
event->resetDeviceCompletionData(true);
}
const auto frequency = device->getNEODevice()->getDeviceInfo().profilingTimerResolution;
const auto maxKernelTsValue = maxNBitValue(hwInfo.capabilityTable.kernelTimestampValidBits);
if (hwInfo.capabilityTable.kernelTimestampValidBits < 64u) {
event->timestampRefreshIntervalInNanoSec = static_cast<uint64_t>(maxKernelTsValue * frequency) / 2;
} else {
event->timestampRefreshIntervalInNanoSec = maxKernelTsValue / 2;
}
if (NEO::DebugManager.flags.EventTimestampRefreshIntervalInMilliSec.get() != -1) {
constexpr uint32_t milliSecondsToNanoSeconds = 1000000u;
const uint32_t refreshTime = NEO::DebugManager.flags.EventTimestampRefreshIntervalInMilliSec.get();
event->timestampRefreshIntervalInNanoSec = refreshTime * milliSecondsToNanoSeconds;
}
return event;
}