Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "RegisterBackendCounters.hpp" |
| 7 | |
| 8 | namespace armnn |
| 9 | { |
| 10 | |
| 11 | namespace profiling |
| 12 | { |
| 13 | |
Sadik Armagan | 4c99899 | 2020-02-25 12:44:44 +0000 | [diff] [blame] | 14 | void RegisterBackendCounters::RegisterCategory(const std::string& categoryName) |
Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame] | 15 | { |
Sadik Armagan | 4c99899 | 2020-02-25 12:44:44 +0000 | [diff] [blame] | 16 | m_CounterDirectory.RegisterCategory(categoryName); |
Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | uint16_t RegisterBackendCounters::RegisterDevice(const std::string& deviceName, |
| 20 | uint16_t cores, |
| 21 | const Optional<std::string>& parentCategoryName) |
| 22 | { |
| 23 | const Device* devicePtr = m_CounterDirectory.RegisterDevice(deviceName, cores, parentCategoryName); |
| 24 | return devicePtr->m_Uid; |
| 25 | } |
| 26 | |
| 27 | uint16_t RegisterBackendCounters::RegisterCounterSet(const std::string& counterSetName, |
| 28 | uint16_t count, |
| 29 | const Optional<std::string>& parentCategoryName) |
| 30 | { |
| 31 | const CounterSet* counterSetPtr = m_CounterDirectory.RegisterCounterSet(counterSetName, count, parentCategoryName); |
| 32 | return counterSetPtr->m_Uid; |
| 33 | } |
| 34 | |
| 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 Optional<std::string>& units, |
| 43 | const Optional<uint16_t>& numberOfCores, |
| 44 | const Optional<uint16_t>& deviceUid, |
| 45 | const 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 |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 62 | IRegisterCounterMapping& counterIdMap = m_ProfilingService.GetCounterMappingRegistry(); |
Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame] | 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 profiling |
| 84 | |
| 85 | } // namespace armnn |