From 981508b2afa607808763da8b9f10906bb6dd4e47 Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Tue, 19 Oct 2021 00:01:41 -0400 Subject: [PATCH] SWDEV-303567 - Correct events for hipHccModuleLaunchKernel Start event should be collected before the kernel launch. End event can use the command from the kernel launch. Change-Id: I5413c340280be680b15a44daa0c69b21ed314213 --- hipamd/src/hip_event.hpp | 8 ++++++++ hipamd/src/hip_module.cpp | 23 ++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/hipamd/src/hip_event.hpp b/hipamd/src/hip_event.hpp index ac05f2d4f3..6fdb67ef1d 100644 --- a/hipamd/src/hip_event.hpp +++ b/hipamd/src/hip_event.hpp @@ -98,6 +98,14 @@ class Event { hipError_t recordCommand(amd::Command*& command, amd::HostQueue* queue); hipError_t enqueueRecordCommand(hipStream_t stream, amd::Command* command, bool record); hipError_t addMarker(hipStream_t stream, amd::Command* command, bool record); + void BindCommand(amd::Command& command) { + amd::ScopedLock lock(lock_); + if (event_ != nullptr) { + event_->release(); + } + event_ = &command.event(); + command.retain(); + } bool isRecorded() { return recorded_; } amd::Monitor& lock() { return lock_; } diff --git a/hipamd/src/hip_module.cpp b/hipamd/src/hip_module.cpp index c3845e3e71..3d8658b778 100644 --- a/hipamd/src/hip_module.cpp +++ b/hipamd/src/hip_module.cpp @@ -388,22 +388,19 @@ hipError_t ihipModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX, return status; } - hip::Event* eStart = reinterpret_cast(startEvent); - hip::Event* eStop = reinterpret_cast(stopEvent); - command->enqueue(); if (startEvent != nullptr) { - status = eStart->addMarker(hStream, command, false); - command->retain(); - } - if (status != hipSuccess) { - return status; + hip::Event* eStart = reinterpret_cast(startEvent); + status = eStart->addMarker(hStream, nullptr, false); + if (status != hipSuccess) { + return status; + } } + + command->enqueue(); + if (stopEvent != nullptr) { - status = eStop->addMarker(hStream, command, true); - command->retain(); - } - if (status != hipSuccess) { - return status; + hip::Event* eStop = reinterpret_cast(stopEvent); + eStop->BindCommand(*command); } command->release();