2
0

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:
Sean Keely
2019-05-20 12:41:48 -05:00
ascendente 259a1bac18
cometimento 4b22d24346
2 ficheiros modificados com 6 adições e 6 eliminações
+5 -5
Ver ficheiro
@@ -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;
+1 -1
Ver ficheiro
@@ -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: {