aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/ProfilingService.hpp
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-10-02 12:50:57 +0100
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-10-07 10:34:54 +0100
commita84edee4702c112a6e004b1987acc11144e2d6dd (patch)
tree738ce957b2fa26423df188b0d370664d15c86665 /src/profiling/ProfilingService.hpp
parentd66d68b13fb309e8d4eac9435a58b89dd6a55158 (diff)
downloadarmnn-a84edee4702c112a6e004b1987acc11144e2d6dd.tar.gz
IVGCVSW-3937 Initial ServiceProfiling refactoring
* Made the ServiceProfiling class a singleton * Registered basic category and counters * Code refactoring * Updated unit tests accordingly Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: I648a6202eead2a3016aac14d905511bd945a90cb
Diffstat (limited to 'src/profiling/ProfilingService.hpp')
-rw-r--r--src/profiling/ProfilingService.hpp63
1 files changed, 44 insertions, 19 deletions
diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp
index 6d617978e5..36d95e0b5e 100644
--- a/src/profiling/ProfilingService.hpp
+++ b/src/profiling/ProfilingService.hpp
@@ -16,38 +16,63 @@ namespace armnn
namespace profiling
{
-class ProfilingService : IWriteCounterValues
+class ProfilingService final : public IReadWriteCounterValues
{
public:
- ProfilingService(const Runtime::CreationOptions::ExternalProfilingOptions& options);
- ~ProfilingService() = default;
+ using ExternalProfilingOptions = Runtime::CreationOptions::ExternalProfilingOptions;
+ using IProfilingConnectionPtr = std::unique_ptr<IProfilingConnection>;
+ using CounterIndices = std::vector<std::atomic<uint32_t>*>;
+ using CounterValues = std::list<std::atomic<uint32_t>>;
+
+ // Getter for the singleton instance
+ static ProfilingService& Instance()
+ {
+ static ProfilingService instance;
+ return instance;
+ }
+
+ // Resets the profiling options, optionally clears the profiling service entirely
+ void ResetExternalProfilingOptions(const ExternalProfilingOptions& options, bool resetProfilingService = false);
+ // Runs the profiling service
void Run();
+ // Getters for the profiling service state
const ICounterDirectory& GetCounterDirectory() const;
ProfilingState GetCurrentState() const;
- void ResetExternalProfilingOptions(const Runtime::CreationOptions::ExternalProfilingOptions& options);
+ uint16_t GetCounterCount() const override;
+ uint32_t GetCounterValue(uint16_t counterUid) const override;
- uint16_t GetCounterCount() const;
- void GetCounterValue(uint16_t index, uint32_t& value) const;
- void SetCounterValue(uint16_t index, uint32_t value);
- void AddCounterValue(uint16_t index, uint32_t value);
- void SubtractCounterValue(uint16_t index, uint32_t value);
- void IncrementCounterValue(uint16_t index);
- void DecrementCounterValue(uint16_t index);
+ // Setters for the profiling service state
+ void SetCounterValue(uint16_t counterUid, uint32_t value) override;
+ uint32_t AddCounterValue(uint16_t counterUid, uint32_t value) override;
+ uint32_t SubtractCounterValue(uint16_t counterUid, uint32_t value) override;
+ uint32_t IncrementCounterValue(uint16_t counterUid) override;
+ uint32_t DecrementCounterValue(uint16_t counterUid) override;
private:
- void Initialise();
- void CheckIndexSize(uint16_t counterIndex) const;
+ // Default/copy/move constructors/destructors and copy/move assignment operators are kept private
+ ProfilingService() = default;
+ ProfilingService(const ProfilingService&) = delete;
+ ProfilingService(ProfilingService&&) = delete;
+ ProfilingService& operator=(const ProfilingService&) = delete;
+ ProfilingService& operator=(ProfilingService&&) = delete;
+ ~ProfilingService() = default;
- CounterDirectory m_CounterDirectory;
- ProfilingConnectionFactory m_Factory;
- Runtime::CreationOptions::ExternalProfilingOptions m_Options;
- ProfilingStateMachine m_State;
+ // Initialization functions
+ void Initialize();
+ void InitializeCounterValue(uint16_t counterUid);
- std::unordered_map<uint16_t, std::atomic<uint32_t>> m_CounterIdToValue;
+ // Profiling service state variables
+ ExternalProfilingOptions m_Options;
+ CounterDirectory m_CounterDirectory;
+ ProfilingConnectionFactory m_ProfilingConnectionFactory;
+ IProfilingConnectionPtr m_ProfilingConnection;
+ ProfilingStateMachine m_StateMachine;
+ CounterIndices m_CounterIndex;
+ CounterValues m_CounterValues;
};
} // namespace profiling
-} // namespace armnn \ No newline at end of file
+} // namespace armnn