2
0

Switch to CLOCK_BOOTTIME for HSA system clock.

This is consistent with KFD and has significantly better latency.
KFD is taking this as the definition of the SystemClockCounter.

Change-Id: I4c1b3bc58c738206265c55ebefd41356c013bfe5


[ROCm/ROCR-Runtime commit: 0ee82742a7]
Este cometimento está contido em:
Sean Keely
2022-04-27 20:16:54 -05:00
ascendente be1d3bef2d
cometimento 2b8c129efb
4 ficheiros modificados com 40 adições e 7 eliminações
@@ -515,6 +515,25 @@ void DestroySharedMutex(SharedMutex lock) {
delete *(pthread_rwlock_t**)&lock;
}
static uint64_t sys_clock_period_ = 0;
uint64_t ReadSystemClock() {
struct timespec ts;
clock_gettime(CLOCK_BOOTTIME, &ts);
uint64_t time = (uint64_t(ts.tv_sec) * 1000000000 + uint64_t(ts.tv_nsec));
if (sys_clock_period_ != 1)
return time / sys_clock_period_;
else
return time;
}
uint64_t SystemClockFrequency() {
struct timespec ts;
clock_getres(CLOCK_BOOTTIME, &ts);
sys_clock_period_ = (uint64_t(ts.tv_sec) * 1000000000 + uint64_t(ts.tv_nsec));
return 1000000000 / sys_clock_period_;
}
} // namespace os
} // namespace rocr
+8
Ver ficheiro
@@ -266,6 +266,14 @@ uint64_t ReadAccurateClock();
/// seconds. This frequency does not change at runtime.
/// @return returns the frequency
uint64_t AccurateClockFrequency();
/// @brief read the system clock which serves as the HSA system clock
/// counter in KFD.
uint64_t ReadSystemClock();
/// @brief read the system clock frequency
uint64_t SystemClockFrequency();
} // namespace os
} // namespace rocr
@@ -270,6 +270,16 @@ void DestroySharedMutex(SharedMutex lock) {
abort();
}
uint64_t ReadSystemClock() {
assert(false && "Not implemented.");
abort();
}
uint64_t SystemClockFrequency() {
assert(false && "Not implemented.");
abort();
}
} // namespace os
} // namespace rocr