From 4e9849034dd8ab2e2eea48559ada3d2c78996c22 Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Tue, 29 Mar 2022 18:00:52 -0500 Subject: [PATCH] Correct inf loop defect in fast clock init. Each time delay is grown we need to reset elapsed. We want to take the most accurate sample from the set at fixed delay. Without this we will hang if there is ever an insufficiently accurate, high unit clock read. Change-Id: Ic65f364067789ac85a6572d67af2d77528e265bb --- runtime/hsa-runtime/core/util/timer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/hsa-runtime/core/util/timer.cpp b/runtime/hsa-runtime/core/util/timer.cpp index d9257eb32b..5419e4f61d 100644 --- a/runtime/hsa-runtime/core/util/timer.cpp +++ b/runtime/hsa-runtime/core/util/timer.cpp @@ -57,9 +57,11 @@ fast_clock::init::init() { // calibrate clock fast_clock::raw_rep min = 0; - clock::duration elapsed = clock::duration::max(); + clock::duration elapsed; do { + elapsed = clock::duration::max(); + for (int t = 0; t < 10; t++) { fast_clock::raw_rep r1, r2; clock::time_point t0, t1, t2, t3;