Skip to content

[SYCL][L0] Fix timestamp calculation (in ns) #5555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5105,6 +5105,8 @@ pi_result piEventGetProfilingInfo(pi_event Event, pi_profiling_info ParamName,
Event->Queue
? Event->Queue->Device->ZeDeviceProperties->timerResolution
: Event->Context->Devices[0]->ZeDeviceProperties->timerResolution;
// Get timestamp frequency
const double ZeTimerFreq = 1E09 / ZeTimerResolution;

ReturnHelper ReturnValue(ParamValueSize, ParamValue, ParamValueSizeRet);

Expand All @@ -5113,11 +5115,8 @@ pi_result piEventGetProfilingInfo(pi_event Event, pi_profiling_info ParamName,
switch (ParamName) {
case PI_PROFILING_INFO_COMMAND_START: {
ZE_CALL(zeEventQueryKernelTimestamp, (Event->ZeEvent, &tsResult));

uint64_t ContextStartTime = tsResult.context.kernelStart;
ContextStartTime *= ZeTimerResolution;

return ReturnValue(uint64_t{ContextStartTime});
uint64_t ContextStartTime = tsResult.context.kernelStart * ZeTimerFreq;
return ReturnValue(ContextStartTime);
}
case PI_PROFILING_INFO_COMMAND_END: {
ZE_CALL(zeEventQueryKernelTimestamp, (Event->ZeEvent, &tsResult));
Expand All @@ -5136,9 +5135,8 @@ pi_result piEventGetProfilingInfo(pi_event Event, pi_profiling_info ParamName,
(1LL << Device->ZeDeviceProperties->kernelTimestampValidBits) - 1;
ContextEndTime += TimestampMaxValue - ContextStartTime;
}
ContextEndTime *= ZeTimerResolution;

return ReturnValue(uint64_t{ContextEndTime});
ContextEndTime *= ZeTimerFreq;
return ReturnValue(ContextEndTime);
}
case PI_PROFILING_INFO_COMMAND_QUEUED:
case PI_PROFILING_INFO_COMMAND_SUBMIT:
Expand Down