From f80044bd6a6b310ee95ca4eeab19b47c8fc47900 Mon Sep 17 00:00:00 2001 From: Satyanvesh Dittakavi Date: Thu, 20 Aug 2020 13:03:52 +0000 Subject: [PATCH] SWDEV-248293 - Fix elapsedTime Fixes the elapsed time for the scenarios where HIP API takes one of the start/stop events and another one is recorded using hipEventRecord. Change-Id: I51831b2651fc8e7207ff0e3fcc6dc7c1b4239fa8 --- hipamd/rocclr/hip_event.cpp | 12 ++++++------ hipamd/rocclr/hip_module.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hipamd/rocclr/hip_event.cpp b/hipamd/rocclr/hip_event.cpp index 52775990be..5fa2e9ea6e 100755 --- a/hipamd/rocclr/hip_event.cpp +++ b/hipamd/rocclr/hip_event.cpp @@ -90,12 +90,10 @@ hipError_t Event::elapsedTime(Event& eStop, float& ms) { return hipErrorNotReady; } - // For certain HIP API's that take start and stop event - // and no hipEventRecord needs to be called - if (event_ == eStop.event_ && !recorded_ && !eStop.recorded_) { + if (event_ != eStop.event_ && recorded_ && eStop.recorded_) { ms = static_cast(static_cast(eStop.event_->profilingInfo().end_ - - event_->profilingInfo().start_))/1000000.f; - } else if (event_ == eStop.event_) { + event_->profilingInfo().end_))/1000000.f; + } else if (event_ == eStop.event_ && (recorded_ || eStop.recorded_)) { // Events are the same, which indicates the stream is empty and likely // eventRecord is called on another stream. For such cases insert and measure a // marker. @@ -107,8 +105,10 @@ hipError_t Event::elapsedTime(Event& eStop, float& ms) { command->release(); } else { + // For certain HIP API's that take both start and stop event + // or scenarios where HIP API takes one of the events and the other event is recorded with hipEventRecord ms = static_cast(static_cast(eStop.event_->profilingInfo().end_ - - event_->profilingInfo().end_))/1000000.f; + event_->profilingInfo().start_))/1000000.f; } return hipSuccess; } diff --git a/hipamd/rocclr/hip_module.cpp b/hipamd/rocclr/hip_module.cpp index 3af767d8a9..4a09cc6ed0 100755 --- a/hipamd/rocclr/hip_module.cpp +++ b/hipamd/rocclr/hip_module.cpp @@ -287,7 +287,7 @@ hipError_t ihipModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX, } } - profileNDRange = (startEvent != nullptr && stopEvent != nullptr); + profileNDRange = (startEvent != nullptr || stopEvent != nullptr); // Flag set to 1 signifies that kernel can be launched in anyorder if (flags & hipExtAnyOrderLaunch) {