diff options
author | James Conroy <james.conroy@arm.com> | 2020-02-06 18:34:52 +0000 |
---|---|---|
committer | Colm Donelan <colm.donelan@arm.com> | 2020-02-10 11:13:00 +0000 |
commit | 2dcd3fef30ad3ac41621f3f8b142632e912ea42d (patch) | |
tree | 3916a75d338e1d261a71c786d1c25d4ff144c1df /src/profiling/backends | |
parent | 1398b75f03f8558756f11ec0f89dccea6e864c84 (diff) | |
download | armnn-2dcd3fef30ad3ac41621f3f8b142632e912ea42d.tar.gz |
IVGCVSW-4319 Implement Counter Status Querying
* Adds implementations for GetCounterStatus and
GetActiveCounters.
* Adds CheckCounterStatusQuery in ProfilingTests.
* Modifies Holder and ProfilingService to open
up access to CaptureData for use by
BackendProfiling.
Signed-off-by: James Conroy <james.conroy@arm.com>
Signed-off-by: Colm Donelan <Colm.Donelan@arm.com>
Change-Id: Iec47952545c0072a71088b12ca3dc31673fa9c51
Diffstat (limited to 'src/profiling/backends')
-rw-r--r-- | src/profiling/backends/BackendProfiling.cpp | 37 | ||||
-rw-r--r-- | src/profiling/backends/BackendProfiling.hpp | 21 |
2 files changed, 45 insertions, 13 deletions
diff --git a/src/profiling/backends/BackendProfiling.cpp b/src/profiling/backends/BackendProfiling.cpp index a49122a7a1..884fb3f2ff 100644 --- a/src/profiling/backends/BackendProfiling.cpp +++ b/src/profiling/backends/BackendProfiling.cpp @@ -15,7 +15,7 @@ namespace profiling std::unique_ptr<IRegisterBackendCounters> BackendProfiling::GetCounterRegistrationInterface(uint16_t currentMaxGlobalCounterID) { - return std::make_unique<RegisterBackendCounters>(RegisterBackendCounters(currentMaxGlobalCounterID, m_backendId)); + return std::make_unique<RegisterBackendCounters>(RegisterBackendCounters(currentMaxGlobalCounterID, m_BackendId)); } std::unique_ptr<ISendTimelinePacket> BackendProfiling::GetSendTimelinePacket() @@ -29,14 +29,43 @@ IProfilingGuidGenerator& BackendProfiling::GetProfilingGuidGenerator() return m_ProfilingService; } -CounterStatus BackendProfiling::GetCounterStatus(uint16_t) +CounterStatus BackendProfiling::GetCounterStatus(uint16_t backendCounterId) { - return CounterStatus(); + uint16_t globalCounterId = m_ProfilingService.GetCounterMappings().GetGlobalId(backendCounterId, m_BackendId); + CaptureData captureData = m_ProfilingService.GetCaptureData(); + + CounterStatus counterStatus(backendCounterId, globalCounterId, false, 0); + + if (captureData.IsCounterIdInCaptureData(globalCounterId)) + { + counterStatus.m_Enabled = true; + counterStatus.m_SamplingRateInMicroseconds = captureData.GetCapturePeriod(); + } + + return counterStatus; } std::vector<CounterStatus> BackendProfiling::GetActiveCounters() { - return std::vector<CounterStatus>(); + CaptureData captureData = m_ProfilingService.GetCaptureData(); + + const std::vector<uint16_t>& globalCounterIds = captureData.GetCounterIds(); + std::vector<CounterStatus> activeCounterIds; + + for (auto globalCounterId : globalCounterIds) { + // Get pair of local counterId and backendId using globalCounterId + const std::pair<uint16_t, armnn::BackendId>& backendCounterIdPair = + ProfilingService::Instance().GetCounterMappings().GetBackendId(globalCounterId); + if (backendCounterIdPair.second == m_BackendId) + { + activeCounterIds.emplace_back(backendCounterIdPair.first, + globalCounterId, + true, + captureData.GetCapturePeriod()); + } + } + + return activeCounterIds; } bool BackendProfiling::IsProfilingEnabled() const diff --git a/src/profiling/backends/BackendProfiling.hpp b/src/profiling/backends/BackendProfiling.hpp index 2bc365a1de..e0e0f58e7d 100644 --- a/src/profiling/backends/BackendProfiling.hpp +++ b/src/profiling/backends/BackendProfiling.hpp @@ -3,7 +3,9 @@ // SPDX-License-Identifier: MIT // -#include <ProfilingService.hpp> +#pragma once + +#include "ProfilingService.hpp" #include <armnn/backends/profiling/IBackendProfiling.hpp> namespace armnn @@ -15,17 +17,18 @@ 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(const IRuntime::CreationOptions& options, + ProfilingService& profilingService, + const BackendId& backendId) + : m_Options(options), + m_ProfilingService(profilingService), + m_BackendId(backendId) {} ~BackendProfiling() {} std::unique_ptr<IRegisterBackendCounters> - GetCounterRegistrationInterface(uint16_t currentMaxGlobalCounterID) override; + GetCounterRegistrationInterface(uint16_t currentMaxGlobalCounterID) override; std::unique_ptr<ISendTimelinePacket> GetSendTimelinePacket() override; @@ -41,9 +44,9 @@ public: bool IsProfilingEnabled() const override; private: - IRuntime::CreationOptions m_options; + IRuntime::CreationOptions m_Options; ProfilingService& m_ProfilingService; - BackendId m_backendId; + BackendId m_BackendId; }; } // namespace profiling } // namespace armnn
\ No newline at end of file |