From e394bd99f1a55e099445823b7a951f0faa84d439 Mon Sep 17 00:00:00 2001 From: Keith Davis Date: Mon, 2 Dec 2019 15:12:19 +0000 Subject: IVGCVSW-4178 Add code to increment the 3 ArmNN counters * Increment at Runtime.cpp | BackendRegistry.cpp | LoadedNetwork.cpp * Update unit tests * UID generation is now handled by backends Signed-off-by: Keith Davis Change-Id: Ifa53763409078c14839675206d8b260cdc36a8df --- include/armnn/BackendId.hpp | 6 + src/armnn/BackendRegistry.cpp | 10 +- src/armnn/LoadedNetwork.cpp | 4 + src/armnn/Runtime.cpp | 9 + src/profiling/CounterDirectory.cpp | 9 +- src/profiling/CounterDirectory.hpp | 23 +- src/profiling/DirectoryCaptureCommandHandler.cpp | 19 +- src/profiling/ICounterDirectory.hpp | 9 +- src/profiling/ICounterValues.hpp | 1 - src/profiling/ProfilingService.cpp | 70 ++++-- src/profiling/ProfilingService.hpp | 10 +- src/profiling/ProfilingUtils.cpp | 10 +- src/profiling/ProfilingUtils.hpp | 2 +- src/profiling/test/ProfilingTests.cpp | 287 +++++++++++++++++------ src/profiling/test/SendCounterPacketTests.cpp | 51 ++-- src/profiling/test/SendCounterPacketTests.hpp | 9 +- 16 files changed, 391 insertions(+), 138 deletions(-) diff --git a/include/armnn/BackendId.hpp b/include/armnn/BackendId.hpp index d7b54979b6..36f298741c 100644 --- a/include/armnn/BackendId.hpp +++ b/include/armnn/BackendId.hpp @@ -165,6 +165,12 @@ struct hash namespace armnn { +namespace profiling +{ + // Static constant describing ArmNN as a dummy backend + static const BackendId BACKEND_ID("ARMNN"); +} // profiling + inline std::ostream& operator<<(std::ostream& os, const BackendId& id) { os << id.Get(); diff --git a/src/armnn/BackendRegistry.cpp b/src/armnn/BackendRegistry.cpp index dc3e2bc254..35e82f2e67 100644 --- a/src/armnn/BackendRegistry.cpp +++ b/src/armnn/BackendRegistry.cpp @@ -5,6 +5,7 @@ #include #include +#include namespace armnn { @@ -23,12 +24,19 @@ void BackendRegistry::Register(const BackendId& id, BackendRegistry::FactoryFunc std::string(id) + " already registered as IBackend factory", CHECK_LOCATION()); } - + if (profiling::ProfilingService::Instance().IsProfilingEnabled()) + { + profiling::ProfilingService::Instance().IncrementCounterValue(armnn::profiling::REGISTERED_BACKENDS); + } m_Factories[id] = factory; } void BackendRegistry::Deregister(const BackendId& id) { + if (profiling::ProfilingService::Instance().IsProfilingEnabled()) + { + profiling::ProfilingService::Instance().IncrementCounterValue(armnn::profiling::UNREGISTERED_BACKENDS); + } m_Factories.erase(id); } diff --git a/src/armnn/LoadedNetwork.cpp b/src/armnn/LoadedNetwork.cpp index c0f3fec3f5..e915d36e7b 100644 --- a/src/armnn/LoadedNetwork.cpp +++ b/src/armnn/LoadedNetwork.cpp @@ -462,6 +462,10 @@ Status LoadedNetwork::EnqueueWorkload(const InputTensors& inputTensors, bool executionSucceeded = true; { + if (profiling::ProfilingService::Instance().IsProfilingEnabled()) + { + profiling::ProfilingService::Instance().IncrementCounterValue(armnn::profiling::INFERENCES_RUN); + } ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Execute"); ARMNN_SCOPED_HEAP_PROFILING("Executing"); executionSucceeded = Execute(timelineUtils, inferenceGuid); diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp index 4ad6fa59a0..1e3e232046 100644 --- a/src/armnn/Runtime.cpp +++ b/src/armnn/Runtime.cpp @@ -92,6 +92,11 @@ Status Runtime::LoadNetwork(NetworkId& networkIdOut, context.second->AfterLoadNetwork(networkIdOut); } + if (profiling::ProfilingService::Instance().IsProfilingEnabled()) + { + profiling::ProfilingService::Instance().IncrementCounterValue(armnn::profiling::NETWORK_LOADS); + } + return Status::Success; } @@ -118,6 +123,10 @@ Status Runtime::UnloadNetwork(NetworkId networkId) ARMNN_LOG(warning) << "WARNING: Runtime::UnloadNetwork(): " << networkId << " not found!"; return Status::Failure; } + if (profiling::ProfilingService::Instance().IsProfilingEnabled()) + { + profiling::ProfilingService::Instance().IncrementCounterValue(armnn::profiling::NETWORK_UNLOADS); + } } for (auto&& context : m_BackendContexts) diff --git a/src/profiling/CounterDirectory.cpp b/src/profiling/CounterDirectory.cpp index 979b8046be..5a69e1c802 100644 --- a/src/profiling/CounterDirectory.cpp +++ b/src/profiling/CounterDirectory.cpp @@ -272,7 +272,9 @@ const CounterSet* CounterDirectory::RegisterCounterSet(const std::string& counte return counterSetPtr; } -const Counter* CounterDirectory::RegisterCounter(const std::string& parentCategoryName, +const Counter* CounterDirectory::RegisterCounter(const BackendId& backendId, + const uint16_t uid, + const std::string& parentCategoryName, uint16_t counterClass, uint16_t interpolation, double multiplier, @@ -379,7 +381,7 @@ const Counter* CounterDirectory::RegisterCounter(const std::string& parentCatego uint16_t deviceCores = GetNumberOfCores(numberOfCores, deviceUidValue, parentCategory); // Get the counter UIDs and calculate the max counter UID - std::vector counterUids = GetNextCounterUids(deviceCores); + std::vector counterUids = GetNextCounterUids(uid, deviceCores); BOOST_ASSERT(!counterUids.empty()); uint16_t maxCounterUid = deviceCores <= 1 ? counterUids.front() : counterUids.back(); @@ -387,7 +389,8 @@ const Counter* CounterDirectory::RegisterCounter(const std::string& parentCatego const std::string unitsValue = units.has_value() ? units.value() : ""; // Create the counter - CounterPtr counter = std::make_shared(counterUids.front(), + CounterPtr counter = std::make_shared(armnn::profiling::BACKEND_ID, + counterUids.front(), maxCounterUid, counterClass, interpolation, diff --git a/src/profiling/CounterDirectory.hpp b/src/profiling/CounterDirectory.hpp index bff5cfef98..b0ddbcea3f 100644 --- a/src/profiling/CounterDirectory.hpp +++ b/src/profiling/CounterDirectory.hpp @@ -8,6 +8,7 @@ #include "ICounterDirectory.hpp" #include +#include #include #include @@ -37,16 +38,18 @@ public: const CounterSet* RegisterCounterSet(const std::string& counterSetName, uint16_t count = 0, const Optional& parentCategoryName = EmptyOptional()); - const Counter* RegisterCounter (const std::string& parentCategoryName, - uint16_t counterClass, - uint16_t interpolation, - double multiplier, - const std::string& name, - const std::string& description, - const Optional& units = EmptyOptional(), - const Optional& numberOfCores = EmptyOptional(), - const Optional& deviceUid = EmptyOptional(), - const Optional& counterSetUid = EmptyOptional()); + const Counter* RegisterCounter(const BackendId& backendId, + 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 Optional& units = EmptyOptional(), + const Optional& numberOfCores = EmptyOptional(), + const Optional& deviceUid = EmptyOptional(), + const Optional& counterSetUid = EmptyOptional()); // Getters for counts uint16_t GetCategoryCount() const override { return boost::numeric_cast(m_Categories.size()); } diff --git a/src/profiling/DirectoryCaptureCommandHandler.cpp b/src/profiling/DirectoryCaptureCommandHandler.cpp index 65a7880d50..f221513572 100644 --- a/src/profiling/DirectoryCaptureCommandHandler.cpp +++ b/src/profiling/DirectoryCaptureCommandHandler.cpp @@ -2,11 +2,12 @@ // Copyright © 2019 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // - -#include #include "DirectoryCaptureCommandHandler.hpp" -#include "SendCounterPacket.hpp" +#include +#include "ProfilingUtils.hpp" + +#include #include namespace armnn @@ -199,9 +200,15 @@ void DirectoryCaptureCommandHandler::ReadCategoryRecords(const unsigned char* co GetStringNameFromBuffer(data, categoryRecordOffset + nameOffset), deviceUid, counterSetUid); for (auto& counter : eventRecords) { - const Counter* registeredCounter = m_CounterDirectory.RegisterCounter( - category->m_Name, counter.m_CounterClass, counter.m_CounterInterpolation, counter.m_CounterMultiplier, - counter.m_CounterName, counter.m_CounterDescription, counter.m_CounterUnits); + const Counter* registeredCounter = m_CounterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + counter.m_CounterUid, + category->m_Name, + counter.m_CounterClass, + counter.m_CounterInterpolation, + counter.m_CounterMultiplier, + counter.m_CounterName, + counter.m_CounterDescription, + counter.m_CounterUnits); m_UidTranslation[registeredCounter->m_Uid] = counter.m_CounterUid; } } diff --git a/src/profiling/ICounterDirectory.hpp b/src/profiling/ICounterDirectory.hpp index c7259ab041..4f82b2e6e4 100644 --- a/src/profiling/ICounterDirectory.hpp +++ b/src/profiling/ICounterDirectory.hpp @@ -5,6 +5,8 @@ #pragma once +#include + #include #include #include @@ -98,7 +100,8 @@ class Counter final { public: // Constructors - Counter(uint16_t counterUid, + Counter(BackendId backendId, + uint16_t counterUid, uint16_t maxCounterUid, uint16_t counterClass, uint16_t interpolation, @@ -108,7 +111,8 @@ public: const std::string& units, uint16_t deviceUid, uint16_t counterSetUid) - : m_Uid(counterUid) + : m_BackendId(backendId) + , m_Uid(counterUid) , m_MaxCounterUid(maxCounterUid) , m_Class(counterClass) , m_Interpolation(interpolation) @@ -121,6 +125,7 @@ public: {} // Fields + BackendId m_BackendId; uint16_t m_Uid; uint16_t m_MaxCounterUid; uint16_t m_Class; diff --git a/src/profiling/ICounterValues.hpp b/src/profiling/ICounterValues.hpp index 18e34b6747..cef02668f6 100644 --- a/src/profiling/ICounterValues.hpp +++ b/src/profiling/ICounterValues.hpp @@ -32,7 +32,6 @@ public: virtual uint32_t AddCounterValue(uint16_t counterUid, uint32_t value) = 0; virtual uint32_t SubtractCounterValue(uint16_t counterUid, uint32_t value) = 0; virtual uint32_t IncrementCounterValue(uint16_t counterUid) = 0; - virtual uint32_t DecrementCounterValue(uint16_t counterUid) = 0; }; class IReadWriteCounterValues : public IReadCounterValues, public IWriteCounterValues diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp index 409e71dfa0..9119597ceb 100644 --- a/src/profiling/ProfilingService.cpp +++ b/src/profiling/ProfilingService.cpp @@ -5,6 +5,7 @@ #include "ProfilingService.hpp" +#include #include #include @@ -29,6 +30,11 @@ void ProfilingService::ResetExternalProfilingOptions(const ExternalProfilingOpti } } +bool ProfilingService::IsProfilingEnabled() +{ + return m_Options.m_EnableProfiling; +} + ProfilingState ProfilingService::ConfigureProfilingService( const ExternalProfilingOptions& options, bool resetProfilingService) @@ -235,14 +241,6 @@ uint32_t ProfilingService::IncrementCounterValue(uint16_t counterUid) return counterValuePtr->operator++(std::memory_order::memory_order_relaxed); } -uint32_t ProfilingService::DecrementCounterValue(uint16_t counterUid) -{ - CheckCounterUid(counterUid); - std::atomic* counterValuePtr = m_CounterIndex.at(counterUid); - BOOST_ASSERT(counterValuePtr); - return counterValuePtr->operator--(std::memory_order::memory_order_relaxed); -} - ProfilingDynamicGuid ProfilingService::NextGuid() { return m_GuidGenerator.NextGuid(); @@ -266,41 +264,77 @@ void ProfilingService::Initialize() m_CounterDirectory.RegisterCategory("ArmNN_Runtime"); } - // Register a counter for the number of loaded networks - if (!m_CounterDirectory.IsCounterRegistered("Loaded networks")) + // Register a counter for the number of Network loads + if (!m_CounterDirectory.IsCounterRegistered("Network loads")) { const Counter* loadedNetworksCounter = - m_CounterDirectory.RegisterCounter("ArmNN_Runtime", + m_CounterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + armnn::profiling::NETWORK_LOADS, + "ArmNN_Runtime", 0, 0, 1.f, - "Loaded networks", + "Network loads", "The number of networks loaded at runtime", std::string("networks")); BOOST_ASSERT(loadedNetworksCounter); InitializeCounterValue(loadedNetworksCounter->m_Uid); } - + // Register a counter for the number of unloaded networks + if (!m_CounterDirectory.IsCounterRegistered("Network unloads")) + { + const Counter* unloadedNetworksCounter = + m_CounterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + armnn::profiling::NETWORK_UNLOADS, + "ArmNN_Runtime", + 0, + 0, + 1.f, + "Network unloads", + "The number of networks unloaded at runtime", + std::string("networks")); + BOOST_ASSERT(unloadedNetworksCounter); + InitializeCounterValue(unloadedNetworksCounter->m_Uid); + } // Register a counter for the number of registered backends - if (!m_CounterDirectory.IsCounterRegistered("Registered backends")) + if (!m_CounterDirectory.IsCounterRegistered("Backends registered")) { const Counter* registeredBackendsCounter = - m_CounterDirectory.RegisterCounter("ArmNN_Runtime", + m_CounterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + armnn::profiling::REGISTERED_BACKENDS, + "ArmNN_Runtime", 0, 0, 1.f, - "Registered backends", + "Backends registered", "The number of registered backends", std::string("backends")); BOOST_ASSERT(registeredBackendsCounter); InitializeCounterValue(registeredBackendsCounter->m_Uid); } - + // Register a counter for the number of registered backends + if (!m_CounterDirectory.IsCounterRegistered("Backends unregistered")) + { + const Counter* unregisteredBackendsCounter = + m_CounterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + armnn::profiling::UNREGISTERED_BACKENDS, + "ArmNN_Runtime", + 0, + 0, + 1.f, + "Backends unregistered", + "The number of unregistered backends", + std::string("backends")); + BOOST_ASSERT(unregisteredBackendsCounter); + InitializeCounterValue(unregisteredBackendsCounter->m_Uid); + } // Register a counter for the number of inferences run if (!m_CounterDirectory.IsCounterRegistered("Inferences run")) { const Counter* inferencesRunCounter = - m_CounterDirectory.RegisterCounter("ArmNN_Runtime", + m_CounterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + armnn::profiling::INFERENCES_RUN, + "ArmNN_Runtime", 0, 0, 1.f, diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp index dd75d053c9..746edb8a6c 100644 --- a/src/profiling/ProfilingService.hpp +++ b/src/profiling/ProfilingService.hpp @@ -26,6 +26,12 @@ namespace armnn namespace profiling { +// Static constants describing ArmNN's counter UID's +static const uint16_t NETWORK_LOADS = 0; +static const uint16_t NETWORK_UNLOADS = 1; +static const uint16_t REGISTERED_BACKENDS = 2; +static const uint16_t UNREGISTERED_BACKENDS = 3; +static const uint16_t INFERENCES_RUN = 4; class ProfilingService : public IReadWriteCounterValues, public IProfilingGuidGenerator { @@ -59,15 +65,15 @@ public: const ICounterDirectory& GetCounterDirectory() const; ProfilingState GetCurrentState() const; bool IsCounterRegistered(uint16_t counterUid) const override; - uint16_t GetCounterCount() const override; uint32_t GetCounterValue(uint16_t counterUid) const override; + uint16_t GetCounterCount() const override; + bool IsProfilingEnabled(); // Setters for the profiling service state void SetCounterValue(uint16_t counterUid, uint32_t value) override; uint32_t AddCounterValue(uint16_t counterUid, uint32_t value) override; uint32_t SubtractCounterValue(uint16_t counterUid, uint32_t value) override; uint32_t IncrementCounterValue(uint16_t counterUid) override; - uint32_t DecrementCounterValue(uint16_t counterUid) override; // IProfilingGuidGenerator functions /// Return the next random Guid in the sequence diff --git a/src/profiling/ProfilingUtils.cpp b/src/profiling/ProfilingUtils.cpp index 8a7d9147cc..0125f0db4b 100644 --- a/src/profiling/ProfilingUtils.cpp +++ b/src/profiling/ProfilingUtils.cpp @@ -6,7 +6,6 @@ #include "ProfilingUtils.hpp" #include -#include #include @@ -72,20 +71,17 @@ uint16_t GetNextUid(bool peekOnly) } } -std::vector GetNextCounterUids(uint16_t cores) +std::vector GetNextCounterUids(uint16_t firstUid, uint16_t cores) { - // The UID used for counters only. The first valid UID is 0 - static uint16_t counterUid = 0; - // Check that it is possible to generate the next counter UID without causing an overflow (throws in case of error) - ThrowIfCantGenerateNextUid(counterUid, cores); + ThrowIfCantGenerateNextUid(firstUid, cores); // Get the next counter UIDs size_t counterUidsSize = cores == 0 ? 1 : cores; std::vector counterUids(counterUidsSize, 0); for (size_t i = 0; i < counterUidsSize; i++) { - counterUids[i] = counterUid++; + counterUids[i] = firstUid++; } return counterUids; } diff --git a/src/profiling/ProfilingUtils.hpp b/src/profiling/ProfilingUtils.hpp index 4427140ece..9bbe421817 100644 --- a/src/profiling/ProfilingUtils.hpp +++ b/src/profiling/ProfilingUtils.hpp @@ -136,7 +136,7 @@ bool ConvertDirectoryComponent(const std::string& directoryComponent, SwTraceBuf uint16_t GetNextUid(bool peekOnly = false); -std::vector GetNextCounterUids(uint16_t cores); +std::vector GetNextCounterUids(uint16_t firstUid, uint16_t cores); void WriteBytes(const IPacketBuffer& packetBuffer, unsigned int offset, const void* value, unsigned int valueSize); diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index 47a686a883..647870ac13 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -663,8 +663,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceCounterValues) const Counters& counters = counterDirectory.GetCounters(); BOOST_CHECK(!counters.empty()); - // Get the UID of the first counter for testing - uint16_t counterUid = counters.begin()->first; + // Get the UID of the first counter for testing; ProfilingService* profilingServicePtr = &profilingService; std::vector writers; @@ -672,21 +671,35 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceCounterValues) for (int i = 0; i < 100; ++i) { // Increment and decrement the first counter - writers.push_back(std::thread(&ProfilingService::IncrementCounterValue, profilingServicePtr, counterUid)); - writers.push_back(std::thread(&ProfilingService::DecrementCounterValue, profilingServicePtr, counterUid)); + writers.push_back(std::thread(&ProfilingService::IncrementCounterValue, + profilingServicePtr, + armnn::profiling::REGISTERED_BACKENDS)); + + writers.push_back(std::thread(&ProfilingService::IncrementCounterValue, + profilingServicePtr, + armnn::profiling::UNREGISTERED_BACKENDS)); + // Add 10 and subtract 5 from the first counter - writers.push_back(std::thread(&ProfilingService::AddCounterValue, profilingServicePtr, counterUid, 10)); - writers.push_back(std::thread(&ProfilingService::SubtractCounterValue, profilingServicePtr, counterUid, 5)); + writers.push_back(std::thread(&ProfilingService::AddCounterValue, + profilingServicePtr, + armnn::profiling::INFERENCES_RUN, + 10)); + writers.push_back(std::thread(&ProfilingService::SubtractCounterValue, + profilingServicePtr, + armnn::profiling::INFERENCES_RUN, + 5)); } std::for_each(writers.begin(), writers.end(), mem_fn(&std::thread::join)); uint32_t counterValue = 0; - BOOST_CHECK_NO_THROW(counterValue = profilingService.GetCounterValue(counterUid)); - BOOST_CHECK(counterValue == 500); - - BOOST_CHECK_NO_THROW(profilingService.SetCounterValue(counterUid, 0)); - BOOST_CHECK_NO_THROW(counterValue = profilingService.GetCounterValue(counterUid)); - BOOST_CHECK(counterValue == 0); + BOOST_CHECK(counterValue == + (profilingService.GetCounterValue(armnn::profiling::UNREGISTERED_BACKENDS) + - profilingService.GetCounterValue(armnn::profiling::REGISTERED_BACKENDS))); + BOOST_CHECK(profilingService.GetCounterValue(armnn::profiling::INFERENCES_RUN) == 500); + + BOOST_CHECK_NO_THROW(profilingService.SetCounterValue(armnn::profiling::UNREGISTERED_BACKENDS, 4)); + BOOST_CHECK_NO_THROW(counterValue = profilingService.GetCounterValue(armnn::profiling::UNREGISTERED_BACKENDS)); + BOOST_CHECK(counterValue == 4); // Reset the profiling service to stop any running thread options.m_EnableProfiling = false; profilingService.ResetExternalProfilingOptions(options, true); @@ -703,18 +716,19 @@ BOOST_AUTO_TEST_CASE(CheckProfilingObjectUids) BOOST_CHECK(nextUid > uid); std::vector counterUids; - BOOST_CHECK_NO_THROW(counterUids = GetNextCounterUids(0)); + BOOST_CHECK_NO_THROW(counterUids = GetNextCounterUids(uid,0)); BOOST_CHECK(counterUids.size() == 1); BOOST_CHECK(counterUids[0] >= 0); std::vector nextCounterUids; - BOOST_CHECK_NO_THROW(nextCounterUids = GetNextCounterUids(1)); - BOOST_CHECK(nextCounterUids.size() == 1); + BOOST_CHECK_NO_THROW(nextCounterUids = GetNextCounterUids(nextUid, 2)); + BOOST_CHECK(nextCounterUids.size() == 2); BOOST_CHECK(nextCounterUids[0] > counterUids[0]); std::vector counterUidsMultiCore; + uint16_t thirdUid = 4; uint16_t numberOfCores = 13; - BOOST_CHECK_NO_THROW(counterUidsMultiCore = GetNextCounterUids(numberOfCores)); + BOOST_CHECK_NO_THROW(counterUidsMultiCore = GetNextCounterUids(thirdUid, numberOfCores)); BOOST_CHECK(counterUidsMultiCore.size() == numberOfCores); BOOST_CHECK(counterUidsMultiCore.front() >= nextCounterUids[0]); for (size_t i = 1; i < numberOfCores; i++) @@ -1127,34 +1141,68 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) // Register a counter with an invalid parent category name const Counter* noCounter = nullptr; BOOST_CHECK_THROW(noCounter = - counterDirectory.RegisterCounter("", 0, 1, 123.45f, "valid name", "valid description"), + counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 0, + "", + 0, + 1, + 123.45f, + "valid ", + "name"), armnn::InvalidArgumentException); BOOST_CHECK(counterDirectory.GetCounterCount() == 0); BOOST_CHECK(!noCounter); // Register a counter with an invalid parent category name - BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("invalid parent category", 0, 1, 123.45f, - "valid name", "valid description"), + BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 1, + "invalid parent category", + 0, + 1, + 123.45f, + "valid name", + "valid description"), armnn::InvalidArgumentException); BOOST_CHECK(counterDirectory.GetCounterCount() == 0); BOOST_CHECK(!noCounter); // Register a counter with an invalid class - BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category", 2, 1, 123.45f, "valid name", + BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 2, + "valid_parent_category", + 2, + 1, + 123.45f, + "valid " + "name", "valid description"), armnn::InvalidArgumentException); BOOST_CHECK(counterDirectory.GetCounterCount() == 0); BOOST_CHECK(!noCounter); // Register a counter with an invalid interpolation - BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category", 0, 3, 123.45f, "valid name", + BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 4, + "valid_parent_category", + 0, + 3, + 123.45f, + "valid " + "name", "valid description"), armnn::InvalidArgumentException); BOOST_CHECK(counterDirectory.GetCounterCount() == 0); BOOST_CHECK(!noCounter); // Register a counter with an invalid multiplier - BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category", 0, 1, .0f, "valid name", + BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 5, + "valid_parent_category", + 0, + 1, + .0f, + "valid " + "name", "valid description"), armnn::InvalidArgumentException); BOOST_CHECK(counterDirectory.GetCounterCount() == 0); @@ -1162,42 +1210,82 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) // Register a counter with an invalid name BOOST_CHECK_THROW( - noCounter = counterDirectory.RegisterCounter("valid_parent_category", 0, 1, 123.45f, "", "valid description"), + noCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 6, + "valid_parent_category", + 0, + 1, + 123.45f, + "", + "valid description"), armnn::InvalidArgumentException); BOOST_CHECK(counterDirectory.GetCounterCount() == 0); BOOST_CHECK(!noCounter); // Register a counter with an invalid name - BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category", 0, 1, 123.45f, - "invalid nam€", "valid description"), + BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 7, + "valid_parent_category", + 0, + 1, + 123.45f, + "invalid nam€", + "valid description"), armnn::InvalidArgumentException); BOOST_CHECK(counterDirectory.GetCounterCount() == 0); BOOST_CHECK(!noCounter); // Register a counter with an invalid description BOOST_CHECK_THROW(noCounter = - counterDirectory.RegisterCounter("valid_parent_category", 0, 1, 123.45f, "valid name", ""), + counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 8, + "valid_parent_category", + 0, + 1, + 123.45f, + "valid name", + ""), armnn::InvalidArgumentException); BOOST_CHECK(counterDirectory.GetCounterCount() == 0); BOOST_CHECK(!noCounter); // Register a counter with an invalid description - BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category", 0, 1, 123.45f, "valid name", + BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 9, + "valid_parent_category", + 0, + 1, + 123.45f, + "valid " + "name", "inv@lid description"), armnn::InvalidArgumentException); BOOST_CHECK(counterDirectory.GetCounterCount() == 0); BOOST_CHECK(!noCounter); // Register a counter with an invalid unit2 - BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category", 0, 1, 123.45f, "valid name", - "valid description", std::string("Mb/s2")), + BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 10, + "valid_parent_category", + 0, + 1, + 123.45f, + "valid name", + "valid description", + std::string("Mb/s2")), armnn::InvalidArgumentException); BOOST_CHECK(counterDirectory.GetCounterCount() == 0); BOOST_CHECK(!noCounter); // Register a counter with a non-existing parent category name - BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("invalid_parent_category", 0, 1, 123.45f, - "valid name", "valid description"), + BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 11, + "invalid_parent_category", + 0, + 1, + 123.45f, + "valid name", + "valid description"), armnn::InvalidArgumentException); BOOST_CHECK(counterDirectory.GetCounterCount() == 0); BOOST_CHECK(!noCounter); @@ -1220,7 +1308,14 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) // Register a counter with a valid parent category name const Counter* counter = nullptr; BOOST_CHECK_NO_THROW( - counter = counterDirectory.RegisterCounter(categoryName, 0, 1, 123.45f, "valid name", "valid description")); + counter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 12, + categoryName, + 0, + 1, + 123.45f, + "valid name", + "valid description")); BOOST_CHECK(counterDirectory.GetCounterCount() == 1); BOOST_CHECK(counter); BOOST_CHECK(counter->m_Uid >= 0); @@ -1239,16 +1334,30 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) // Register a counter with a name of a counter already registered for the given parent category name const Counter* counterSameName = nullptr; BOOST_CHECK_THROW(counterSameName = - counterDirectory.RegisterCounter(categoryName, 0, 0, 1.0f, "valid name", "valid description"), + counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 13, + categoryName, + 0, + 0, + 1.0f, + "valid name", + "valid description", + std::string("description")), armnn::InvalidArgumentException); BOOST_CHECK(counterDirectory.GetCounterCount() == 1); BOOST_CHECK(!counterSameName); // Register a counter with a valid parent category name and units const Counter* counterWUnits = nullptr; - BOOST_CHECK_NO_THROW(counterWUnits = counterDirectory.RegisterCounter(categoryName, 0, 1, 123.45f, "valid name 2", - "valid description", - std::string("Mnnsq2"))); // Units + BOOST_CHECK_NO_THROW(counterWUnits = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 14, + categoryName, + 0, + 1, + 123.45f, + "valid name 2", + "valid description", + std::string("Mnnsq2"))); // Units BOOST_CHECK(counterDirectory.GetCounterCount() == 2); BOOST_CHECK(counterWUnits); BOOST_CHECK(counterWUnits->m_Uid >= 0); @@ -1267,11 +1376,17 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) // Register a counter with a valid parent category name and not associated with a device const Counter* counterWoDevice = nullptr; - BOOST_CHECK_NO_THROW(counterWoDevice = counterDirectory.RegisterCounter( - categoryName, 0, 1, 123.45f, "valid name 3", "valid description", - armnn::EmptyOptional(), // Units - armnn::EmptyOptional(), // Number of cores - 0)); // Device UID + BOOST_CHECK_NO_THROW(counterWoDevice = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 26, + categoryName, + 0, + 1, + 123.45f, + "valid name 3", + "valid description", + armnn::EmptyOptional(),// Units + armnn::EmptyOptional(),// Number of cores + 0)); // Device UID BOOST_CHECK(counterDirectory.GetCounterCount() == 3); BOOST_CHECK(counterWoDevice); BOOST_CHECK(counterWoDevice->m_Uid >= 0); @@ -1289,7 +1404,13 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) BOOST_CHECK(category->m_Counters.back() == counterWoDevice->m_Uid); // Register a counter with a valid parent category name and associated to an invalid device - BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(categoryName, 0, 1, 123.45f, "valid name 4", + BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 15, + categoryName, + 0, + 1, + 123.45f, + "valid name 4", "valid description", armnn::EmptyOptional(), // Units armnn::EmptyOptional(), // Number of cores @@ -1310,8 +1431,14 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) // Register a counter with a valid parent category name and associated to a device const Counter* counterWDevice = nullptr; - BOOST_CHECK_NO_THROW(counterWDevice = counterDirectory.RegisterCounter(categoryName, 0, 1, 123.45f, "valid name 5", - "valid description", + BOOST_CHECK_NO_THROW(counterWDevice = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 16, + categoryName, + 0, + 1, + 123.45f, + "valid name 5", + std::string("valid description"), armnn::EmptyOptional(), // Units armnn::EmptyOptional(), // Number of cores device->m_Uid)); // Device UID @@ -1333,12 +1460,18 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) // Register a counter with a valid parent category name and not associated with a counter set const Counter* counterWoCounterSet = nullptr; - BOOST_CHECK_NO_THROW(counterWoCounterSet = counterDirectory.RegisterCounter( - categoryName, 0, 1, 123.45f, "valid name 6", "valid description", - armnn::EmptyOptional(), // Units - armnn::EmptyOptional(), // Number of cores - armnn::EmptyOptional(), // Device UID - 0)); // Counter set UID + BOOST_CHECK_NO_THROW(counterWoCounterSet = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 17, + categoryName, + 0, + 1, + 123.45f, + "valid name 6", + "valid description", + armnn::EmptyOptional(),// Units + armnn::EmptyOptional(),// No of cores + armnn::EmptyOptional(),// Device UID + 0)); // CounterSet UID BOOST_CHECK(counterDirectory.GetCounterCount() == 5); BOOST_CHECK(counterWoCounterSet); BOOST_CHECK(counterWoCounterSet->m_Uid >= 0); @@ -1356,12 +1489,18 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) BOOST_CHECK(category->m_Counters.back() == counterWoCounterSet->m_Uid); // Register a counter with a valid parent category name and associated to an invalid counter set - BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(categoryName, 0, 1, 123.45f, "valid name 7", - "valid description", + BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 18, + categoryName, + 0, + 1, + 123.45f, + "valid ", + "name 7", + std::string("valid description"), armnn::EmptyOptional(), // Units armnn::EmptyOptional(), // Number of cores - armnn::EmptyOptional(), // Device UID - 100), // Counter set UID + 100), // Counter set UID armnn::InvalidArgumentException); BOOST_CHECK(counterDirectory.GetCounterCount() == 5); BOOST_CHECK(!noCounter); @@ -1370,6 +1509,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) const Counter* counterWNumberOfCores = nullptr; uint16_t numberOfCores = 15; BOOST_CHECK_NO_THROW(counterWNumberOfCores = counterDirectory.RegisterCounter( + armnn::profiling::BACKEND_ID, 50, categoryName, 0, 1, 123.45f, "valid name 8", "valid description", armnn::EmptyOptional(), // Units numberOfCores, // Number of cores @@ -1408,7 +1548,8 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) // Register a counter with a valid parent category name and associated to the multi-core device const Counter* counterWMultiCoreDevice = nullptr; BOOST_CHECK_NO_THROW(counterWMultiCoreDevice = counterDirectory.RegisterCounter( - categoryName, 0, 1, 123.45f, "valid name 9", "valid description", + armnn::profiling::BACKEND_ID, 19, categoryName, 0, 1, + 123.45f, "valid name 9", "valid description", armnn::EmptyOptional(), // Units armnn::EmptyOptional(), // Number of cores multiCoreDevice->m_Uid, // Device UID @@ -1447,12 +1588,19 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) // Register a counter with a valid parent category name and getting the number of cores of the multi-core device // associated to that category const Counter* counterWMultiCoreDeviceWParentCategory = nullptr; - BOOST_CHECK_NO_THROW(counterWMultiCoreDeviceWParentCategory = counterDirectory.RegisterCounter( - categoryName, 0, 1, 123.45f, "valid name 10", "valid description", - armnn::EmptyOptional(), // Units - armnn::EmptyOptional(), // Number of cores - armnn::EmptyOptional(), // Device UID - armnn::EmptyOptional())); // Counter set UID + BOOST_CHECK_NO_THROW(counterWMultiCoreDeviceWParentCategory = + counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 100, + categoryName, + 0, + 1, + 123.45f, + "valid name 10", + "valid description", + armnn::EmptyOptional(),// Units + armnn::EmptyOptional(),// Number of cores + armnn::EmptyOptional(),// Device UID + armnn::EmptyOptional()));// Counter set UID BOOST_CHECK(counterDirectory.GetCounterCount() == 26); BOOST_CHECK(counterWMultiCoreDeviceWParentCategory); BOOST_CHECK(counterWMultiCoreDeviceWParentCategory->m_Uid >= 0); @@ -1487,6 +1635,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) // Register a counter with a valid parent category name and associated to a counter set const Counter* counterWCounterSet = nullptr; BOOST_CHECK_NO_THROW(counterWCounterSet = counterDirectory.RegisterCounter( + armnn::profiling::BACKEND_ID, 300, categoryName, 0, 1, 123.45f, "valid name 11", "valid description", armnn::EmptyOptional(), // Units 0, // Number of cores @@ -1511,6 +1660,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) // Register a counter with a valid parent category name and associated to a device and a counter set const Counter* counterWDeviceWCounterSet = nullptr; BOOST_CHECK_NO_THROW(counterWDeviceWCounterSet = counterDirectory.RegisterCounter( + armnn::profiling::BACKEND_ID, 23, categoryName, 0, 1, 123.45f, "valid name 12", "valid description", armnn::EmptyOptional(), // Units 1, // Number of cores @@ -1546,7 +1696,8 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) // Register a counter to the other category const Counter* anotherCounter = nullptr; - BOOST_CHECK_NO_THROW(anotherCounter = counterDirectory.RegisterCounter(anotherCategoryName, 1, 0, .00043f, + BOOST_CHECK_NO_THROW(anotherCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, 24, + anotherCategoryName, 1, 0, .00043f, "valid name", "valid description", armnn::EmptyOptional(), // Units armnn::EmptyOptional(), // Number of cores @@ -2128,8 +2279,10 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2) const CounterSet* counterSet = counterDirectory.RegisterCounterSet("countersetA"); BOOST_CHECK(counterSet != nullptr); counterDirectory.RegisterCategory("categoryA", device->m_Uid, counterSet->m_Uid); - counterDirectory.RegisterCounter("categoryA", 0, 1, 2.0f, "counterA", "descA"); - counterDirectory.RegisterCounter("categoryA", 1, 1, 3.0f, "counterB", "descB"); + counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, 24, + "categoryA", 0, 1, 2.0f, "counterA", "descA"); + counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, 25, + "categoryA", 1, 1, 3.0f, "counterB", "descB"); profilingStateMachine.TransitionToState(ProfilingState::Uninitialised); BOOST_CHECK_THROW(commandHandler(packet), armnn::RuntimeException); // Wrong profiling state @@ -2325,7 +2478,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodRequestCounterDirectoryPacket) const std::vector writtenData = mockProfilingConnection->GetWrittenData(); BOOST_TEST(writtenData.size() == 2); BOOST_TEST(writtenData[0] == 427); // The size of the expected Timeline Directory packet - BOOST_TEST(writtenData[1] == 416); // The size of the expected Counter Directory packet + BOOST_TEST(writtenData[1] ==656); // The size of the expected Counter Directory packet // The Request Counter Directory Command Handler should not have updated the profiling state BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Active); @@ -2996,7 +3149,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadConnectionAcknowledgedPacket) // Wait for a bit (must at least be the delay value of the mock profiling connection) to make sure that // the Connection Acknowledged packet gets processed by the profiling service - std::this_thread::sleep_for(std::chrono::milliseconds(7)); + std::this_thread::sleep_for(std::chrono::milliseconds(15)); streamRedirector.CancelRedirect(); @@ -3075,7 +3228,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadRequestCounterDirectoryPacket) // Wait for a bit (must at least be the delay value of the mock profiling connection) to make sure that // the Create the Request Counter packet gets processed by the profiling service - std::this_thread::sleep_for(std::chrono::milliseconds(7)); + std::this_thread::sleep_for(std::chrono::milliseconds(15)); streamRedirector.CancelRedirect(); diff --git a/src/profiling/test/SendCounterPacketTests.cpp b/src/profiling/test/SendCounterPacketTests.cpp index 1f2df9bf76..c3ad50c9cb 100644 --- a/src/profiling/test/SendCounterPacketTests.cpp +++ b/src/profiling/test/SendCounterPacketTests.cpp @@ -524,7 +524,8 @@ BOOST_AUTO_TEST_CASE(CreateEventRecordTest) const std::string counterName = "some_valid_counter"; const std::string counterDescription = "a_counter_for_testing"; const std::string counterUnits = "Mrads2"; - const CounterPtr counter = std::make_unique(counterUid, + const CounterPtr counter = std::make_unique(armnn::profiling::BACKEND_ID, + counterUid, maxCounterUid, counterClass, counterInterpolation, @@ -645,7 +646,8 @@ BOOST_AUTO_TEST_CASE(CreateEventRecordNoUnitsTest) double counterMultiplier = 4435.0023f; const std::string counterName = "some_valid_counter"; const std::string counterDescription = "a_counter_for_testing"; - const CounterPtr counter = std::make_unique(counterUid, + const CounterPtr counter = std::make_unique(armnn::profiling::BACKEND_ID, + counterUid, maxCounterUid, counterClass, counterInterpolation, @@ -751,7 +753,8 @@ BOOST_AUTO_TEST_CASE(CreateInvalidEventRecordTest1) const std::string counterName = "some_invalid_counter £££"; // Invalid name const std::string counterDescription = "a_counter_for_testing"; const std::string counterUnits = "Mrads2"; - const CounterPtr counter = std::make_unique(counterUid, + const CounterPtr counter = std::make_unique(armnn::profiling::BACKEND_ID, + counterUid, maxCounterUid, counterClass, counterInterpolation, @@ -791,7 +794,8 @@ BOOST_AUTO_TEST_CASE(CreateInvalidEventRecordTest2) const std::string counterName = "some_invalid_counter"; const std::string counterDescription = "an invalid d€scription"; // Invalid description const std::string counterUnits = "Mrads2"; - const CounterPtr counter = std::make_unique(counterUid, + const CounterPtr counter = std::make_unique(armnn::profiling::BACKEND_ID, + counterUid, maxCounterUid, counterClass, counterInterpolation, @@ -831,7 +835,8 @@ BOOST_AUTO_TEST_CASE(CreateInvalidEventRecordTest3) const std::string counterName = "some_invalid_counter"; const std::string counterDescription = "a valid description"; const std::string counterUnits = "Mrad s2"; // Invalid units - const CounterPtr counter = std::make_unique(counterUid, + const CounterPtr counter = std::make_unique(armnn::profiling::BACKEND_ID, + counterUid, maxCounterUid, counterClass, counterInterpolation, @@ -871,10 +876,11 @@ BOOST_AUTO_TEST_CASE(CreateCategoryRecordTest) // Create a collection of counters Counters counters; counters.insert(std::make_pair(11, - CounterPtr(new Counter(11, - 1234, + CounterPtr(new Counter(armnn::profiling::BACKEND_ID, + 0, + 11, + 0, 0, - 1, 534.0003f, "counter1", "the first counter", @@ -882,9 +888,10 @@ BOOST_AUTO_TEST_CASE(CreateCategoryRecordTest) 0, 0)))); counters.insert(std::make_pair(23, - CounterPtr(new Counter(23, - 344, + CounterPtr(new Counter(armnn::profiling::BACKEND_ID, 1, + 23, + 0, 1, 534.0003f, "this is counter 2", @@ -893,8 +900,9 @@ BOOST_AUTO_TEST_CASE(CreateCategoryRecordTest) 0, 0)))); counters.insert(std::make_pair(5670, - CounterPtr(new Counter(5670, - 31, + CounterPtr(new Counter(armnn::profiling::BACKEND_ID, + 2, + 5670, 0, 0, 534.0003f, @@ -1099,7 +1107,8 @@ BOOST_AUTO_TEST_CASE(CreateInvalidCategoryRecordTest2) // Create a collection of counters Counters counters; counters.insert(std::make_pair(11, - CounterPtr(new Counter(11, + CounterPtr(new Counter(armnn::profiling::BACKEND_ID, + 11, 1234, 0, 1, @@ -1198,7 +1207,9 @@ BOOST_AUTO_TEST_CASE(SendCounterDirectoryPacketTest2) // Register a counter associated to "category1" const Counter* counter1 = nullptr; - BOOST_CHECK_NO_THROW(counter1 = counterDirectory.RegisterCounter(category1Name, + BOOST_CHECK_NO_THROW(counter1 = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 0, + category1Name, 0, 1, 123.45f, @@ -1210,7 +1221,9 @@ BOOST_AUTO_TEST_CASE(SendCounterDirectoryPacketTest2) // Register a counter associated to "category1" const Counter* counter2 = nullptr; - BOOST_CHECK_NO_THROW(counter2 = counterDirectory.RegisterCounter(category1Name, + BOOST_CHECK_NO_THROW(counter2 = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 4, + category1Name, 1, 0, 330.1245656765f, @@ -1225,7 +1238,9 @@ BOOST_AUTO_TEST_CASE(SendCounterDirectoryPacketTest2) // Register a counter associated to "category2" const Counter* counter3 = nullptr; - BOOST_CHECK_NO_THROW(counter3 = counterDirectory.RegisterCounter(category2Name, + BOOST_CHECK_NO_THROW(counter3 = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 5, + category2Name, 1, 1, 0.0000045399f, @@ -1755,7 +1770,9 @@ BOOST_AUTO_TEST_CASE(SendCounterDirectoryPacketTest7) // Register an invalid counter associated to a valid category const Counter* counter = nullptr; - BOOST_CHECK_NO_THROW(counter = counterDirectory.RegisterCounter(categoryName, + BOOST_CHECK_NO_THROW(counter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, + 0, + categoryName, 0, 1, 123.45f, diff --git a/src/profiling/test/SendCounterPacketTests.hpp b/src/profiling/test/SendCounterPacketTests.hpp index 4395d81d16..79ebcd6cba 100644 --- a/src/profiling/test/SendCounterPacketTests.hpp +++ b/src/profiling/test/SendCounterPacketTests.hpp @@ -420,7 +420,9 @@ public: return counterSetPtr; } - const Counter* RegisterCounter(const std::string& parentCategoryName, + const Counter* RegisterCounter(const BackendId& backendId, + const uint16_t uid, + const std::string& parentCategoryName, uint16_t counterClass, uint16_t interpolation, double multiplier, @@ -441,7 +443,7 @@ public: uint16_t counterSetUidValue = counterSetUid.has_value() ? counterSetUid.value() : 0; // Get the counter UIDs and calculate the max counter UID - std::vector counterUids = GetNextCounterUids(deviceCores); + std::vector counterUids = GetNextCounterUids(uid, deviceCores); BOOST_ASSERT(!counterUids.empty()); uint16_t maxCounterUid = deviceCores <= 1 ? counterUids.front() : counterUids.back(); @@ -449,7 +451,8 @@ public: const std::string unitsValue = units.has_value() ? units.value() : ""; // Create the counter - CounterPtr counter = std::make_shared(counterUids.front(), + CounterPtr counter = std::make_shared(armnn::profiling::BACKEND_ID, + counterUids.front(), maxCounterUid, counterClass, interpolation, -- cgit v1.2.1