From 50be95e169c8d0df66201db6334f60b8a29dc13b Mon Sep 17 00:00:00 2001 From: Saleel Kudchadker Date: Wed, 20 May 2020 10:54:57 -0700 Subject: [PATCH] Fix elapsed time calc for hipEventElapsedTime If the start and stop events have same command internally then measure command end to command start Change-Id: Ie70cfa37c06c06573f0ed58dab2bbe4434c1724b --- rocclr/hip_event.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rocclr/hip_event.cpp b/rocclr/hip_event.cpp index dddadd1bfd..2e4870834f 100644 --- a/rocclr/hip_event.cpp +++ b/rocclr/hip_event.cpp @@ -90,9 +90,15 @@ hipError_t Event::elapsedTime(Event& eStop, float& ms) { return hipErrorNotReady; } - ms = static_cast(static_cast(eStop.event_->profilingInfo().end_ - + // For certain HIP Api's that take start and stop event + // the command is the same + if (event_ == eStop.event_) { + ms = static_cast(static_cast(eStop.event_->profilingInfo().end_ - + event_->profilingInfo().start_))/1000000.f; + } else { + ms = static_cast(static_cast(eStop.event_->profilingInfo().end_ - event_->profilingInfo().end_))/1000000.f; - + } return hipSuccess; }