diff options
Diffstat (limited to 'src/profiling')
-rw-r--r-- | src/profiling/ProfilingService.cpp | 1 | ||||
-rw-r--r-- | src/profiling/ProfilingService.hpp | 10 | ||||
-rw-r--r-- | src/profiling/backends/BackendProfiling.cpp | 48 | ||||
-rw-r--r-- | src/profiling/backends/BackendProfiling.hpp | 49 |
4 files changed, 108 insertions, 0 deletions
diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp index 926e54a5bd..5cee477bd5 100644 --- a/src/profiling/ProfilingService.cpp +++ b/src/profiling/ProfilingService.cpp @@ -391,6 +391,7 @@ void ProfilingService::Reset() // ...finally reset the profiling state machine m_StateMachine.Reset(); + m_BackendProfilingContexts.clear(); } void ProfilingService::Stop() diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp index e510589caa..4438952853 100644 --- a/src/profiling/ProfilingService.hpp +++ b/src/profiling/ProfilingService.hpp @@ -22,6 +22,7 @@ #include "SendCounterPacket.hpp" #include "SendTimelinePacket.hpp" #include "TimelinePacketWriterFactory.hpp" +#include <armnn/backends/profiling/IBackendProfilingContext.hpp> namespace armnn { @@ -63,6 +64,13 @@ public: // Disconnects the profiling service from the external server void Disconnect(); + // Store a profiling context returned from a backend that support profiling. + void AddBackendProfilingContext(const BackendId backendId, + std::shared_ptr<armnn::profiling::IBackendProfilingContext> profilingContext) + { + m_BackendProfilingContexts.emplace(backendId, std::move(profilingContext)); + } + const ICounterDirectory& GetCounterDirectory() const; ICounterRegistry& GetCounterRegistry(); ProfilingState GetCurrentState() const; @@ -132,6 +140,8 @@ private: PerJobCounterSelectionCommandHandler m_PerJobCounterSelectionCommandHandler; ProfilingGuidGenerator m_GuidGenerator; TimelinePacketWriterFactory m_TimelinePacketWriterFactory; + std::unordered_map<BackendId, + std::shared_ptr<armnn::profiling::IBackendProfilingContext>> m_BackendProfilingContexts; protected: // Default constructor/destructor kept protected for testing diff --git a/src/profiling/backends/BackendProfiling.cpp b/src/profiling/backends/BackendProfiling.cpp new file mode 100644 index 0000000000..a49122a7a1 --- /dev/null +++ b/src/profiling/backends/BackendProfiling.cpp @@ -0,0 +1,48 @@ +// +// Copyright © 2020 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "BackendProfiling.hpp" +#include "RegisterBackendCounters.hpp" + +namespace armnn +{ + +namespace profiling +{ + +std::unique_ptr<IRegisterBackendCounters> + BackendProfiling::GetCounterRegistrationInterface(uint16_t currentMaxGlobalCounterID) +{ + return std::make_unique<RegisterBackendCounters>(RegisterBackendCounters(currentMaxGlobalCounterID, m_backendId)); +} + +std::unique_ptr<ISendTimelinePacket> BackendProfiling::GetSendTimelinePacket() +{ + return m_ProfilingService.GetSendTimelinePacket(); +} + +IProfilingGuidGenerator& BackendProfiling::GetProfilingGuidGenerator() +{ + // The profiling service is our Guid Generator. + return m_ProfilingService; +} + +CounterStatus BackendProfiling::GetCounterStatus(uint16_t) +{ + return CounterStatus(); +} + +std::vector<CounterStatus> BackendProfiling::GetActiveCounters() +{ + return std::vector<CounterStatus>(); +} + +bool BackendProfiling::IsProfilingEnabled() const +{ + return m_ProfilingService.IsProfilingEnabled(); +} + +} // namespace profiling +} // namespace armnn diff --git a/src/profiling/backends/BackendProfiling.hpp b/src/profiling/backends/BackendProfiling.hpp new file mode 100644 index 0000000000..2bc365a1de --- /dev/null +++ b/src/profiling/backends/BackendProfiling.hpp @@ -0,0 +1,49 @@ +// +// Copyright © 2020 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include <ProfilingService.hpp> +#include <armnn/backends/profiling/IBackendProfiling.hpp> + +namespace armnn +{ + +namespace profiling +{ + +class BackendProfiling : public IBackendProfiling +{ +public: + BackendProfiling(const IRuntime::CreationOptions& options, ProfilingService& profilingService, const BackendId& id) + : m_options(options) + , m_ProfilingService(profilingService) + , m_backendId(id) + {} + + ~BackendProfiling() + {} + + std::unique_ptr<IRegisterBackendCounters> + GetCounterRegistrationInterface(uint16_t currentMaxGlobalCounterID) override; + + std::unique_ptr<ISendTimelinePacket> GetSendTimelinePacket() override; + + IProfilingGuidGenerator& GetProfilingGuidGenerator() override; + + void ReportCounters(const std::vector<Timestamp>&) override + {} + + CounterStatus GetCounterStatus(uint16_t backendCounterId) override; + + std::vector<CounterStatus> GetActiveCounters() override; + + bool IsProfilingEnabled() const override; + +private: + IRuntime::CreationOptions m_options; + ProfilingService& m_ProfilingService; + BackendId m_backendId; +}; +} // namespace profiling +} // namespace armnn
\ No newline at end of file |