From 4fd506cfe132471735407da41f2cf3ca8ffbbed9 Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Wed, 30 Jun 2021 14:36:10 -0400 Subject: [PATCH] SWDEV-289378 - Avoid CPU TS overwrite if GPU TS is available Change-Id: I2fc1a43c048b4fa1e42f27c4cf5c72fc7ae84e9c --- rocclr/device/rocm/rocvirtual.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rocclr/device/rocm/rocvirtual.hpp b/rocclr/device/rocm/rocvirtual.hpp index 64f556e412..fcf75b094e 100644 --- a/rocclr/device/rocm/rocvirtual.hpp +++ b/rocclr/device/rocm/rocvirtual.hpp @@ -131,7 +131,14 @@ class Timestamp : public amd::HeapObject { void start() { start_ = amd::Os::timeNanos(); } // End a timestamp (get timestamp from OS) - void end() { end_ = amd::Os::timeNanos(); } + void end() { + // Timestamp value can be updated by HW profiling if current command had a stall. + // Although CPU TS should be still valid in this situation, there are cases in VM mode + // when CPU timeline is out of sync with GPU timeline and shifted time can be reported + if (end_ != 0) { + end_ = amd::Os::timeNanos(); + } + } static void setGpuTicksToTime(double ticksToTime) { ticksToTime_ = ticksToTime; } static double getGpuTicksToTime() { return ticksToTime_; }