Skip to content

Commit c228f12

Browse files
[SYCL][L0] Fix timestamp calculation (in ns) (#5555)
Follow L0 spec for proper timestamp calculation: https://spec.oneapi.io/level-zero/latest/core/PROG.html?highlight=zeeventquerykerneltimestamp#kernel-timestamp-events Signed-off-by: Sergey V Maslov <[email protected]>
1 parent c7ba937 commit c228f12

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5105,6 +5105,8 @@ pi_result piEventGetProfilingInfo(pi_event Event, pi_profiling_info ParamName,
51055105
Event->Queue
51065106
? Event->Queue->Device->ZeDeviceProperties->timerResolution
51075107
: Event->Context->Devices[0]->ZeDeviceProperties->timerResolution;
5108+
// Get timestamp frequency
5109+
const double ZeTimerFreq = 1E09 / ZeTimerResolution;
51085110

51095111
ReturnHelper ReturnValue(ParamValueSize, ParamValue, ParamValueSizeRet);
51105112

@@ -5113,11 +5115,8 @@ pi_result piEventGetProfilingInfo(pi_event Event, pi_profiling_info ParamName,
51135115
switch (ParamName) {
51145116
case PI_PROFILING_INFO_COMMAND_START: {
51155117
ZE_CALL(zeEventQueryKernelTimestamp, (Event->ZeEvent, &tsResult));
5116-
5117-
uint64_t ContextStartTime = tsResult.context.kernelStart;
5118-
ContextStartTime *= ZeTimerResolution;
5119-
5120-
return ReturnValue(uint64_t{ContextStartTime});
5118+
uint64_t ContextStartTime = tsResult.context.kernelStart * ZeTimerFreq;
5119+
return ReturnValue(ContextStartTime);
51215120
}
51225121
case PI_PROFILING_INFO_COMMAND_END: {
51235122
ZE_CALL(zeEventQueryKernelTimestamp, (Event->ZeEvent, &tsResult));
@@ -5136,9 +5135,8 @@ pi_result piEventGetProfilingInfo(pi_event Event, pi_profiling_info ParamName,
51365135
(1LL << Device->ZeDeviceProperties->kernelTimestampValidBits) - 1;
51375136
ContextEndTime += TimestampMaxValue - ContextStartTime;
51385137
}
5139-
ContextEndTime *= ZeTimerResolution;
5140-
5141-
return ReturnValue(uint64_t{ContextEndTime});
5138+
ContextEndTime *= ZeTimerFreq;
5139+
return ReturnValue(ContextEndTime);
51425140
}
51435141
case PI_PROFILING_INFO_COMMAND_QUEUED:
51445142
case PI_PROFILING_INFO_COMMAND_SUBMIT:

0 commit comments

Comments
 (0)