Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include "ProfilingStateMachine.hpp" |
| 9 | #include "ProfilingConnectionFactory.hpp" |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame] | 10 | #include "CounterDirectory.hpp" |
FinnWilliamsArm | f6e534a | 2019-09-16 15:45:42 +0100 | [diff] [blame^] | 11 | #include "CounterValues.hpp" |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
| 16 | namespace profiling |
| 17 | { |
| 18 | |
FinnWilliamsArm | f6e534a | 2019-09-16 15:45:42 +0100 | [diff] [blame^] | 19 | class ProfilingService : IWriteCounterValues |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 20 | { |
| 21 | public: |
| 22 | ProfilingService(const Runtime::CreationOptions::ExternalProfilingOptions& options); |
| 23 | ~ProfilingService() = default; |
| 24 | |
| 25 | void Run(); |
| 26 | |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame] | 27 | const ICounterDirectory& GetCounterDirectory() const; |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 28 | ProfilingState GetCurrentState() const; |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame] | 29 | void ResetExternalProfilingOptions(const Runtime::CreationOptions::ExternalProfilingOptions& options); |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 30 | |
FinnWilliamsArm | f6e534a | 2019-09-16 15:45:42 +0100 | [diff] [blame^] | 31 | uint16_t GetCounterCount() const; |
| 32 | void GetCounterValue(uint16_t index, uint32_t& value) const; |
| 33 | void SetCounterValue(uint16_t index, uint32_t value); |
| 34 | void AddCounterValue(uint16_t index, uint32_t value); |
| 35 | void SubtractCounterValue(uint16_t index, uint32_t value); |
| 36 | void IncrementCounterValue(uint16_t index); |
| 37 | void DecrementCounterValue(uint16_t index); |
| 38 | |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 39 | private: |
| 40 | void Initialise(); |
FinnWilliamsArm | f6e534a | 2019-09-16 15:45:42 +0100 | [diff] [blame^] | 41 | void CheckIndexSize(uint16_t counterIndex) const; |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 42 | |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame] | 43 | CounterDirectory m_CounterDirectory; |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 44 | ProfilingConnectionFactory m_Factory; |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame] | 45 | Runtime::CreationOptions::ExternalProfilingOptions m_Options; |
| 46 | ProfilingStateMachine m_State; |
FinnWilliamsArm | f6e534a | 2019-09-16 15:45:42 +0100 | [diff] [blame^] | 47 | |
| 48 | std::unordered_map<uint16_t, std::atomic<uint32_t>> m_CounterIdToValue; |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | } // namespace profiling |
| 52 | |
| 53 | } // namespace armnn |