From 87d2df3da3abd682b4b0745556dcc7f39873370c Mon Sep 17 00:00:00 2001 From: hthangir Date: Thu, 14 Sep 2017 13:56:15 -0500 Subject: [PATCH] Use non-RAW version in clock_getres to workaround bug in older kernels Change-Id: Ice0606a42cd7054f0804baf4af3521ffae3b7d50 --- runtime/hsa-runtime/core/util/lnx/os_linux.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/runtime/hsa-runtime/core/util/lnx/os_linux.cpp b/runtime/hsa-runtime/core/util/lnx/os_linux.cpp index 27ddcfb852..879ade0dd8 100644 --- a/runtime/hsa-runtime/core/util/lnx/os_linux.cpp +++ b/runtime/hsa-runtime/core/util/lnx/os_linux.cpp @@ -335,13 +335,14 @@ uint64_t ReadAccurateClock() { uint64_t AccurateClockFrequency() { timespec time; - int err = clock_getres(CLOCK_MONOTONIC_RAW, &time); - assert(err == 0 && "clock_getres(CLOCK_MONOTONIC_RAW,...) failed"); + //use non-RAW for getres due to bug in older 2.6.x kernels + int err = clock_getres(CLOCK_MONOTONIC, &time); + assert(err == 0 && "clock_getres(CLOCK_MONOTONIC,...) failed"); assert(time.tv_sec == 0 && - "clock_getres(CLOCK_MONOTONIC_RAW,...) returned very low frequency " + "clock_getres(CLOCK_MONOTONIC,...) returned very low frequency " "(<1Hz)."); assert(time.tv_nsec < 0xFFFFFFFF && - "clock_getres(CLOCK_MONOTONIC_RAW,...) returned very low frequency " + "clock_getres(CLOCK_MONOTONIC,...) returned very low frequency " "(<1Hz)."); if (invPeriod == 0.0) invPeriod = 1.0 / double(time.tv_nsec); return 1000000000ull / uint64_t(time.tv_nsec);