Revert to SystemClockCounter for HSA system time.
CPUClockCounter is not NTP adjusted (CLOCK_MONOTONIC_RAW) so should be better for measurements. However, it is implemented with syscall while CLOCK_MONOTONIC is implemented via vDSO. The latency increase becomes significant when language layers make corresponding clock measurements. Reverting to CLOCK_MONOTONIC will reduce latency and allow small duration events to be measured at the cost of incorporating NTP frequency skew errors. NTP may adjust frequency by 500ppm so limits us to ~3 decimals in elapsed time. Change-Id: I920b9f707f47109d80d6c256c475638c03fb8d76
Este cometimento está contido em:
@@ -1095,25 +1095,25 @@ uint64_t GpuAgent::TranslateTime(uint64_t tick) {
|
||||
if ((t1_.GPUClockCounter < tick) || (t1_.GPUClockCounter == t0_.GPUClockCounter)) SyncClocks();
|
||||
|
||||
// Good for ~300 yrs
|
||||
// uint64_t sysdelta = t1_.CPUClockCounter - t0_.CPUClockCounter;
|
||||
// uint64_t sysdelta = t1_.SystemClockCounter - t0_.SystemClockCounter;
|
||||
// uint64_t gpudelta = t1_.GPUClockCounter - t0_.GPUClockCounter;
|
||||
// int64_t offtick = int64_t(tick - t1_.GPUClockCounter);
|
||||
//__int128 num = __int128(sysdelta)*__int128(offtick) +
|
||||
//__int128(gpudelta)*__int128(t1_.CPUClockCounter);
|
||||
//__int128(gpudelta)*__int128(t1_.SystemClockCounter);
|
||||
//__int128 sysLarge = num / __int128(gpudelta);
|
||||
// return sysLarge;
|
||||
|
||||
// Good for ~3.5 months.
|
||||
uint64_t system_tick = 0;
|
||||
double ratio = double(t1_.CPUClockCounter - t0_.CPUClockCounter) /
|
||||
double ratio = double(t1_.SystemClockCounter - t0_.SystemClockCounter) /
|
||||
double(t1_.GPUClockCounter - t0_.GPUClockCounter);
|
||||
system_tick = uint64_t(ratio * double(int64_t(tick - t1_.GPUClockCounter))) + t1_.CPUClockCounter;
|
||||
system_tick = uint64_t(ratio * double(int64_t(tick - t1_.GPUClockCounter))) + t1_.SystemClockCounter;
|
||||
|
||||
// tick predates HSA startup - extrapolate with fixed clock ratio
|
||||
if (tick < t0_.GPUClockCounter) {
|
||||
if (historical_clock_ratio_ == 0.0) historical_clock_ratio_ = ratio;
|
||||
system_tick = uint64_t(historical_clock_ratio_ * double(int64_t(tick - t0_.GPUClockCounter))) +
|
||||
t0_.CPUClockCounter;
|
||||
t0_.SystemClockCounter;
|
||||
}
|
||||
|
||||
return system_tick;
|
||||
|
||||
@@ -509,7 +509,7 @@ hsa_status_t Runtime::GetSystemInfo(hsa_system_info_t attribute, void* value) {
|
||||
case HSA_SYSTEM_INFO_TIMESTAMP: {
|
||||
HsaClockCounters clocks;
|
||||
hsaKmtGetClockCounters(0, &clocks);
|
||||
*((uint64_t*)value) = clocks.CPUClockCounter;
|
||||
*((uint64_t*)value) = clocks.SystemClockCounter;
|
||||
break;
|
||||
}
|
||||
case HSA_SYSTEM_INFO_TIMESTAMP_FREQUENCY: {
|
||||
|
||||
Criar uma nova questão referindo esta
Bloquear um utilizador