From 3d540ec113d310a9ef506f87584b5030541d600c Mon Sep 17 00:00:00 2001 From: Satyanvesh Dittakavi Date: Thu, 25 Apr 2024 16:41:10 +0000 Subject: [PATCH] SWDEV-457755 - Add TS only for kernel packets in the Accumulate command Change-Id: I1b2f01c5763761808f49802fa117abc6306a22aa --- rocclr/device/rocm/rocdevice.hpp | 2 ++ rocclr/device/rocm/rocvirtual.cpp | 19 ++++++++++++------- rocclr/platform/activity.cpp | 8 ++++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/rocclr/device/rocm/rocdevice.hpp b/rocclr/device/rocm/rocdevice.hpp index 6a45974628..3db4de144a 100644 --- a/rocclr/device/rocm/rocdevice.hpp +++ b/rocclr/device/rocm/rocdevice.hpp @@ -82,6 +82,7 @@ public: Timestamp* ts_; //!< Timestamp object associated with the signal HwQueueEngine engine_; //!< Engine used with this signal amd::Monitor lock_; //!< Signal lock for update + bool isPacketDispatch_; //!< True if the packet associated with the signal is dispatch typedef union { struct { @@ -98,6 +99,7 @@ public: : ts_(nullptr) , engine_(HwQueueEngine::Compute) , lock_("Signal Ops Lock", true) + , isPacketDispatch_(false) { signal_.handle = 0; flags_.done_ = true; diff --git a/rocclr/device/rocm/rocvirtual.cpp b/rocclr/device/rocm/rocvirtual.cpp index e074b7e9f7..04e5aea379 100644 --- a/rocclr/device/rocm/rocvirtual.cpp +++ b/rocclr/device/rocm/rocvirtual.cpp @@ -158,7 +158,7 @@ void Timestamp::checkGpuTime() { start = std::min(time.start, start); end = std::max(time.end, end); - if (command().type() == CL_COMMAND_TASK) { + if ((command().type() == CL_COMMAND_TASK) && (it->isPacketDispatch_ == true)) { static_cast(command()).addTimestamps(time.start, time.end); } @@ -868,12 +868,17 @@ bool VirtualGPU::dispatchGenericAqlPacket( // Get active signal for current dispatch if profiling is necessary packet->completion_signal = Barriers().ActiveSignal(kInitSignalValueOne, timestamp_); - // If profiling is enabled, store the correlation ID in the dispatch packet. The profiler can - // retrieve this correlation ID to attribute waves to specific dispatch locations. - if (std::is_same::value && - activity_prof::IsEnabled(OP_ID_DISPATCH)) { - auto dispatchPacket = reinterpret_cast(packet); - dispatchPacket->reserved2 = timestamp_->command().profilingInfo().correlation_id_; + if (std::is_same::value) { + // If profiling is enabled, store the correlation ID in the dispatch packet. The profiler can + // retrieve this correlation ID to attribute waves to specific dispatch locations. + if (activity_prof::IsEnabled(OP_ID_DISPATCH)) { + auto dispatchPacket = reinterpret_cast(packet); + dispatchPacket->reserved2 = timestamp_->command().profilingInfo().correlation_id_; + } + + ProfilingSignal* current_signal = Barriers().GetLastSignal(); + current_signal->isPacketDispatch_ = true; + } } diff --git a/rocclr/platform/activity.cpp b/rocclr/platform/activity.cpp index e90c5a7b08..518bca55e8 100644 --- a/rocclr/platform/activity.cpp +++ b/rocclr/platform/activity.cpp @@ -103,12 +103,16 @@ void ReportActivity(const amd::Command& command) { if (command.type() == CL_COMMAND_TASK) { auto timestamps = static_cast(command).getTimestamps(); + std::vector kernel_names = + static_cast(command).getKernelNames(); for (uint32_t i = 0; i < timestamps.size(); i++) { auto it = timestamps[i]; record.begin_ns = it.first; record.end_ns = it.second; - record.kernel_name = - static_cast(command).getKernelNames()[i].c_str(); + if (kernel_names[i].empty()) { + LogError("kernel name cannot be empty"); + } + record.kernel_name = kernel_names[i].c_str(); function(ACTIVITY_DOMAIN_HIP_OPS, operation_id, &record); } } else {