Aron Virginas-Tar | 4e5fc1f | 2019-08-22 18:10:52 +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 <atomic> |
| 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
| 12 | namespace armnn |
| 13 | { |
| 14 | |
| 15 | namespace profiling |
| 16 | { |
| 17 | |
Matteo Martincigh | 149528e | 2019-09-05 12:02:04 +0100 | [diff] [blame^] | 18 | class Category |
| 19 | { |
| 20 | public: |
| 21 | std::string m_Name; |
| 22 | }; |
| 23 | |
Aron Virginas-Tar | 4e5fc1f | 2019-08-22 18:10:52 +0100 | [diff] [blame] | 24 | class Device |
| 25 | { |
| 26 | public: |
| 27 | uint16_t m_Uid; |
| 28 | std::string m_Name; |
| 29 | uint16_t m_Cores; |
| 30 | }; |
| 31 | |
| 32 | class Counter |
| 33 | { |
| 34 | public: |
| 35 | uint16_t m_Uid; |
| 36 | uint16_t m_MaxCounterUid; |
| 37 | uint16_t m_Class; |
| 38 | uint16_t m_Interpolation; |
| 39 | float m_Multiplier; |
| 40 | std::string m_Name; |
| 41 | std::string m_Description; |
| 42 | std::string m_Units; |
| 43 | }; |
| 44 | |
Matteo Martincigh | 149528e | 2019-09-05 12:02:04 +0100 | [diff] [blame^] | 45 | class CounterSet |
Aron Virginas-Tar | 4e5fc1f | 2019-08-22 18:10:52 +0100 | [diff] [blame] | 46 | { |
| 47 | public: |
Matteo Martincigh | 149528e | 2019-09-05 12:02:04 +0100 | [diff] [blame^] | 48 | uint16_t m_Uid; |
Aron Virginas-Tar | 4e5fc1f | 2019-08-22 18:10:52 +0100 | [diff] [blame] | 49 | std::string m_Name; |
Matteo Martincigh | 149528e | 2019-09-05 12:02:04 +0100 | [diff] [blame^] | 50 | uint16_t m_Count; |
Aron Virginas-Tar | 4e5fc1f | 2019-08-22 18:10:52 +0100 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | class CounterDirectory final |
| 54 | { |
| 55 | public: |
| 56 | CounterDirectory(uint16_t uid, |
| 57 | const std::string& name, |
| 58 | uint16_t deviceCount, |
| 59 | uint16_t counterCount, |
| 60 | uint16_t categoryCount); |
| 61 | |
| 62 | ~CounterDirectory() = default; |
| 63 | |
| 64 | uint16_t GetUid() const; |
| 65 | const std::string& GetName() const; |
| 66 | |
| 67 | uint16_t GetDeviceCount() const; |
| 68 | uint16_t GetCounterCount() const; |
| 69 | uint16_t GetCategoryCount() const; |
| 70 | |
| 71 | void GetDeviceValue(uint16_t index, uint32_t& value) const; |
| 72 | void SetDeviceValue(uint16_t index, uint32_t value); |
| 73 | |
| 74 | void GetDeviceObject(uint16_t index, Device* counter) const; |
| 75 | void SetDeviceObject(uint16_t index, Device* counter); |
| 76 | |
| 77 | void GetCounterValue(uint16_t index, uint32_t& value) const; |
| 78 | void SetCounterValue(uint16_t index, uint32_t value); |
| 79 | |
| 80 | void GetCounterObject(uint16_t index, Counter* counter) const; |
| 81 | void SetCounterObject(uint16_t index, Counter* counter); |
| 82 | |
| 83 | void GetCategoryValue(uint16_t index, uint32_t& value) const; |
| 84 | void SetCategoryValue(uint16_t index, uint32_t value); |
| 85 | |
| 86 | void GetCategoryObject(uint16_t index, Category* counter) const; |
| 87 | void SetCategoryObject(uint16_t index, Category* counter); |
| 88 | |
| 89 | private: |
| 90 | uint16_t m_Uid; |
| 91 | std::string m_Name; |
| 92 | |
| 93 | uint16_t m_DeviceCount; |
| 94 | uint16_t m_CounterCount; |
| 95 | uint16_t m_CategoryCount; |
| 96 | |
| 97 | std::vector<std::atomic<uint32_t>> m_DeviceIds; |
| 98 | std::vector<std::atomic<uint32_t>> m_CounterIds; |
| 99 | std::vector<std::atomic<uint32_t>> m_CategoryIds; |
| 100 | |
| 101 | std::vector<std::atomic<Device*>> m_DeviceObjects; |
| 102 | std::vector<std::atomic<Counter*>> m_CounterObjects; |
| 103 | std::vector<std::atomic<Category*>> m_CategoryObjects; |
| 104 | |
| 105 | void CheckDeviceIndex(uint16_t index) const; |
| 106 | void CheckCounterIndex(uint16_t index) const; |
| 107 | void CheckCategoryIndex(uint16_t index) const; |
| 108 | }; |
| 109 | |
| 110 | } // namespace profiling |
| 111 | |
| 112 | } // namespace armnn |