blob: d024516ab82173bbe74d6ff2b8abdeb3a15e48fc [file] [log] [blame]
Matteo Martincigh6db5f202019-09-05 12:02:04 +01001//
2// Copyright © 2019 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
Jim Flynn34430252022-03-04 15:03:58 +00008#include "Counter.hpp"
Keith Davise394bd92019-12-02 15:12:19 +00009
Matteo Martincigh6db5f202019-09-05 12:02:04 +010010#include <string>
11#include <vector>
12#include <memory>
13#include <unordered_set>
14#include <unordered_map>
15
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000016namespace arm
Matteo Martincigh6db5f202019-09-05 12:02:04 +010017{
18
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000019namespace pipe
Matteo Martincigh6db5f202019-09-05 12:02:04 +010020{
21
22// Forward declarations
23class Category;
24class Device;
25class CounterSet;
Matteo Martincigh6db5f202019-09-05 12:02:04 +010026
27// Profiling objects smart pointer types
28using CategoryPtr = std::unique_ptr<Category>;
29using DevicePtr = std::unique_ptr<Device>;
30using CounterSetPtr = std::unique_ptr<CounterSet>;
31using CounterPtr = std::shared_ptr<Counter>;
32
33// Profiling objects collection types
34using Categories = std::unordered_set<CategoryPtr>;
35using Devices = std::unordered_map<uint16_t, DevicePtr>;
36using CounterSets = std::unordered_map<uint16_t, CounterSetPtr>;
37using Counters = std::unordered_map<uint16_t, CounterPtr>;
38
39// Profiling objects collection iterator types
40using CategoriesIt = Categories::const_iterator;
41using DevicesIt = Devices::const_iterator;
42using CounterSetsIt = CounterSets::const_iterator;
43using CountersIt = Counters::const_iterator;
44
45class Category final
46{
47public:
48 // Constructors
Sadik Armagan4c998992020-02-25 12:44:44 +000049 Category(const std::string& name)
Matteo Martincigh6db5f202019-09-05 12:02:04 +010050 : m_Name(name)
Matteo Martincigh6db5f202019-09-05 12:02:04 +010051 {}
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 Martincigh6db5f202019-09-05 12:02:04 +010058};
59
60class Device final
61{
62public:
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
76class CounterSet final
77{
78public:
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 Martincigh6db5f202019-09-05 12:02:04 +010092class ICounterDirectory
93{
94public:
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 Corbett5aa9fd72022-02-25 15:33:28 +0000116} // namespace pipe
Matteo Martincigh6db5f202019-09-05 12:02:04 +0100117
Cathal Corbett5aa9fd72022-02-25 15:33:28 +0000118} // namespace arm