fix: improve event timestamp completion tracking

Related-To: HSD-18041011542

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski 2024-12-20 13:11:47 +00:00 committed by Compute-Runtime-Automation
parent 6aeb8dffa0
commit 54fb82f689
3 changed files with 18 additions and 11 deletions

View File

@ -78,6 +78,7 @@ struct EventImp : public Event {
const uint32_t count, const ze_kernel_timestamp_result_t *pKernelTimestampsBuffer); const uint32_t count, const ze_kernel_timestamp_result_t *pKernelTimestampsBuffer);
void copyDataToEventAlloc(void *dstHostAddr, uint64_t dstGpuVa, size_t copySize, const void *copyData); void copyDataToEventAlloc(void *dstHostAddr, uint64_t dstGpuVa, size_t copySize, const void *copyData);
void copyTbxData(uint64_t dstGpuVa, size_t copySize); void copyTbxData(uint64_t dstGpuVa, size_t copySize);
bool isTimestampPopulated() const { return (contextEndTS != Event::STATE_CLEARED || globalEndTS != Event::STATE_CLEARED); }
void synchronizeCounterBasedTimestampCompletionWithTimeout(); void synchronizeCounterBasedTimestampCompletionWithTimeout();
}; };

View File

@ -772,8 +772,8 @@ void EventImp<TagSizeT>::synchronizeCounterBasedTimestampCompletionWithTimeout()
calculateProfilingData(); calculateProfilingData();
timeDiff = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - startTime).count(); timeDiff = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - startTime).count();
} while ((contextEndTS == Event::STATE_CLEARED || contextEndTS == 0) && (timeDiff < timeoutMs)); } while (!isTimestampPopulated() && (timeDiff < timeoutMs));
DEBUG_BREAK_IF(contextEndTS == Event::STATE_CLEARED || contextEndTS == 0); DEBUG_BREAK_IF(!isTimestampPopulated());
} }
template <typename TagSizeT> template <typename TagSizeT>
@ -787,7 +787,7 @@ ze_result_t EventImp<TagSizeT>::queryKernelTimestamp(ze_kernel_timestamp_result_
assignKernelEventCompletionData(getHostAddress()); assignKernelEventCompletionData(getHostAddress());
calculateProfilingData(); calculateProfilingData();
if (isCounterBased() && (contextEndTS == Event::STATE_CLEARED || contextEndTS == 0)) { if (isCounterBased() && !isTimestampPopulated()) {
synchronizeCounterBasedTimestampCompletionWithTimeout(); synchronizeCounterBasedTimestampCompletionWithTimeout();
} }

View File

@ -457,10 +457,12 @@ HWTEST2_F(InOrderCmdListTests, givenCounterBasedTimestampEventWhenQueryingTimest
uint32_t assignKernelEventCompletionDataCalled = 0; uint32_t assignKernelEventCompletionDataCalled = 0;
uint32_t assignKernelEventCompletionDataFailCounter = 0; uint32_t assignKernelEventCompletionDataFailCounter = 0;
uint64_t notReadyData = Event::STATE_CLEARED; const uint64_t notReadyData = Event::STATE_CLEARED;
bool useContextEndForVerification = true;
void assignKernelEventCompletionData(void *address) override { void assignKernelEventCompletionData(void *address) override {
auto completionAddress = reinterpret_cast<uint64_t *>(getCompletionFieldHostAddress()); auto offset = useContextEndForVerification ? NEO::TimestampPackets<uint64_t, 1>::getContextEndOffset() : NEO::TimestampPackets<uint64_t, 1>::getGlobalEndOffset();
auto completionAddress = reinterpret_cast<uint64_t *>(ptrOffset(getHostAddress(), offset));
assignKernelEventCompletionDataCalled++; assignKernelEventCompletionDataCalled++;
if (assignKernelEventCompletionDataCalled <= assignKernelEventCompletionDataFailCounter) { if (assignKernelEventCompletionDataCalled <= assignKernelEventCompletionDataFailCounter) {
*completionAddress = notReadyData; *completionAddress = notReadyData;
@ -481,17 +483,21 @@ HWTEST2_F(InOrderCmdListTests, givenCounterBasedTimestampEventWhenQueryingTimest
event1->enableCounterBasedMode(true, ZE_EVENT_POOL_COUNTER_BASED_EXP_FLAG_IMMEDIATE); event1->enableCounterBasedMode(true, ZE_EVENT_POOL_COUNTER_BASED_EXP_FLAG_IMMEDIATE);
event1->assignKernelEventCompletionDataFailCounter = 2; event1->assignKernelEventCompletionDataFailCounter = 2;
event1->setUsingContextEndOffset(true); event1->setUsingContextEndOffset(true);
event1->setEventTimestampFlag(true);
event1->useContextEndForVerification = true;
event2->enableCounterBasedMode(true, ZE_EVENT_POOL_COUNTER_BASED_EXP_FLAG_IMMEDIATE); event2->enableCounterBasedMode(true, ZE_EVENT_POOL_COUNTER_BASED_EXP_FLAG_IMMEDIATE);
event2->assignKernelEventCompletionDataFailCounter = 2; event2->assignKernelEventCompletionDataFailCounter = 2;
event2->setUsingContextEndOffset(true); event2->setUsingContextEndOffset(true);
event2->notReadyData = 0; event2->setEventTimestampFlag(true);
event2->useContextEndForVerification = false;
cmdList->appendLaunchKernel(kernel->toHandle(), groupCount, event1->toHandle(), 0, nullptr, launchParams, false); cmdList->appendLaunchKernel(kernel->toHandle(), groupCount, event1->toHandle(), 0, nullptr, launchParams, false);
cmdList->appendLaunchKernel(kernel->toHandle(), groupCount, event2->toHandle(), 0, nullptr, launchParams, false); event1->hostEventSetValue(Event::STATE_CLEARED);
cmdList->appendLaunchKernel(kernel->toHandle(), groupCount, event2->toHandle(), 0, nullptr, launchParams, false);
event2->hostEventSetValue(Event::STATE_CLEARED);
*reinterpret_cast<uint64_t *>(event1->getCompletionFieldHostAddress()) = Event::STATE_CLEARED;
*reinterpret_cast<uint64_t *>(event2->getCompletionFieldHostAddress()) = 0;
event1->getInOrderExecInfo()->setLastWaitedCounterValue(2); event1->getInOrderExecInfo()->setLastWaitedCounterValue(2);
event2->getInOrderExecInfo()->setLastWaitedCounterValue(2); event2->getInOrderExecInfo()->setLastWaitedCounterValue(2);
@ -500,8 +506,8 @@ HWTEST2_F(InOrderCmdListTests, givenCounterBasedTimestampEventWhenQueryingTimest
ze_kernel_timestamp_result_t kernelTimestamps = {}; ze_kernel_timestamp_result_t kernelTimestamps = {};
EXPECT_EQ(0u, event1->assignKernelEventCompletionDataCalled); event1->assignKernelEventCompletionDataCalled = 0;
EXPECT_EQ(0u, event2->assignKernelEventCompletionDataCalled); event2->assignKernelEventCompletionDataCalled = 0;
event1->queryKernelTimestamp(&kernelTimestamps); event1->queryKernelTimestamp(&kernelTimestamps);
event2->queryKernelTimestamp(&kernelTimestamps); event2->queryKernelTimestamp(&kernelTimestamps);