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