From 5bee4dfe908663fccfdc770d1584eeb60cba656c Mon Sep 17 00:00:00 2001 From: foreman Date: Thu, 13 Jun 2019 15:40:39 -0400 Subject: [PATCH] P4 to Git Change 1815357 by cpaquot@cpaquot-ocl-lc-lnx on 2019/06/12 16:24:09 SWDEV-192384 - [HIP] Fixed case where start and stop events are the same for ElapsedTime. Affected files ... ... //depot/stg/opencl/drivers/opencl/api/hip/hip_event.cpp#11 edit --- hipamd/api/hip/hip_event.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/hipamd/api/hip/hip_event.cpp b/hipamd/api/hip/hip_event.cpp index b7929461cb..1507629321 100644 --- a/hipamd/api/hip/hip_event.cpp +++ b/hipamd/api/hip/hip_event.cpp @@ -56,6 +56,23 @@ hipError_t Event::synchronize() { hipError_t Event::elapsedTime(Event& eStop, float& ms) { amd::ScopedLock startLock(lock_); + + if (this == &eStop) { + if (event_ == nullptr) { + return hipErrorInvalidResourceHandle; + } + + if (flags & hipEventDisableTiming) { + return hipErrorInvalidResourceHandle; + } + + if (!ready()) { + return hipErrorNotReady; + } + + ms = 0.f; + return hipSuccess; + } amd::ScopedLock stopLock(eStop.lock_); if (event_ == nullptr || @@ -189,7 +206,7 @@ hipError_t hipEventElapsedTime(float *ms, hipEvent_t start, hipEvent_t stop) { hip::Event* eStart = reinterpret_cast(start); hip::Event* eStop = reinterpret_cast(stop); - return HIP_RETURN(eStart->elapsedTime(*eStop, *ms)); + HIP_RETURN(eStart->elapsedTime(*eStop, *ms)); } hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) {