From 2f18d996fde7908f2110a9be9a4e32ab86897f3c Mon Sep 17 00:00:00 2001 From: lyndonli Date: Thu, 7 Nov 2024 17:45:15 +0800 Subject: [PATCH] wsl/hsakmt: Fix inaccurate elapsed time measurement Signed-off-by: lyndonli Reviewed-by: Shane Xiao Reviewed-by: Flora Cui Part-of: --- time.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/time.cpp b/time.cpp index f0fa66705d..edc9cb3052 100644 --- a/time.cpp +++ b/time.cpp @@ -39,12 +39,10 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtGetClockCounters(HSAuint32 NodeId, wsl::thunk::WDDMDevice *device_ = get_wddmdev(NodeId); assert(device_); - device_->GetClockCounters(&Counters->GPUClockCounter, nullptr); + device_->GetClockCounters(&Counters->GPUClockCounter, &Counters->CPUClockCounter); struct timespec ts; - if (clock_gettime(CLOCK_REALTIME, &ts) == 0) - Counters->CPUClockCounter = ts.tv_sec * 1e9 + ts.tv_nsec; - if (clock_gettime(CLOCK_BOOTTIME, &ts) == 0) + if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) == 0) Counters->SystemClockCounter = ts.tv_sec * 1e9 + ts.tv_nsec; Counters->SystemClockFrequencyHz = 1000000000;