@@ -5147,8 +5147,15 @@ pi_result piEventGetProfilingInfo(pi_event Event, pi_profiling_info ParamName,
5147
5147
Event->Queue
5148
5148
? Event->Queue ->Device ->ZeDeviceProperties ->timerResolution
5149
5149
: Event->Context ->Devices [0 ]->ZeDeviceProperties ->timerResolution ;
5150
- // Get timestamp frequency
5151
- const double ZeTimerFreq = 1E09 / ZeTimerResolution;
5150
+
5151
+ const uint64_t TimestampMaxValue =
5152
+ Event->Queue
5153
+ ? ((1ULL << Event->Queue ->Device ->ZeDeviceProperties
5154
+ ->kernelTimestampValidBits ) -
5155
+ 1ULL )
5156
+ : ((1ULL << Event->Context ->Devices [0 ]
5157
+ ->ZeDeviceProperties ->kernelTimestampValidBits ) -
5158
+ 1ULL );
5152
5159
5153
5160
ReturnHelper ReturnValue (ParamValueSize, ParamValue, ParamValueSizeRet);
5154
5161
@@ -5157,27 +5164,27 @@ pi_result piEventGetProfilingInfo(pi_event Event, pi_profiling_info ParamName,
5157
5164
switch (ParamName) {
5158
5165
case PI_PROFILING_INFO_COMMAND_START: {
5159
5166
ZE_CALL (zeEventQueryKernelTimestamp, (Event->ZeEvent , &tsResult));
5160
- uint64_t ContextStartTime = tsResult.context .kernelStart * ZeTimerFreq;
5167
+ uint64_t ContextStartTime =
5168
+ (tsResult.context .kernelStart & TimestampMaxValue) * ZeTimerResolution;
5161
5169
return ReturnValue (ContextStartTime);
5162
5170
}
5163
5171
case PI_PROFILING_INFO_COMMAND_END: {
5164
5172
ZE_CALL (zeEventQueryKernelTimestamp, (Event->ZeEvent , &tsResult));
5165
5173
5166
- uint64_t ContextStartTime = tsResult.context .kernelStart ;
5167
- uint64_t ContextEndTime = tsResult.context .kernelEnd ;
5174
+ uint64_t ContextStartTime =
5175
+ (tsResult.context .kernelStart & TimestampMaxValue);
5176
+ uint64_t ContextEndTime = (tsResult.context .kernelEnd & TimestampMaxValue);
5177
+
5168
5178
//
5169
5179
// Handle a possible wrap-around (the underlying HW counter is < 64-bit).
5170
5180
// Note, it will not report correct time if there were multiple wrap
5171
5181
// arounds, and the longer term plan is to enlarge the capacity of the
5172
5182
// HW timestamps.
5173
5183
//
5174
5184
if (ContextEndTime <= ContextStartTime) {
5175
- pi_device Device = Event->Context ->Devices [0 ];
5176
- const uint64_t TimestampMaxValue =
5177
- (1LL << Device->ZeDeviceProperties ->kernelTimestampValidBits ) - 1 ;
5178
- ContextEndTime += TimestampMaxValue - ContextStartTime;
5185
+ ContextEndTime += TimestampMaxValue;
5179
5186
}
5180
- ContextEndTime *= ZeTimerFreq ;
5187
+ ContextEndTime *= ZeTimerResolution ;
5181
5188
return ReturnValue (ContextEndTime);
5182
5189
}
5183
5190
case PI_PROFILING_INFO_COMMAND_QUEUED:
0 commit comments