From 1cc4048533e2788f5cae4aa5099d8a112a8cb4fa Mon Sep 17 00:00:00 2001 From: Saleel Kudchadker Date: Sat, 17 Oct 2020 10:18:45 -0700 Subject: [PATCH] Add a new flag for profilingInfo to record gpu TS Add a flag to record gpu TS in a marker, also disable marker flush if there was already a marker submitted before. Change-Id: I9cdf8e49137690c0050fe9370764dd059855a2f8 [ROCm/hip commit: 390d8c54cb8aa0ff35323a5534aab26151d12bf0] --- projects/hip/rocclr/hip_event.cpp | 35 +++++++++++++++++-------------- projects/hip/rocclr/hip_event.hpp | 3 ++- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/projects/hip/rocclr/hip_event.cpp b/projects/hip/rocclr/hip_event.cpp index 5fa2e9ea6e..e11db7cb8c 100755 --- a/projects/hip/rocclr/hip_event.cpp +++ b/projects/hip/rocclr/hip_event.cpp @@ -138,26 +138,29 @@ hipError_t Event::streamWait(amd::HostQueue* hostQueue, uint flags) { } void Event::addMarker(amd::HostQueue* queue, amd::Command* command, bool record) { - amd::ScopedLock lock(lock_); + if (command == nullptr) { + command = queue->getLastQueuedCommand(true); - if (queue->properties().test(CL_QUEUE_PROFILING_ENABLE)) { - if (command == nullptr) { - command = queue->getLastQueuedCommand(true); - if ((command == nullptr) || (command->type() == 0)) { - // if lastEnqueuedCommand is user invisible command(command->type() == 0), - // which is only used for sync, create a new amd:Marker - // and release() lastEnqueuedCommand - if (command != nullptr) { - command->release(); - } - command = new amd::Marker(*queue, kMarkerDisableFlush); - command->enqueue(); + bool cmdNullOrMarker = (command == nullptr) || (command->type() == 0); + + // If lastQueuedCommand is user invisible command(command->type() == 0), + // Always submit a marker if queue profiling is not explicitly enabled else + // submit a normal marker. Disable queue flush to batch commands + if (!queue->properties().test(CL_QUEUE_PROFILING_ENABLE)) { + if (command != nullptr) { + command->release(); } + command = new hip::ProfileMarker(*queue, cmdNullOrMarker, true); + command->enqueue(); + } else if (cmdNullOrMarker) { + if (command != nullptr) { + command->release(); + } + command = new amd::Marker(*queue, kMarkerDisableFlush); + command->enqueue(); } - } else if (command == nullptr) { - command = new hip::ProfileMarker(*queue, false); - command->enqueue(); } + amd::ScopedLock lock(lock_); if (event_ == &command->event()) return; diff --git a/projects/hip/rocclr/hip_event.hpp b/projects/hip/rocclr/hip_event.hpp index dccd4e884a..4a5395383d 100644 --- a/projects/hip/rocclr/hip_event.hpp +++ b/projects/hip/rocclr/hip_event.hpp @@ -28,10 +28,11 @@ namespace hip { class ProfileMarker: public amd::Marker { public: - ProfileMarker(amd::HostQueue& queue, bool disableFlush) + ProfileMarker(amd::HostQueue& queue, bool disableFlush, bool markerTs) : amd::Marker(queue, disableFlush) { profilingInfo_.enabled_ = true; profilingInfo_.callback_ = nullptr; + profilingInfo_.marker_ts_ = markerTs; profilingInfo_.clear(); } };