Matteo Martincigh | 6db5f20 | 2019-09-05 12:02:04 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2019 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
Jim Flynn | 3443025 | 2022-03-04 15:03:58 +0000 | [diff] [blame] | 8 | #include "Counter.hpp" |
Keith Davis | e394bd9 | 2019-12-02 15:12:19 +0000 | [diff] [blame] | 9 | |
Matteo Martincigh | 6db5f20 | 2019-09-05 12:02:04 +0100 | [diff] [blame] | 10 | #include <string> |
| 11 | #include <vector> |
| 12 | #include <memory> |
| 13 | #include <unordered_set> |
| 14 | #include <unordered_map> |
| 15 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 16 | namespace arm |
Matteo Martincigh | 6db5f20 | 2019-09-05 12:02:04 +0100 | [diff] [blame] | 17 | { |
| 18 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 19 | namespace pipe |
Matteo Martincigh | 6db5f20 | 2019-09-05 12:02:04 +0100 | [diff] [blame] | 20 | { |
| 21 | |
| 22 | // Forward declarations |
| 23 | class Category; |
| 24 | class Device; |
| 25 | class CounterSet; |
Matteo Martincigh | 6db5f20 | 2019-09-05 12:02:04 +0100 | [diff] [blame] | 26 | |
| 27 | // Profiling objects smart pointer types |
| 28 | using CategoryPtr = std::unique_ptr<Category>; |
| 29 | using DevicePtr = std::unique_ptr<Device>; |
| 30 | using CounterSetPtr = std::unique_ptr<CounterSet>; |
| 31 | using CounterPtr = std::shared_ptr<Counter>; |
| 32 | |
| 33 | // Profiling objects collection types |
| 34 | using Categories = std::unordered_set<CategoryPtr>; |
| 35 | using Devices = std::unordered_map<uint16_t, DevicePtr>; |
| 36 | using CounterSets = std::unordered_map<uint16_t, CounterSetPtr>; |
| 37 | using Counters = std::unordered_map<uint16_t, CounterPtr>; |
| 38 | |
| 39 | // Profiling objects collection iterator types |
| 40 | using CategoriesIt = Categories::const_iterator; |
| 41 | using DevicesIt = Devices::const_iterator; |
| 42 | using CounterSetsIt = CounterSets::const_iterator; |
| 43 | using CountersIt = Counters::const_iterator; |
| 44 | |
| 45 | class Category final |
| 46 | { |
| 47 | public: |
| 48 | // Constructors |
Sadik Armagan | 4c99899 | 2020-02-25 12:44:44 +0000 | [diff] [blame] | 49 | Category(const std::string& name) |
Matteo Martincigh | 6db5f20 | 2019-09-05 12:02:04 +0100 | [diff] [blame] | 50 | : m_Name(name) |
Matteo Martincigh | 6db5f20 | 2019-09-05 12:02:04 +0100 | [diff] [blame] | 51 | {} |
| 52 | |
| 53 | // Fields |
| 54 | std::string m_Name; |
| 55 | |
| 56 | // Connections |
| 57 | std::vector<uint16_t> m_Counters; // The UIDs of the counters associated with this category |
Matteo Martincigh | 6db5f20 | 2019-09-05 12:02:04 +0100 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | class Device final |
| 61 | { |
| 62 | public: |
| 63 | // Constructors |
| 64 | Device(uint16_t deviceUid, const std::string& name, uint16_t cores) |
| 65 | : m_Uid(deviceUid) |
| 66 | , m_Name(name) |
| 67 | , m_Cores(cores) |
| 68 | {} |
| 69 | |
| 70 | // Fields |
| 71 | uint16_t m_Uid; |
| 72 | std::string m_Name; |
| 73 | uint16_t m_Cores; |
| 74 | }; |
| 75 | |
| 76 | class CounterSet final |
| 77 | { |
| 78 | public: |
| 79 | // Constructors |
| 80 | CounterSet(uint16_t counterSetUid, const std::string& name, uint16_t count) |
| 81 | : m_Uid(counterSetUid) |
| 82 | , m_Name(name) |
| 83 | , m_Count(count) |
| 84 | {} |
| 85 | |
| 86 | // Fields |
| 87 | uint16_t m_Uid; |
| 88 | std::string m_Name; |
| 89 | uint16_t m_Count; |
| 90 | }; |
| 91 | |
Matteo Martincigh | 6db5f20 | 2019-09-05 12:02:04 +0100 | [diff] [blame] | 92 | class ICounterDirectory |
| 93 | { |
| 94 | public: |
| 95 | virtual ~ICounterDirectory() {} |
| 96 | |
| 97 | // Getters for counts |
| 98 | virtual uint16_t GetCategoryCount() const = 0; |
| 99 | virtual uint16_t GetDeviceCount() const = 0; |
| 100 | virtual uint16_t GetCounterSetCount() const = 0; |
| 101 | virtual uint16_t GetCounterCount() const = 0; |
| 102 | |
| 103 | // Getters for collections |
| 104 | virtual const Categories& GetCategories() const = 0; |
| 105 | virtual const Devices& GetDevices() const = 0; |
| 106 | virtual const CounterSets& GetCounterSets() const = 0; |
| 107 | virtual const Counters& GetCounters() const = 0; |
| 108 | |
| 109 | // Getters for profiling objects |
| 110 | virtual const Category* GetCategory(const std::string& name) const = 0; |
| 111 | virtual const Device* GetDevice(uint16_t uid) const = 0; |
| 112 | virtual const CounterSet* GetCounterSet(uint16_t uid) const = 0; |
| 113 | virtual const Counter* GetCounter(uint16_t uid) const = 0; |
| 114 | }; |
| 115 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 116 | } // namespace pipe |
Matteo Martincigh | 6db5f20 | 2019-09-05 12:02:04 +0100 | [diff] [blame] | 117 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 118 | } // namespace arm |