1 // 2 // Copyright © 2019 Arm Ltd. All rights reserved. 3 // SPDX-License-Identifier: MIT 4 // 5 6 #pragma once 7 8 #include "Counter.hpp" 9 10 #include <string> 11 #include <vector> 12 #include <memory> 13 #include <unordered_set> 14 #include <unordered_map> 15 16 namespace arm 17 { 18 19 namespace pipe 20 { 21 22 // Forward declarations 23 class Category; 24 class Device; 25 class CounterSet; 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 Category(const std::string & name)49 Category(const std::string& name) 50 : m_Name(name) 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 58 }; 59 60 class Device final 61 { 62 public: 63 // Constructors Device(uint16_t deviceUid,const std::string & name,uint16_t cores)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 CounterSet(uint16_t counterSetUid,const std::string & name,uint16_t count)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 92 class ICounterDirectory 93 { 94 public: ~ICounterDirectory()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 116 } // namespace pipe 117 118 } // namespace arm 119