From e713b5c7d0a098faeddab42ff6a4122001e280b8 Mon Sep 17 00:00:00 2001 From: Laurent Morichetti Date: Fri, 26 Aug 2022 22:38:17 -0700 Subject: [PATCH] SWDEV-351980 - Enable profiling for commands reporting activities Profiling should be enabled for any command reporting activities as the activity record captures the profilingInfo's start and end timestamps. Since IS_PROFILER_ON is only used to determine whether API tracing is enabled, there is no need to expose it globally, it should be a property of the activity_prof::CallbacksTable. Change-Id: I44a0d19ed2862606cfbc9a98c1a07a336ab7e26c --- rocclr/platform/command.cpp | 10 ++++++---- rocclr/platform/command.hpp | 2 +- rocclr/utils/flags.cpp | 1 - rocclr/utils/flags.hpp | 1 - 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rocclr/platform/command.cpp b/rocclr/platform/command.cpp index e2a2092dca..c16831606f 100644 --- a/rocclr/platform/command.cpp +++ b/rocclr/platform/command.cpp @@ -26,6 +26,7 @@ * \date October 2008 */ +#include "platform/activity.hpp" #include "platform/command.hpp" #include "platform/commandqueue.hpp" #include "device/device.hpp" @@ -43,14 +44,13 @@ namespace amd { // ================================================================================================ -Event::Event(HostQueue& queue) +Event::Event(HostQueue& queue, bool profilingEnabled) : callbacks_(NULL), status_(CL_INT_MAX), hw_event_(nullptr), notify_event_(nullptr), device_(&queue.device()), - profilingInfo_(IS_PROFILER_ON || queue.properties().test(CL_QUEUE_PROFILING_ENABLE) || - Agent::shouldPostEventEvents()), + profilingInfo_(profilingEnabled), event_scope_(Device::kCacheStateInvalid) { notified_.clear(); } @@ -313,7 +313,9 @@ const Event::EventWaitList Event::nullWaitList(0); // ================================================================================================ Command::Command(HostQueue& queue, cl_command_type type, const EventWaitList& eventWaitList, uint32_t commandWaitBits, const Event* waitingEvent) - : Event(queue), + : Event(queue, activity_prof::CallbacksTable::isEnabled(activity_prof::operationId(type)) || + queue.properties().test(CL_QUEUE_PROFILING_ENABLE) || + Agent::shouldPostEventEvents()), queue_(&queue), next_(nullptr), type_(type), diff --git a/rocclr/platform/command.hpp b/rocclr/platform/command.hpp index df20845037..6519557351 100644 --- a/rocclr/platform/command.hpp +++ b/rocclr/platform/command.hpp @@ -143,7 +143,7 @@ class Event : public RuntimeObject { Event(); //! Construct a new event associated to the given command \a queue. - Event(HostQueue& queue); + Event(HostQueue& queue, bool profilingEnabled = false); //! Destroy the event. virtual ~Event(); diff --git a/rocclr/utils/flags.cpp b/rocclr/utils/flags.cpp index 34eb13595b..4606d2c6b4 100644 --- a/rocclr/utils/flags.cpp +++ b/rocclr/utils/flags.cpp @@ -82,7 +82,6 @@ namespace amd { #endif // __APPLE__ bool IS_HIP = false; -std::atomic_bool IS_PROFILER_ON(false); #if !defined(_WIN32) && defined(WITH_PAL_DEVICE) bool IS_LEGACY = true; diff --git a/rocclr/utils/flags.hpp b/rocclr/utils/flags.hpp index 86fca91f5f..c9d25e0887 100644 --- a/rocclr/utils/flags.hpp +++ b/rocclr/utils/flags.hpp @@ -282,7 +282,6 @@ release(bool, ROC_EVENT_NO_FLUSH, false, \ namespace amd { extern bool IS_HIP; -extern std::atomic_bool IS_PROFILER_ON; extern bool IS_LEGACY;