1 //
2 // Copyright © 2020 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include "RegisterBackendCounters.hpp"
7
8 namespace arm
9 {
10
11 namespace pipe
12 {
13
RegisterCategory(const std::string & categoryName)14 void RegisterBackendCounters::RegisterCategory(const std::string& categoryName)
15 {
16 m_CounterDirectory.RegisterCategory(categoryName);
17 }
18
RegisterDevice(const std::string & deviceName,uint16_t cores,const arm::pipe::Optional<std::string> & parentCategoryName)19 uint16_t RegisterBackendCounters::RegisterDevice(const std::string& deviceName,
20 uint16_t cores,
21 const arm::pipe::Optional<std::string>& parentCategoryName)
22 {
23 const Device* devicePtr = m_CounterDirectory.RegisterDevice(deviceName, cores, parentCategoryName);
24 return devicePtr->m_Uid;
25 }
26
RegisterCounterSet(const std::string & counterSetName,uint16_t count,const arm::pipe::Optional<std::string> & parentCategoryName)27 uint16_t RegisterBackendCounters::RegisterCounterSet(const std::string& counterSetName,
28 uint16_t count,
29 const arm::pipe::Optional<std::string>& parentCategoryName)
30 {
31 const CounterSet* counterSetPtr = m_CounterDirectory.RegisterCounterSet(counterSetName, count, parentCategoryName);
32 return counterSetPtr->m_Uid;
33 }
34
RegisterCounter(const uint16_t uid,const std::string & parentCategoryName,uint16_t counterClass,uint16_t interpolation,double multiplier,const std::string & name,const std::string & description,const arm::pipe::Optional<std::string> & units,const arm::pipe::Optional<uint16_t> & numberOfCores,const arm::pipe::Optional<uint16_t> & deviceUid,const arm::pipe::Optional<uint16_t> & counterSetUid)35 uint16_t RegisterBackendCounters::RegisterCounter(const uint16_t uid,
36 const std::string& parentCategoryName,
37 uint16_t counterClass,
38 uint16_t interpolation,
39 double multiplier,
40 const std::string& name,
41 const std::string& description,
42 const arm::pipe::Optional<std::string>& units,
43 const arm::pipe::Optional<uint16_t>& numberOfCores,
44 const arm::pipe::Optional<uint16_t>& deviceUid,
45 const arm::pipe::Optional<uint16_t>& counterSetUid)
46 {
47 ++m_CurrentMaxGlobalCounterID;
48 const Counter* counterPtr = m_CounterDirectory.RegisterCounter(m_BackendId,
49 m_CurrentMaxGlobalCounterID,
50 parentCategoryName,
51 counterClass,
52 interpolation,
53 multiplier,
54 name,
55 description,
56 units,
57 numberOfCores,
58 deviceUid,
59 counterSetUid);
60 m_CurrentMaxGlobalCounterID = counterPtr->m_MaxCounterUid;
61 // register mappings
62 IRegisterCounterMapping& counterIdMap = m_ProfilingService.GetCounterMappingRegistry();
63 uint16_t globalCounterId = counterPtr->m_Uid;
64 if (globalCounterId == counterPtr->m_MaxCounterUid)
65 {
66 counterIdMap.RegisterMapping(globalCounterId, uid, m_BackendId);
67 }
68 else
69 {
70 uint16_t backendCounterId = uid;
71 while (globalCounterId <= counterPtr->m_MaxCounterUid)
72 {
73 // register mapping
74 // globalCounterId -> backendCounterId, m_BackendId
75 counterIdMap.RegisterMapping(globalCounterId, backendCounterId, m_BackendId);
76 ++globalCounterId;
77 ++backendCounterId;
78 }
79 }
80 return m_CurrentMaxGlobalCounterID;
81 }
82
83 } // namespace pipe
84
85 } // namespace arm
86