Colm Donelan | e49755b | 2020-01-29 15:22:43 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | #pragma once |
| 6 | |
| 7 | #include <armnn/IRuntime.hpp> |
| 8 | #include <armnn/profiling/IProfilingGuidGenerator.hpp> |
| 9 | #include <armnn/profiling/ISendTimelinePacket.hpp> |
| 10 | #include <memory> |
| 11 | #include <vector> |
| 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
| 16 | namespace profiling |
| 17 | { |
| 18 | |
| 19 | struct CounterValue |
| 20 | { |
| 21 | uint16_t counterId; |
| 22 | uint32_t counterValue; |
| 23 | }; |
| 24 | |
| 25 | struct Timestamp |
| 26 | { |
| 27 | uint64_t timestamp; |
| 28 | std::vector<CounterValue> counterValues; |
| 29 | }; |
| 30 | |
| 31 | struct CounterStatus |
| 32 | { |
| 33 | uint16_t m_BackendCounterId; |
| 34 | uint16_t m_GlobalCounterId; |
| 35 | bool m_Enabled; |
| 36 | uint32_t m_SamplingRateInMicroseconds; |
| 37 | }; |
| 38 | |
| 39 | class IRegisterBackendCounters |
| 40 | { |
| 41 | public: |
Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame^] | 42 | virtual void RegisterCategory(const std::string& categoryName, |
| 43 | const Optional<uint16_t>& deviceUid = EmptyOptional(), |
| 44 | const Optional<uint16_t>& counterSetUid = EmptyOptional()) = 0; |
Colm Donelan | e49755b | 2020-01-29 15:22:43 +0000 | [diff] [blame] | 45 | |
Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame^] | 46 | virtual uint16_t RegisterDevice(const std::string& deviceName, |
| 47 | uint16_t cores = 0, |
| 48 | const Optional<std::string>& parentCategoryName = EmptyOptional()) = 0; |
Colm Donelan | e49755b | 2020-01-29 15:22:43 +0000 | [diff] [blame] | 49 | |
Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame^] | 50 | virtual uint16_t RegisterCounterSet(const std::string& counterSetName, |
| 51 | uint16_t count = 0, |
| 52 | const Optional<std::string>& parentCategoryName = EmptyOptional()) = 0; |
Colm Donelan | e49755b | 2020-01-29 15:22:43 +0000 | [diff] [blame] | 53 | |
Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame^] | 54 | virtual uint16_t RegisterCounter(const uint16_t uid, |
| 55 | const std::string& parentCategoryName, |
| 56 | uint16_t counterClass, |
| 57 | uint16_t interpolation, |
| 58 | double multiplier, |
| 59 | const std::string& name, |
| 60 | const std::string& description, |
| 61 | const Optional<std::string>& units = EmptyOptional(), |
| 62 | const Optional<uint16_t>& numberOfCores = EmptyOptional(), |
| 63 | const Optional<uint16_t>& deviceUid = EmptyOptional(), |
| 64 | const Optional<uint16_t>& counterSetUid = EmptyOptional()) = 0; |
| 65 | |
| 66 | virtual ~IRegisterBackendCounters() {} |
Colm Donelan | e49755b | 2020-01-29 15:22:43 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | class IBackendProfiling |
| 70 | { |
| 71 | protected: |
| 72 | IBackendProfiling(const IRuntime::CreationOptions&) |
| 73 | {} |
| 74 | |
| 75 | public: |
| 76 | virtual ~IBackendProfiling() |
| 77 | {} |
| 78 | |
Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame^] | 79 | IRegisterBackendCounters& GetCounterRegistrationInterface(uint16_t currentMaxGlobalCounterID); |
Colm Donelan | e49755b | 2020-01-29 15:22:43 +0000 | [diff] [blame] | 80 | |
| 81 | ISendTimelinePacket& GetSendTimelinePacket(); |
| 82 | |
| 83 | IProfilingGuidGenerator& GetProfilingGuidGenerator(); |
| 84 | |
| 85 | void ReportCounters(const std::vector<Timestamp>& counterValues); |
| 86 | |
| 87 | CounterStatus GetCounterStatus(uint16_t backendCounterId); |
| 88 | |
| 89 | std::vector<CounterStatus> GetActiveCounters(); |
| 90 | |
| 91 | bool IsProfilingEnabled() const; |
| 92 | }; |
| 93 | } // namespace profiling |
| 94 | } // namespace armnn |