From ecf5e6ca8fc78b051c576ebf05f5e69f060e902c Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Tue, 25 Aug 2020 20:12:52 -0500 Subject: [PATCH] Convert from double to uint64_t in two steps. We want wraparound behavior here but we don't want to trigger sanitizer warnings. Converting to int64_t and then wraping around by cast to uint64_t avoids the UB issue that triggers the sanitizer warning. Change-Id: I9400b988dce7899e9ba42cab3e35c7ffedec8fe1 [ROCm/ROCR-Runtime commit: 5f43778a51c697999cbfb8cc73501f517d4c30f0] --- .../runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp index 1cb61fc7fa..2caf5fa07d 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp @@ -1188,7 +1188,7 @@ uint64_t GpuAgent::TranslateTime(uint64_t tick) { uint64_t system_tick = 0; double ratio = double(t1_.SystemClockCounter - t0_.SystemClockCounter) / double(t1_.GPUClockCounter - t0_.GPUClockCounter); - system_tick = uint64_t(ratio * double(int64_t(tick - t1_.GPUClockCounter))) + t1_.SystemClockCounter; + system_tick = uint64_t(int64_t(ratio * double(int64_t(tick - t1_.GPUClockCounter)))) + t1_.SystemClockCounter; // tick predates HSA startup - extrapolate with fixed clock ratio if (tick < t0_.GPUClockCounter) {