From 9c85b41a9fcb3c64d7a686373e7dde75630ccd49 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Wed, 16 Mar 2022 00:27:43 +0000 Subject: IVGCVSW-6852 Break the remaining dependencies on Arm NN in the profiling code Change-Id: I18b8ca22896567904768170350ee5eb22edd4a22 Signed-off-by: Jim Flynn --- Android.mk | 4 +- CMakeLists.txt | 2 - include/armnn/profiling/ArmNNProfiling.hpp | 8 + include/armnnUtils/Threads.hpp | 16 -- profiling/common/include/Processes.hpp | 2 +- profiling/common/include/Threads.hpp | 16 ++ profiling/common/src/CMakeLists.txt | 3 +- profiling/common/src/Processes.cpp | 2 +- profiling/common/src/Threads.cpp | 45 ++++++ .../basePipeServer/tests/BasePipeServerTests.cpp | 4 +- .../src/timelineDecoder/tests/TimelineTests.cpp | 6 +- src/armnn/LoadedNetwork.cpp | 2 +- src/armnn/Runtime.cpp | 21 ++- src/armnn/test/RuntimeTests.cpp | 2 +- src/armnnUtils/Threads.cpp | 45 ------ .../backendsCommon/test/BackendProfilingTests.cpp | 20 ++- .../ActivateTimelineReportingCommandHandler.cpp | 11 +- .../ActivateTimelineReportingCommandHandler.hpp | 5 +- src/profiling/IProfilingService.cpp | 10 +- src/profiling/IProfilingService.hpp | 3 + .../PeriodicCounterSelectionCommandHandler.hpp | 1 - src/profiling/ProfilingService.cpp | 1 - src/profiling/ProfilingService.hpp | 9 +- src/profiling/ProfilingUtils.cpp | 22 +-- src/profiling/ProfilingUtils.hpp | 6 - src/profiling/SendCounterPacket.cpp | 8 +- src/profiling/SendCounterPacket.hpp | 14 +- src/profiling/TimelineUtilityMethods.cpp | 6 +- src/profiling/TimelineUtilityMethods.hpp | 2 - src/profiling/test/ProfilingMocks.hpp | 14 +- src/profiling/test/ProfilingTestUtils.cpp | 18 ++- src/profiling/test/ProfilingTestUtils.hpp | 9 +- src/profiling/test/ProfilingTests.cpp | 169 +++++++++++++++++---- src/profiling/test/ProfilingTests.hpp | 8 +- src/profiling/test/SendCounterPacketTests.cpp | 147 +++++++++++++----- src/profiling/test/SendCounterPacketTests.hpp | 7 +- src/profiling/test/SendTimelinePacketTests.cpp | 19 ++- src/profiling/test/TimelinePacketTests.cpp | 11 +- src/profiling/test/TimelineUtilityMethodsTests.cpp | 42 ++++- .../profiling/gatordmock/tests/GatordMockTests.cpp | 8 +- 40 files changed, 518 insertions(+), 230 deletions(-) delete mode 100644 include/armnnUtils/Threads.hpp create mode 100644 profiling/common/include/Threads.hpp create mode 100644 profiling/common/src/Threads.cpp delete mode 100644 src/armnnUtils/Threads.cpp diff --git a/Android.mk b/Android.mk index c884aa6898..ee2fedd9b5 100644 --- a/Android.mk +++ b/Android.mk @@ -110,12 +110,13 @@ LOCAL_SRC_FILES := \ profiling/common/src/CommandHandlerKey.cpp \ profiling/common/src/CommandHandlerRegistry.cpp \ profiling/common/src/CommonProfilingUtils.cpp \ + profiling/common/src/LabelsAndEventClasses.cpp \ profiling/common/src/Logging.cpp \ profiling/common/src/NetworkSockets.cpp \ profiling/common/src/PacketVersionResolver.cpp \ profiling/common/src/Processes.cpp \ profiling/common/src/SwTrace.cpp \ - profiling/common/src/LabelsAndEventClasses.cpp \ + profiling/common/src/Threads.cpp \ profiling/server/src/timelineDecoder/TimelineCaptureCommandHandler.cpp \ profiling/server/src/timelineDecoder/TimelineDecoder.cpp \ profiling/server/src/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp \ @@ -160,7 +161,6 @@ LOCAL_SRC_FILES := \ src/armnnUtils/VerificationHelpers.cpp \ src/armnnUtils/Filesystem.cpp \ src/armnnUtils/ProfilingOptionsConverter.cpp \ - src/armnnUtils/Threads.cpp \ src/armnnUtils/Transpose.cpp \ src/armnn/layers/ActivationLayer.cpp \ src/armnn/layers/AdditionLayer.cpp \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 923bc64697..c739828763 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,6 @@ list(APPEND armnnUtils_sources include/armnnUtils/QuantizeHelper.hpp include/armnnUtils/TContainer.hpp include/armnnUtils/TensorUtils.hpp - include/armnnUtils/Threads.hpp include/armnnUtils/Transpose.hpp src/armnnUtils/BFloat16.hpp src/armnnUtils/CompatibleTypes.cpp @@ -111,7 +110,6 @@ list(APPEND armnnUtils_sources src/armnnUtils/PrototxtConversions.cpp src/armnnUtils/TensorIOUtils.hpp src/armnnUtils/TensorUtils.cpp - src/armnnUtils/Threads.cpp src/armnnUtils/Transpose.cpp ) diff --git a/include/armnn/profiling/ArmNNProfiling.hpp b/include/armnn/profiling/ArmNNProfiling.hpp index 39d4a6bfcc..72fefe1cab 100644 --- a/include/armnn/profiling/ArmNNProfiling.hpp +++ b/include/armnn/profiling/ArmNNProfiling.hpp @@ -5,6 +5,8 @@ #pragma once +#include + namespace arm { @@ -17,6 +19,12 @@ static const uint16_t REGISTERED_BACKENDS = 2; static const uint16_t UNREGISTERED_BACKENDS = 3; static const uint16_t INFERENCES_RUN = 4; static const uint16_t MAX_ARMNN_COUNTER = INFERENCES_RUN; + +// Static holding Arm NN's software descriptions +static std::string ARMNN_SOFTWARE_INFO("ArmNN"); +static std::string ARMNN_HARDWARE_VERSION; +static std::string ARMNN_SOFTWARE_VERSION = "Armnn " + std::to_string(ARMNN_MAJOR_VERSION) + "." + + std::to_string(ARMNN_MINOR_VERSION); } // namespace pipe } // namespace arm diff --git a/include/armnnUtils/Threads.hpp b/include/armnnUtils/Threads.hpp deleted file mode 100644 index 4cecfd5079..0000000000 --- a/include/armnnUtils/Threads.hpp +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -namespace armnnUtils -{ -namespace Threads -{ - -int GetCurrentThreadId(); - -} -} diff --git a/profiling/common/include/Processes.hpp b/profiling/common/include/Processes.hpp index cc59d8b2d4..0a15368169 100644 --- a/profiling/common/include/Processes.hpp +++ b/profiling/common/include/Processes.hpp @@ -10,7 +10,7 @@ namespace arm namespace pipe { -int GetCurrentId(); +int GetCurrentProcessId(); } // namespace arm } // namespace pipe diff --git a/profiling/common/include/Threads.hpp b/profiling/common/include/Threads.hpp new file mode 100644 index 0000000000..1c24a3087b --- /dev/null +++ b/profiling/common/include/Threads.hpp @@ -0,0 +1,16 @@ +// +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +namespace arm +{ +namespace pipe +{ + +int GetCurrentThreadId(); + +} // namespace pipe +} // namespace arm diff --git a/profiling/common/src/CMakeLists.txt b/profiling/common/src/CMakeLists.txt index 3932186c51..e02c785581 100644 --- a/profiling/common/src/CMakeLists.txt +++ b/profiling/common/src/CMakeLists.txt @@ -10,12 +10,13 @@ if(BUILD_TIMELINE_DECODER) CommandHandlerKey.cpp CommandHandlerRegistry.cpp CommonProfilingUtils.cpp + LabelsAndEventClasses.cpp Logging.cpp NetworkSockets.cpp PacketVersionResolver.cpp Processes.cpp SwTrace.cpp - LabelsAndEventClasses.cpp) + Threads.cpp) include_directories(${PROJECT_SOURCE_DIR}/profiling/common/include) include_directories(${PROJECT_SOURCE_DIR}/common/include) diff --git a/profiling/common/src/Processes.cpp b/profiling/common/src/Processes.cpp index d6d4ca4950..94e809529a 100644 --- a/profiling/common/src/Processes.cpp +++ b/profiling/common/src/Processes.cpp @@ -16,7 +16,7 @@ namespace arm namespace pipe { -int GetCurrentId() +int GetCurrentProcessId() { #if defined(__unix__) || defined(__APPLE__) return getpid(); diff --git a/profiling/common/src/Threads.cpp b/profiling/common/src/Threads.cpp new file mode 100644 index 0000000000..10533b77b9 --- /dev/null +++ b/profiling/common/src/Threads.cpp @@ -0,0 +1,45 @@ +// +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "Threads.hpp" + +#if defined(__linux__) +#include +#include +#define gettid() syscall(SYS_gettid) +#elif defined(_MSC_VER) +#include +#elif defined(__APPLE__) +#include "AvailabilityMacros.h" +#include +#include +#include +#include +#endif + +namespace arm +{ +namespace pipe +{ + +int GetCurrentThreadId() +{ +#if defined(__linux__) + return static_cast(gettid()); +#elif defined(_MSC_VER) + return ::GetCurrentThreadId(); +#elif defined(__APPLE__) + uint64_t threadId; + int iRet = pthread_threadid_np(NULL, &threadId); + if (iRet != 0) + { + return 0; + } + return static_cast(threadId); +#endif +} + +} // namespace pipe +} // namespace arm diff --git a/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp b/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp index 9993fc7a75..516e648ce4 100644 --- a/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp +++ b/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp @@ -41,7 +41,7 @@ TEST_CASE("BasePipeServerTest") CHECK(basePipeServer.get()); arm::pipe::BufferManager bufferManager; - arm::pipe::SendCounterPacket sendCounterPacket(bufferManager); + arm::pipe::SendCounterPacket sendCounterPacket(bufferManager, "ArmNN", "Armnn 25.0", ""); // Check that we can receive a StreamMetaDataPacket sendCounterPacket.SendStreamMetaDataPacket(); @@ -57,7 +57,7 @@ TEST_CASE("BasePipeServerTest") bufferManager.MarkRead(packetBuffer); CHECK(basePipeServer.get()->WaitForStreamMetaData()); - CHECK(basePipeServer.get()->GetStreamMetadataPid() == arm::pipe::GetCurrentId()); + CHECK(basePipeServer.get()->GetStreamMetadataPid() == arm::pipe::GetCurrentProcessId()); CHECK(basePipeServer.get()->GetStreamMetadataMaxDataLen() == MAX_METADATA_PACKET_LENGTH); // Now try a simple PeriodicCounterSelectionPacket diff --git a/profiling/server/src/timelineDecoder/tests/TimelineTests.cpp b/profiling/server/src/timelineDecoder/tests/TimelineTests.cpp index 15c5c7e56d..e865c79edc 100644 --- a/profiling/server/src/timelineDecoder/tests/TimelineTests.cpp +++ b/profiling/server/src/timelineDecoder/tests/TimelineTests.cpp @@ -5,12 +5,12 @@ #include #include +#include #include #include #include #include -#include #include #include #include @@ -172,7 +172,7 @@ TEST_CASE("TimelineCaptureTest") const uint64_t timestamp = 33333u; const uint64_t eventGuid = 44444u; - const int threadId = armnnUtils::Threads::GetCurrentThreadId(); + const int threadId = arm::pipe::GetCurrentThreadId(); // need to do a bit of work here to extract the value from threadId unsigned char* uCharThreadId = new unsigned char[arm::pipe::ThreadIdSize]();; @@ -288,7 +288,7 @@ TEST_CASE("TimelineCaptureTestMultipleStringsInBuffer") const uint64_t timestamp = 33333u; const uint64_t eventGuid = 44444u; - const int threadId = armnnUtils::Threads::GetCurrentThreadId(); + const int threadId = arm::pipe::GetCurrentThreadId(); // need to do a bit of work here to extract the value from threadId unsigned char* uCharThreadId = new unsigned char[arm::pipe::ThreadIdSize](); diff --git a/src/armnn/LoadedNetwork.cpp b/src/armnn/LoadedNetwork.cpp index a720769873..6d08fc321e 100644 --- a/src/armnn/LoadedNetwork.cpp +++ b/src/armnn/LoadedNetwork.cpp @@ -266,7 +266,7 @@ LoadedNetwork::LoadedNetwork(std::unique_ptr net, // Mark the network with a start of life event timelineUtils->RecordEvent(networkGuid, LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS); // and with the process ID - int processID = arm::pipe::GetCurrentId(); + int processID = arm::pipe::GetCurrentProcessId(); std::stringstream ss; ss << processID; timelineUtils->MarkEntityWithLabel(networkGuid, ss.str(), LabelsAndEventClasses::PROCESS_ID_GUID); diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp index 57bceddbfd..e7d8e482ab 100644 --- a/src/armnn/Runtime.cpp +++ b/src/armnn/Runtime.cpp @@ -6,23 +6,29 @@ #include "ArmNNProfilingServiceInitialiser.hpp" #include "Runtime.hpp" +#include + #include #include #include #include -#include #include + +#include + +#include +#include + +#include + #include #include -#include -#include #include #include -#include using namespace armnn; using namespace std; @@ -311,7 +317,12 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options) : m_NetworkIdCounter(0) { m_ProfilingService = arm::pipe::IProfilingService::CreateProfilingService( - arm::pipe::MAX_ARMNN_COUNTER, *this, *this); + arm::pipe::MAX_ARMNN_COUNTER, + *this, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION, + *this); const auto start_time = armnn::GetTimeNow(); ARMNN_LOG(info) << "ArmNN v" << ARMNN_VERSION; if ( options.m_ProfilingOptions.m_TimelineEnabled && !options.m_ProfilingOptions.m_EnableProfiling ) diff --git a/src/armnn/test/RuntimeTests.cpp b/src/armnn/test/RuntimeTests.cpp index fcfcc48f96..3cbe8848df 100644 --- a/src/armnn/test/RuntimeTests.cpp +++ b/src/armnn/test/RuntimeTests.cpp @@ -736,7 +736,7 @@ TEST_CASE("ProfilingEnableCpuRef") offset); // Process ID Label - int processID = arm::pipe::GetCurrentId(); + int processID = arm::pipe::GetCurrentProcessId(); std::stringstream ss; ss << processID; std::string processIdLabel = ss.str(); diff --git a/src/armnnUtils/Threads.cpp b/src/armnnUtils/Threads.cpp deleted file mode 100644 index 4cdea6654a..0000000000 --- a/src/armnnUtils/Threads.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// -// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#include - -#if defined(__linux__) -#include -#include -#define gettid() syscall(SYS_gettid) -#elif defined(_MSC_VER) -#include -#elif defined(__APPLE__) -#include "AvailabilityMacros.h" -#include -#include -#include -#include -#endif - -namespace armnnUtils -{ -namespace Threads -{ - -int GetCurrentThreadId() -{ -#if defined(__linux__) - return static_cast(gettid()); -#elif defined(_MSC_VER) - return ::GetCurrentThreadId(); -#elif defined(__APPLE__) - uint64_t threadId; - int iRet = pthread_threadid_np(NULL, &threadId); - if (iRet != 0) - { - return 0; - } - return static_cast(threadId); -#endif -} - -} -} diff --git a/src/backends/backendsCommon/test/BackendProfilingTests.cpp b/src/backends/backendsCommon/test/BackendProfilingTests.cpp index 253ff4a8fc..164efb3b9d 100644 --- a/src/backends/backendsCommon/test/BackendProfilingTests.cpp +++ b/src/backends/backendsCommon/test/BackendProfilingTests.cpp @@ -15,6 +15,8 @@ #include "ProfilingUtils.hpp" #include "RequestCounterDirectoryCommandHandler.hpp" +#include + #include #include @@ -199,7 +201,11 @@ TEST_CASE("TestBackendCounters") armnn::ArmNNProfilingServiceInitialiser initialiser; std::unique_ptr profilingService = arm::pipe::IProfilingService::CreateProfilingService( - arm::pipe::MAX_ARMNN_COUNTER, initialiser); + arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); std::unique_ptr cpuBackendProfilingPtr = std::make_unique(options, *profilingService.get(), cpuAccId); @@ -449,7 +455,11 @@ TEST_CASE("TestBackendCounterLogging") armnn::ArmNNProfilingServiceInitialiser initialiser; std::unique_ptr profilingService = arm::pipe::IProfilingService::CreateProfilingService( - arm::pipe::MAX_ARMNN_COUNTER, initialiser); + arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); std::unique_ptr cpuBackendProfilingPtr = std::make_unique(options, *profilingService.get(), cpuAccId); @@ -506,7 +516,11 @@ TEST_CASE("BackendProfilingContextGetSendTimelinePacket") armnn::ArmNNProfilingServiceInitialiser psInitialiser; std::unique_ptr profilingService = arm::pipe::IProfilingService::CreateProfilingService( - arm::pipe::MAX_ARMNN_COUNTER, psInitialiser); + arm::pipe::MAX_ARMNN_COUNTER, + psInitialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService->ConfigureProfilingService( ConvertExternalProfilingOptions(options.m_ProfilingOptions), true); diff --git a/src/profiling/ActivateTimelineReportingCommandHandler.cpp b/src/profiling/ActivateTimelineReportingCommandHandler.cpp index aca750d5e8..58a88256ea 100644 --- a/src/profiling/ActivateTimelineReportingCommandHandler.cpp +++ b/src/profiling/ActivateTimelineReportingCommandHandler.cpp @@ -5,9 +5,6 @@ #include "ActivateTimelineReportingCommandHandler.hpp" #include "TimelineUtilityMethods.hpp" -#include -#include - #include #include @@ -54,10 +51,10 @@ void ActivateTimelineReportingCommandHandler::operator()(const arm::pipe::Packet m_TimelineReporting = true; - armnn::ArmNNProfilingServiceInitialiser initialiser; - std::unique_ptr profilingService = IProfilingService::CreateProfilingService( - arm::pipe::MAX_ARMNN_COUNTER, initialiser); - m_ReportStructure.value().ReportStructure(*profilingService); + if (m_ReportStructure.has_value()) + { + m_ReportStructure.value().ReportStructure(m_ProfilingService); + } m_BackendNotifier.NotifyBackendsForTimelineReporting(); } diff --git a/src/profiling/ActivateTimelineReportingCommandHandler.hpp b/src/profiling/ActivateTimelineReportingCommandHandler.hpp index 6b311fe851..21e1fe6186 100644 --- a/src/profiling/ActivateTimelineReportingCommandHandler.hpp +++ b/src/profiling/ActivateTimelineReportingCommandHandler.hpp @@ -30,12 +30,14 @@ public: ProfilingStateMachine& profilingStateMachine, arm::pipe::Optional reportStructure, std::atomic& timelineReporting, - INotifyBackends& notifyBackends) + INotifyBackends& notifyBackends, + IProfilingService& profilingService) : CommandHandlerFunctor(familyId, packetId, version), m_SendTimelinePacket(sendTimelinePacket), m_StateMachine(profilingStateMachine), m_TimelineReporting(timelineReporting), m_BackendNotifier(notifyBackends), + m_ProfilingService(profilingService), m_ReportStructure(reportStructure) {} @@ -46,6 +48,7 @@ private: ProfilingStateMachine& m_StateMachine; std::atomic& m_TimelineReporting; INotifyBackends& m_BackendNotifier; + IProfilingService& m_ProfilingService; arm::pipe::Optional m_ReportStructure; }; diff --git a/src/profiling/IProfilingService.cpp b/src/profiling/IProfilingService.cpp index 3bae941a47..b7a394c12f 100644 --- a/src/profiling/IProfilingService.cpp +++ b/src/profiling/IProfilingService.cpp @@ -15,9 +15,17 @@ namespace pipe std::unique_ptr IProfilingService::CreateProfilingService( uint16_t maxGlobalCounterId, IInitialiseProfilingService& initialiser, + const std::string& softwareInfo, + const std::string& softwareVersion, + const std::string& hardwareVersion, arm::pipe::Optional reportStructure) { - return std::make_unique(maxGlobalCounterId, initialiser, reportStructure); + return std::make_unique(maxGlobalCounterId, + initialiser, + softwareInfo, + softwareVersion, + hardwareVersion, + reportStructure); } ProfilingGuidGenerator IProfilingService::m_GuidGenerator; diff --git a/src/profiling/IProfilingService.hpp b/src/profiling/IProfilingService.hpp index bc16860029..6486b6f246 100644 --- a/src/profiling/IProfilingService.hpp +++ b/src/profiling/IProfilingService.hpp @@ -35,6 +35,9 @@ public: static std::unique_ptr CreateProfilingService( uint16_t maxGlobalCounterId, IInitialiseProfilingService& initialiser, + const std::string& softwareInfo, + const std::string& softwareVersion, + const std::string& hardwareVersion, arm::pipe::Optional reportStructure = arm::pipe::EmptyOptional()); virtual ~IProfilingService() {}; virtual std::unique_ptr GetSendTimelinePacket() const = 0; diff --git a/src/profiling/PeriodicCounterSelectionCommandHandler.hpp b/src/profiling/PeriodicCounterSelectionCommandHandler.hpp index 103258ab88..e0feddf9a5 100644 --- a/src/profiling/PeriodicCounterSelectionCommandHandler.hpp +++ b/src/profiling/PeriodicCounterSelectionCommandHandler.hpp @@ -13,7 +13,6 @@ #include "ICounterValues.hpp" #include "armnn/backends/profiling/IBackendProfilingContext.hpp" -#include "armnn/BackendRegistry.hpp" #include #include diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp index b5f398db97..7acddf1129 100644 --- a/src/profiling/ProfilingService.cpp +++ b/src/profiling/ProfilingService.cpp @@ -347,7 +347,6 @@ void ProfilingService::Reset() // ...finally reset the profiling state machine m_StateMachine.Reset(); m_BackendProfilingContexts.clear(); - m_MaxGlobalCounterId = MAX_ARMNN_COUNTER; } void ProfilingService::Stop() diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp index e43642cf19..9e788fd4b3 100644 --- a/src/profiling/ProfilingService.hpp +++ b/src/profiling/ProfilingService.hpp @@ -28,7 +28,6 @@ #include "SendTimelinePacket.hpp" #include "TimelinePacketWriterFactory.hpp" #include "INotifyBackends.hpp" -#include #include @@ -52,6 +51,9 @@ public: ProfilingService(uint16_t maxGlobalCounterId, IInitialiseProfilingService& initialiser, + const std::string& softwareInfo, + const std::string& softwareVersion, + const std::string& hardwareVersion, arm::pipe::Optional reportStructure = arm::pipe::EmptyOptional()) : m_Options() , m_TimelineReporting(false) @@ -67,7 +69,7 @@ public: m_CommandHandlerRegistry, m_PacketVersionResolver) , m_BufferManager() - , m_SendCounterPacket(m_BufferManager) + , m_SendCounterPacket(m_BufferManager, softwareInfo, softwareVersion, hardwareVersion) , m_SendThread(m_StateMachine, m_BufferManager, m_SendCounterPacket) , m_SendTimelinePacket(m_BufferManager) , m_PeriodicCounterCapture(m_Holder, m_SendCounterPacket, *this, m_CounterIdMap, m_BackendProfilingContexts) @@ -93,7 +95,7 @@ public: m_BackendProfilingContexts, m_CounterIdMap, m_Holder, - MAX_ARMNN_COUNTER, + maxGlobalCounterId, m_PeriodicCounterCapture, *this, m_SendCounterPacket, @@ -110,6 +112,7 @@ public: m_StateMachine, reportStructure, m_TimelineReporting, + *this, *this) , m_DeactivateTimelineReportingCommandHandler(0, 7, diff --git a/src/profiling/ProfilingUtils.cpp b/src/profiling/ProfilingUtils.cpp index 22388f43bf..e403b1cacf 100644 --- a/src/profiling/ProfilingUtils.cpp +++ b/src/profiling/ProfilingUtils.cpp @@ -7,16 +7,12 @@ #include #include +#include #include #include #include -#include - - -#include - #include #include #include @@ -176,22 +172,6 @@ uint8_t ReadUint8(const IPacketBufferPtr& packetBuffer, unsigned int offset) return ReadUint8(packetBuffer->GetReadableData(), offset); } -std::string GetSoftwareInfo() -{ - return std::string("ArmNN"); -} - -std::string GetHardwareVersion() -{ - return std::string(); -} - -std::string GetSoftwareVersion() -{ - std::string result = "Armnn " + std::to_string(ARMNN_MAJOR_VERSION) + "." + std::to_string(ARMNN_MINOR_VERSION); - return result; -} - std::string GetProcessName() { std::ifstream comm("/proc/self/comm"); diff --git a/src/profiling/ProfilingUtils.hpp b/src/profiling/ProfilingUtils.hpp index 39ecebf9e8..649ebfa63a 100644 --- a/src/profiling/ProfilingUtils.hpp +++ b/src/profiling/ProfilingUtils.hpp @@ -84,12 +84,6 @@ std::pair CreateTimelinePacketHeader(uint32_t packetFamily, uint32_t sequenceNumbered, uint32_t dataLength); -std::string GetSoftwareInfo(); - -std::string GetSoftwareVersion(); - -std::string GetHardwareVersion(); - std::string GetProcessName(); enum class TimelinePacketStatus diff --git a/src/profiling/SendCounterPacket.cpp b/src/profiling/SendCounterPacket.cpp index d354d40aca..96adb953be 100644 --- a/src/profiling/SendCounterPacket.cpp +++ b/src/profiling/SendCounterPacket.cpp @@ -25,9 +25,9 @@ namespace pipe void SendCounterPacket::SendStreamMetaDataPacket() { - const std::string info(GetSoftwareInfo()); - const std::string hardwareVersion(GetHardwareVersion()); - const std::string softwareVersion(GetSoftwareVersion()); + const std::string info(m_SoftwareInfo); + const std::string hardwareVersion(m_HardwareVersion); + const std::string softwareVersion(m_SoftwareVersion); const std::string processName = GetProcessName().substr(0, 60); const uint32_t infoSize = arm::pipe::numeric_cast(info.size()) + 1; @@ -109,7 +109,7 @@ void SendCounterPacket::SendStreamMetaDataPacket() offset += sizeUint32; WriteUint32(writeBuffer, offset, MAX_METADATA_PACKET_LENGTH); // max_data_length offset += sizeUint32; - int pid = arm::pipe::GetCurrentId(); + int pid = arm::pipe::GetCurrentProcessId(); WriteUint32(writeBuffer, offset, arm::pipe::numeric_cast(pid)); // pid offset += sizeUint32; uint32_t poolOffset = bodySize; diff --git a/src/profiling/SendCounterPacket.hpp b/src/profiling/SendCounterPacket.hpp index f8fd757944..c33bdcc025 100644 --- a/src/profiling/SendCounterPacket.hpp +++ b/src/profiling/SendCounterPacket.hpp @@ -27,8 +27,14 @@ public: using EventRecord = std::vector; using IndexValuePairsVector = std::vector; - SendCounterPacket(IBufferManager& buffer) - : m_BufferManager(buffer) + SendCounterPacket(IBufferManager& buffer, + const std::string& softwareInfo, + const std::string& softwareVersion, + const std::string& hardwareVersion) + : m_BufferManager(buffer), + m_SoftwareInfo(softwareInfo), + m_SoftwareVersion(softwareVersion), + m_HardwareVersion(hardwareVersion) {} void SendStreamMetaDataPacket() override; @@ -83,6 +89,10 @@ protected: bool CreateEventRecord(const CounterPtr& counter, EventRecord& eventRecord, std::string& errorMessage); +private: + std::string m_SoftwareInfo; + std::string m_SoftwareVersion; + std::string m_HardwareVersion; }; } // namespace pipe diff --git a/src/profiling/TimelineUtilityMethods.cpp b/src/profiling/TimelineUtilityMethods.cpp index 1bfbc96df4..9c7780e719 100644 --- a/src/profiling/TimelineUtilityMethods.cpp +++ b/src/profiling/TimelineUtilityMethods.cpp @@ -5,9 +5,7 @@ #include "TimelineUtilityMethods.hpp" #include - - -#include +#include namespace arm { @@ -375,7 +373,7 @@ ProfilingDynamicGuid TimelineUtilityMethods::RecordEvent(ProfilingGuid entityGui uint64_t timestamp = GetTimestamp(); // Get the thread id - int threadId = armnnUtils::Threads::GetCurrentThreadId(); + int threadId = arm::pipe::GetCurrentThreadId(); // Generate a GUID for the event ProfilingDynamicGuid eventGuid = IProfilingService::GetNextGuid(); diff --git a/src/profiling/TimelineUtilityMethods.hpp b/src/profiling/TimelineUtilityMethods.hpp index fa25dc47b0..cfdc26a72b 100644 --- a/src/profiling/TimelineUtilityMethods.hpp +++ b/src/profiling/TimelineUtilityMethods.hpp @@ -8,8 +8,6 @@ #include "IProfilingService.hpp" #include "armnn/profiling/ISendTimelinePacket.hpp" -#include - namespace arm { diff --git a/src/profiling/test/ProfilingMocks.hpp b/src/profiling/test/ProfilingMocks.hpp index 1b5a36686c..cfc1096b8d 100644 --- a/src/profiling/test/ProfilingMocks.hpp +++ b/src/profiling/test/ProfilingMocks.hpp @@ -13,6 +13,9 @@ #include #include +#include +#include + #include #include #include @@ -631,8 +634,15 @@ public: MockBufferManager& mockBufferManager, bool isProfilingEnabled, const CaptureData& captureData) : - ProfilingService(maxGlobalCounterId, initialiser), - m_SendCounterPacket(mockBufferManager), + ProfilingService(maxGlobalCounterId, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION), + m_SendCounterPacket(mockBufferManager, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION), m_IsProfilingEnabled(isProfilingEnabled), m_CaptureData(captureData) {} diff --git a/src/profiling/test/ProfilingTestUtils.cpp b/src/profiling/test/ProfilingTestUtils.cpp index 7fe7069c01..51aa07e163 100644 --- a/src/profiling/test/ProfilingTestUtils.cpp +++ b/src/profiling/test/ProfilingTestUtils.cpp @@ -12,12 +12,12 @@ #include #include -#include #include #include #include #include +#include #include @@ -27,9 +27,9 @@ uint32_t GetStreamMetaDataPacketSize() { uint32_t sizeUint32 = sizeof(uint32_t); uint32_t payloadSize = 0; - payloadSize += arm::pipe::numeric_cast(GetSoftwareInfo().size()) + 1; - payloadSize += arm::pipe::numeric_cast(GetHardwareVersion().size()) + 1; - payloadSize += arm::pipe::numeric_cast(GetSoftwareVersion().size()) + 1; + payloadSize += arm::pipe::numeric_cast(arm::pipe::ARMNN_SOFTWARE_INFO.size()) + 1; + payloadSize += arm::pipe::numeric_cast(arm::pipe::ARMNN_HARDWARE_VERSION.size()) + 1; + payloadSize += arm::pipe::numeric_cast(arm::pipe::ARMNN_SOFTWARE_VERSION.size()) + 1; payloadSize += arm::pipe::numeric_cast(GetProcessName().size()) + 1; // Add packetVersionEntries @@ -128,7 +128,11 @@ ProfilingGuid VerifyTimelineLabelBinaryPacketData(arm::pipe::Optional time } else { - CHECK(readThreadId == armnnUtils::Threads::GetCurrentThreadId()); + CHECK(readThreadId == arm::pipe::GetCurrentThreadId()); } // Check the event GUID @@ -492,7 +496,7 @@ void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId) offset); // Process ID Label - int processID = arm::pipe::GetCurrentId(); + int processID = arm::pipe::GetCurrentProcessId(); std::stringstream ss; ss << processID; std::string processIdLabel = ss.str(); diff --git a/src/profiling/test/ProfilingTestUtils.hpp b/src/profiling/test/ProfilingTestUtils.hpp index b4aa372a98..4ff4221cab 100644 --- a/src/profiling/test/ProfilingTestUtils.hpp +++ b/src/profiling/test/ProfilingTestUtils.hpp @@ -11,6 +11,8 @@ #include #include +#include + #include #include @@ -74,7 +76,12 @@ public: ProfilingServiceRuntimeHelper(uint16_t maxGlobalCounterId, IInitialiseProfilingService& initialiser, arm::pipe::IProfilingService& profilingService) - : ProfilingService(maxGlobalCounterId, initialiser), m_ProfilingService(profilingService) {} + : ProfilingService(maxGlobalCounterId, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION), + m_ProfilingService(profilingService) {} ~ProfilingServiceRuntimeHelper() = default; BufferManager& GetProfilingBufferManager() diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index d635ca3fa5..19e5f1baa6 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -148,7 +148,10 @@ TEST_CASE("CheckCommandHandler") TestProfilingConnectionArmnnError testProfilingConnectionArmnnError; CounterDirectory counterDirectory; MockBufferManager mockBuffer(1024); - SendCounterPacket sendCounterPacket(mockBuffer); + SendCounterPacket sendCounterPacket(mockBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, mockBuffer, sendCounterPacket); SendTimelinePacket sendTimelinePacket(mockBuffer); MockProfilingServiceStatus mockProfilingServiceStatus; @@ -662,7 +665,11 @@ TEST_CASE("CheckProfilingServiceDisabled") { ProfilingOptions options; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised); profilingService.Update(); @@ -673,7 +680,11 @@ TEST_CASE("CheckProfilingServiceCounterDirectory") { ProfilingOptions options; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); const ICounterDirectory& counterDirectory0 = profilingService.GetCounterDirectory(); @@ -698,7 +709,11 @@ TEST_CASE("CheckProfilingServiceCounterValues") ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); profilingService.Update(); @@ -1806,7 +1821,10 @@ TEST_CASE("CounterSelectionCommandHandlerParseData") TestCaptureThread captureThread; TestReadCounterValues readCounterValues; MockBufferManager mockBuffer(512); - SendCounterPacket sendCounterPacket(mockBuffer); + SendCounterPacket sendCounterPacket(mockBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, mockBuffer, sendCounterPacket); uint32_t sizeOfUint32 = arm::pipe::numeric_cast(sizeof(uint32_t)); @@ -1912,8 +1930,9 @@ TEST_CASE("CheckTimelineActivationAndDeactivation") class TestReportStructure : public IReportStructure { public: - virtual void ReportStructure(arm::pipe::IProfilingService& /*profilingService*/) override + virtual void ReportStructure(arm::pipe::IProfilingService& profilingService) override { + arm::pipe::IgnoreUnused(profilingService); m_ReportStructureCalled = true; } @@ -1940,6 +1959,13 @@ TEST_CASE("CheckTimelineActivationAndDeactivation") ProfilingStateMachine stateMachine; TestReportStructure testReportStructure; TestNotifyBackends testNotifyBackends; + armnn::ArmNNProfilingServiceInitialiser initialiser; + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); + ActivateTimelineReportingCommandHandler activateTimelineReportingCommandHandler(0, 6, @@ -1949,7 +1975,8 @@ TEST_CASE("CheckTimelineActivationAndDeactivation") stateMachine, testReportStructure, testNotifyBackends.m_timelineReporting, - testNotifyBackends); + testNotifyBackends, + profilingService); // Write an "ActivateTimelineReporting" packet into the mock profiling connection, to simulate an input from an // external profiling service @@ -2069,7 +2096,10 @@ TEST_CASE("CheckConnectionAcknowledged") CHECK(profilingState.GetCurrentState() == ProfilingState::Uninitialised); CounterDirectory counterDirectory; MockBufferManager mockBuffer(1024); - SendCounterPacket sendCounterPacket(mockBuffer); + SendCounterPacket sendCounterPacket(mockBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingState, mockBuffer, sendCounterPacket); SendTimelinePacket sendTimelinePacket(mockBuffer); MockProfilingServiceStatus mockProfilingServiceStatus; @@ -2375,7 +2405,10 @@ TEST_CASE("CheckPeriodicCounterCaptureThread") std::vector captureIds2; MockBufferManager mockBuffer(512); - SendCounterPacket sendCounterPacket(mockBuffer); + SendCounterPacket sendCounterPacket(mockBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, mockBuffer, sendCounterPacket); std::vector counterIds; @@ -2433,7 +2466,10 @@ TEST_CASE("RequestCounterDirectoryCommandHandlerTest1") ProfilingStateMachine profilingStateMachine; CounterDirectory counterDirectory; MockBufferManager mockBuffer1(1024); - SendCounterPacket sendCounterPacket(mockBuffer1); + SendCounterPacket sendCounterPacket(mockBuffer1, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, mockBuffer1, sendCounterPacket); MockBufferManager mockBuffer2(1024); SendTimelinePacket sendTimelinePacket(mockBuffer2); @@ -2493,7 +2529,10 @@ TEST_CASE("RequestCounterDirectoryCommandHandlerTest2") ProfilingStateMachine profilingStateMachine; CounterDirectory counterDirectory; MockBufferManager mockBuffer1(1024); - SendCounterPacket sendCounterPacket(mockBuffer1); + SendCounterPacket sendCounterPacket(mockBuffer1, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, mockBuffer1, sendCounterPacket); MockBufferManager mockBuffer2(1024); SendTimelinePacket sendTimelinePacket(mockBuffer2); @@ -2576,7 +2615,11 @@ TEST_CASE("CheckProfilingServiceGoodConnectionAcknowledgedPacket") ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); // Swap the profiling connection factory in the profiling service instance with our mock one @@ -2637,7 +2680,11 @@ TEST_CASE("CheckProfilingServiceGoodRequestCounterDirectoryPacket") ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); // Swap the profiling connection factory in the profiling service instance with our mock one @@ -2696,7 +2743,11 @@ TEST_CASE("CheckProfilingServiceBadPeriodicCounterSelectionPacketInvalidCounterU ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); // Swap the profiling connection factory in the profiling service instance with our mock one @@ -2776,7 +2827,11 @@ TEST_CASE("CheckProfilingServiceGoodPeriodicCounterSelectionPacketNoCounters") ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); // Swap the profiling connection factory in the profiling service instance with our mock one @@ -2842,7 +2897,11 @@ TEST_CASE("CheckProfilingServiceGoodPeriodicCounterSelectionPacketSingleCounter" ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); // Swap the profiling connection factory in the profiling service instance with our mock one @@ -2920,7 +2979,11 @@ TEST_CASE("CheckProfilingServiceGoodPeriodicCounterSelectionPacketMultipleCounte ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); // Swap the profiling connection factory in the profiling service instance with our mock one @@ -3000,7 +3063,11 @@ TEST_CASE("CheckProfilingServiceDisconnect") ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); // Swap the profiling connection factory in the profiling service instance with our mock one @@ -3059,7 +3126,11 @@ TEST_CASE("CheckProfilingServiceGoodPerJobCounterSelectionPacket") ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); // Swap the profiling connection factory in the profiling service instance with our mock one @@ -3127,7 +3198,11 @@ TEST_CASE("CheckConfigureProfilingServiceOn") ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised); profilingService.ConfigureProfilingService(options); // should get as far as NOT_CONNECTED @@ -3141,7 +3216,11 @@ TEST_CASE("CheckConfigureProfilingServiceOff") { ProfilingOptions options; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised); profilingService.ConfigureProfilingService(options); // should not move from Uninitialised @@ -3163,7 +3242,11 @@ TEST_CASE("CheckProfilingServiceEnabled") ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised); profilingService.Update(); @@ -3196,7 +3279,11 @@ TEST_CASE("CheckProfilingServiceEnabledRuntime") ProfilingOptions options; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised); profilingService.Update(); @@ -3236,7 +3323,11 @@ TEST_CASE("CheckProfilingServiceBadConnectionAcknowledgedPacket") ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); // Swap the profiling connection factory in the profiling service instance with our mock one @@ -3299,7 +3390,11 @@ TEST_CASE("CheckProfilingServiceBadRequestCounterDirectoryPacket") ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); // Swap the profiling connection factory in the profiling service instance with our mock one @@ -3364,7 +3459,11 @@ TEST_CASE("CheckProfilingServiceBadPeriodicCounterSelectionPacket") ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); // Swap the profiling connection factory in the profiling service instance with our mock one @@ -3466,7 +3565,11 @@ TEST_CASE("CheckRegisterBackendCounters") ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); RegisterBackendCounters registerBackendCounters(globalCounterIds, cpuRefId, profilingService); @@ -3516,7 +3619,11 @@ TEST_CASE("CheckCounterStatusQuery") // Reset the profiling service to the uninitialized state armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); const std::string cpuRefId(GetComputeDeviceAsCString(armnn::Compute::CpuRef)); @@ -3727,7 +3834,11 @@ TEST_CASE("CheckFileFormat") { options.m_FileFormat = "json"; // Enable the profiling service armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); // Start the command handler and the send thread profilingService.Update(); diff --git a/src/profiling/test/ProfilingTests.hpp b/src/profiling/test/ProfilingTests.hpp index e55117bbc7..e9fe57d62e 100644 --- a/src/profiling/test/ProfilingTests.hpp +++ b/src/profiling/test/ProfilingTests.hpp @@ -12,6 +12,8 @@ #include #include +#include + #include #include @@ -168,7 +170,11 @@ public: SwapProfilingConnectionFactoryHelper(uint16_t maxGlobalCounterId, IInitialiseProfilingService& initialiser, ProfilingService& profilingService) - : ProfilingService(maxGlobalCounterId, initialiser) + : ProfilingService(maxGlobalCounterId, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION) , m_ProfilingService(profilingService) , m_MockProfilingConnectionFactory(new MockProfilingConnectionFactory()) , m_BackupProfilingConnectionFactory(nullptr) diff --git a/src/profiling/test/SendCounterPacketTests.cpp b/src/profiling/test/SendCounterPacketTests.cpp index bdc1d5167d..4f7886afe3 100644 --- a/src/profiling/test/SendCounterPacketTests.cpp +++ b/src/profiling/test/SendCounterPacketTests.cpp @@ -153,16 +153,23 @@ TEST_CASE("SendPeriodicCounterSelectionPacketTest") { // Error no space left in buffer MockBufferManager mockBuffer1(10); - SendCounterPacket sendPacket1(mockBuffer1); + SendCounterPacket sendPacket1(mockBuffer1, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); uint32_t capturePeriod = 1000; std::vector selectedCounterIds; - CHECK_THROWS_AS(sendPacket1.SendPeriodicCounterSelectionPacket(capturePeriod, selectedCounterIds), - BufferExhaustion); + CHECK_THROWS_AS(sendPacket1.SendPeriodicCounterSelectionPacket( + capturePeriod, selectedCounterIds), + BufferExhaustion); // Packet without any counters MockBufferManager mockBuffer2(512); - SendCounterPacket sendPacket2(mockBuffer2); + SendCounterPacket sendPacket2(mockBuffer2, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); sendPacket2.SendPeriodicCounterSelectionPacket(capturePeriod, selectedCounterIds); auto readBuffer2 = mockBuffer2.GetReadableBuffer(); @@ -178,7 +185,10 @@ TEST_CASE("SendPeriodicCounterSelectionPacketTest") // Full packet message MockBufferManager mockBuffer3(512); - SendCounterPacket sendPacket3(mockBuffer3); + SendCounterPacket sendPacket3(mockBuffer3, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); selectedCounterIds.reserve(5); selectedCounterIds.emplace_back(100); @@ -216,7 +226,10 @@ TEST_CASE("SendPeriodicCounterCapturePacketTest") // Error no space left in buffer MockBufferManager mockBuffer1(10); - SendCounterPacket sendPacket1(mockBuffer1); + SendCounterPacket sendPacket1(mockBuffer1, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); auto captureTimestamp = std::chrono::steady_clock::now(); uint64_t time = static_cast(captureTimestamp.time_since_epoch().count()); @@ -227,7 +240,10 @@ TEST_CASE("SendPeriodicCounterCapturePacketTest") // Packet without any counters MockBufferManager mockBuffer2(512); - SendCounterPacket sendPacket2(mockBuffer2); + SendCounterPacket sendPacket2(mockBuffer2, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); sendPacket2.SendPeriodicCounterCapturePacket(time, indexValuePairs); auto readBuffer2 = mockBuffer2.GetReadableBuffer(); @@ -244,7 +260,10 @@ TEST_CASE("SendPeriodicCounterCapturePacketTest") // Full packet message MockBufferManager mockBuffer3(512); - SendCounterPacket sendPacket3(mockBuffer3); + SendCounterPacket sendPacket3(mockBuffer3, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); indexValuePairs.reserve(5); indexValuePairs.emplace_back(CounterValue{0, 100}); @@ -293,16 +312,19 @@ TEST_CASE("SendStreamMetaDataPacketTest") // Error no space left in buffer MockBufferManager mockBuffer1(10); - SendCounterPacket sendPacket1(mockBuffer1); + SendCounterPacket sendPacket1(mockBuffer1, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); CHECK_THROWS_AS(sendPacket1.SendStreamMetaDataPacket(), BufferExhaustion); // Full metadata packet std::string processName = GetProcessName().substr(0, 60); - uint32_t infoSize = arm::pipe::numeric_cast(GetSoftwareInfo().size()) + 1; - uint32_t hardwareVersionSize = arm::pipe::numeric_cast(GetHardwareVersion().size()) + 1; - uint32_t softwareVersionSize = arm::pipe::numeric_cast(GetSoftwareVersion().size()) + 1; + uint32_t infoSize = arm::pipe::numeric_cast(arm::pipe::ARMNN_SOFTWARE_INFO.size()) + 1; + uint32_t hardwareVersionSize = arm::pipe::numeric_cast(arm::pipe::ARMNN_HARDWARE_VERSION.size()) + 1; + uint32_t softwareVersionSize = arm::pipe::numeric_cast(arm::pipe::ARMNN_SOFTWARE_VERSION.size()) + 1; uint32_t processNameSize = arm::pipe::numeric_cast(processName.size()) + 1; // Supported Packets @@ -340,7 +362,10 @@ TEST_CASE("SendStreamMetaDataPacketTest") uint32_t packetEntries = static_cast(packetVersions.size()); MockBufferManager mockBuffer2(512); - SendCounterPacket sendPacket2(mockBuffer2); + SendCounterPacket sendPacket2(mockBuffer2, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); sendPacket2.SendStreamMetaDataPacket(); auto readBuffer2 = mockBuffer2.GetReadableBuffer(); @@ -365,7 +390,7 @@ TEST_CASE("SendStreamMetaDataPacketTest") offset += sizeUint32; CHECK(ReadUint32(readBuffer2, offset) == MAX_METADATA_PACKET_LENGTH); // max_data_len offset += sizeUint32; - int pid = arm::pipe::GetCurrentId(); + int pid = arm::pipe::GetCurrentProcessId(); CHECK(ReadUint32(readBuffer2, offset) == arm::pipe::numeric_cast(pid)); offset += sizeUint32; uint32_t poolOffset = 10 * sizeUint32; @@ -390,19 +415,22 @@ TEST_CASE("SendStreamMetaDataPacketTest") offset += sizeUint32; if (infoSize) { - CHECK(strcmp(reinterpret_cast(&readData2[offset]), GetSoftwareInfo().c_str()) == 0); + CHECK(strcmp(reinterpret_cast(&readData2[offset]), + arm::pipe::ARMNN_SOFTWARE_INFO.c_str()) == 0); offset += infoSize; } if (hardwareVersionSize) { - CHECK(strcmp(reinterpret_cast(&readData2[offset]), GetHardwareVersion().c_str()) == 0); + CHECK(strcmp(reinterpret_cast(&readData2[offset]), + arm::pipe::ARMNN_HARDWARE_VERSION.c_str()) == 0); offset += hardwareVersionSize; } if (softwareVersionSize) { - CHECK(strcmp(reinterpret_cast(&readData2[offset]), GetSoftwareVersion().c_str()) == 0); + CHECK(strcmp(reinterpret_cast(&readData2[offset]), + arm::pipe::ARMNN_SOFTWARE_VERSION.c_str()) == 0); offset += softwareVersionSize; } @@ -1178,7 +1206,10 @@ TEST_CASE("SendCounterDirectoryPacketTest1") // Buffer with not enough space MockBufferManager mockBuffer(10); - SendCounterPacket sendCounterPacket(mockBuffer); + SendCounterPacket sendCounterPacket(mockBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), BufferExhaustion); } @@ -1276,7 +1307,10 @@ TEST_CASE("SendCounterDirectoryPacketTest2") // Buffer with enough space MockBufferManager mockBuffer(1024); - SendCounterPacket sendCounterPacket(mockBuffer); + SendCounterPacket sendCounterPacket(mockBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); CHECK_NOTHROW(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory)); // Get the readable buffer @@ -1672,7 +1706,10 @@ TEST_CASE("SendCounterDirectoryPacketTest3") // Buffer with enough space MockBufferManager mockBuffer(1024); - SendCounterPacket sendCounterPacket(mockBuffer); + SendCounterPacket sendCounterPacket(mockBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), arm::pipe::ProfilingException); } @@ -1690,7 +1727,10 @@ TEST_CASE("SendCounterDirectoryPacketTest4") // Buffer with enough space MockBufferManager mockBuffer(1024); - SendCounterPacket sendCounterPacket(mockBuffer); + SendCounterPacket sendCounterPacket(mockBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), arm::pipe::ProfilingException); } @@ -1708,7 +1748,10 @@ TEST_CASE("SendCounterDirectoryPacketTest5") // Buffer with enough space MockBufferManager mockBuffer(1024); - SendCounterPacket sendCounterPacket(mockBuffer); + SendCounterPacket sendCounterPacket(mockBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), arm::pipe::ProfilingException); } @@ -1740,7 +1783,10 @@ TEST_CASE("SendCounterDirectoryPacketTest6") // Buffer with enough space MockBufferManager mockBuffer(1024); - SendCounterPacket sendCounterPacket(mockBuffer); + SendCounterPacket sendCounterPacket(mockBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), arm::pipe::ProfilingException); } @@ -1789,7 +1835,10 @@ TEST_CASE("SendCounterDirectoryPacketTest7") // Buffer with enough space MockBufferManager mockBuffer(1024); - SendCounterPacket sendCounterPacket(mockBuffer); + SendCounterPacket sendCounterPacket(mockBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), arm::pipe::ProfilingException); } @@ -1800,7 +1849,10 @@ TEST_CASE("SendThreadTest0") MockProfilingConnection mockProfilingConnection; MockStreamCounterBuffer mockStreamCounterBuffer(0); - SendCounterPacket sendCounterPacket(mockStreamCounterBuffer); + SendCounterPacket sendCounterPacket(mockStreamCounterBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket); // Try to start the send thread many times, it must only start once @@ -1826,7 +1878,10 @@ TEST_CASE("SendThreadTest1") MockProfilingConnection mockProfilingConnection; MockStreamCounterBuffer mockStreamCounterBuffer(1024); - SendCounterPacket sendCounterPacket(mockStreamCounterBuffer); + SendCounterPacket sendCounterPacket(mockStreamCounterBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket); sendThread.Start(mockProfilingConnection); @@ -1934,7 +1989,10 @@ TEST_CASE("SendThreadTest2") MockProfilingConnection mockProfilingConnection; MockStreamCounterBuffer mockStreamCounterBuffer(1024); - SendCounterPacket sendCounterPacket(mockStreamCounterBuffer); + SendCounterPacket sendCounterPacket(mockStreamCounterBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket); sendThread.Start(mockProfilingConnection); @@ -2052,7 +2110,10 @@ TEST_CASE("SendThreadTest3") MockProfilingConnection mockProfilingConnection; MockStreamCounterBuffer mockStreamCounterBuffer(1024); - SendCounterPacket sendCounterPacket(mockStreamCounterBuffer); + SendCounterPacket sendCounterPacket(mockStreamCounterBuffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket); sendThread.Start(mockProfilingConnection); @@ -2153,7 +2214,10 @@ TEST_CASE("SendCounterPacketTestWithSendThread") MockProfilingConnection mockProfilingConnection; BufferManager bufferManager(1, 1024); - SendCounterPacket sendCounterPacket(bufferManager); + SendCounterPacket sendCounterPacket(bufferManager, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket, -1); sendThread.Start(mockProfilingConnection); @@ -2200,7 +2264,10 @@ TEST_CASE("SendThreadBufferTest") MockProfilingConnection mockProfilingConnection; BufferManager bufferManager(3, 1024); - SendCounterPacket sendCounterPacket(bufferManager); + SendCounterPacket sendCounterPacket(bufferManager, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket, -1); sendThread.Start(mockProfilingConnection); @@ -2258,7 +2325,10 @@ TEST_CASE("SendThreadSendStreamMetadataPacket1") MockProfilingConnection mockProfilingConnection; BufferManager bufferManager(3, 1024); - SendCounterPacket sendCounterPacket(bufferManager); + SendCounterPacket sendCounterPacket(bufferManager, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket); sendThread.Start(mockProfilingConnection); @@ -2273,7 +2343,10 @@ TEST_CASE("SendThreadSendStreamMetadataPacket2") MockProfilingConnection mockProfilingConnection; BufferManager bufferManager(3, 1024); - SendCounterPacket sendCounterPacket(bufferManager); + SendCounterPacket sendCounterPacket(bufferManager, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket); sendThread.Start(mockProfilingConnection); @@ -2290,7 +2363,10 @@ TEST_CASE("SendThreadSendStreamMetadataPacket3") MockProfilingConnection mockProfilingConnection; BufferManager bufferManager(3, 1024); - SendCounterPacket sendCounterPacket(bufferManager); + SendCounterPacket sendCounterPacket(bufferManager, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket); sendThread.Start(mockProfilingConnection); @@ -2315,7 +2391,10 @@ TEST_CASE("SendThreadSendStreamMetadataPacket4") MockProfilingConnection mockProfilingConnection; BufferManager bufferManager(3, 1024); - SendCounterPacket sendCounterPacket(bufferManager); + SendCounterPacket sendCounterPacket(bufferManager, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket); sendThread.Start(mockProfilingConnection); diff --git a/src/profiling/test/SendCounterPacketTests.hpp b/src/profiling/test/SendCounterPacketTests.hpp index 626377a960..f9448aca53 100644 --- a/src/profiling/test/SendCounterPacketTests.hpp +++ b/src/profiling/test/SendCounterPacketTests.hpp @@ -10,6 +10,8 @@ #include #include +#include + #include #include @@ -28,7 +30,10 @@ class SendCounterPacketTest : public SendCounterPacket { public: SendCounterPacketTest(IBufferManager& buffer) - : SendCounterPacket(buffer) + : SendCounterPacket(buffer, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION) {} bool CreateDeviceRecordTest(const DevicePtr& device, diff --git a/src/profiling/test/SendTimelinePacketTests.cpp b/src/profiling/test/SendTimelinePacketTests.cpp index 7f2421dbec..ad71f8fd22 100644 --- a/src/profiling/test/SendTimelinePacketTests.cpp +++ b/src/profiling/test/SendTimelinePacketTests.cpp @@ -13,11 +13,11 @@ #include #include #include -#include #include -#include #include +#include +#include #include @@ -339,7 +339,7 @@ TEST_CASE("SendEventClassAfterTimelineEntityPacketTest") // Send TimelineEventBinaryPacket const uint64_t timestamp = 456789u; - const int threadId = armnnUtils::Threads::GetCurrentThreadId(); + const int threadId = arm::pipe::GetCurrentThreadId(); const uint64_t eventProfilingGuid = 123456u; sendTimelinePacket->SendTimelineEventBinaryPacket(timestamp, threadId, eventProfilingGuid); @@ -435,7 +435,12 @@ TEST_CASE("GetGuidsFromProfilingService") options.m_ProfilingOptions.m_EnableProfiling = true; armnn::RuntimeImpl runtime(options); armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser, runtime); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION, + runtime); profilingService.ResetExternalProfilingOptions( ConvertExternalProfilingOptions(options.m_ProfilingOptions), true); @@ -459,7 +464,11 @@ TEST_CASE("GetTimelinePackerWriterFromProfilingService") ProfilingOptions options; options.m_EnableProfiling = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); std::unique_ptr writer = profilingService.GetSendTimelinePacket(); diff --git a/src/profiling/test/TimelinePacketTests.cpp b/src/profiling/test/TimelinePacketTests.cpp index f1a038555c..a64b3731ce 100644 --- a/src/profiling/test/TimelinePacketTests.cpp +++ b/src/profiling/test/TimelinePacketTests.cpp @@ -5,10 +5,9 @@ #include -#include - #include #include +#include #include @@ -729,7 +728,7 @@ TEST_CASE("TimelineEventClassTestFullConstructionOfData") TEST_CASE("TimelineEventPacketTestNoBuffer") { const uint64_t timestamp = 456789u; - const int threadId = armnnUtils::Threads::GetCurrentThreadId(); + const int threadId = arm::pipe::GetCurrentThreadId(); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = WriteTimelineEventBinary(timestamp, @@ -747,7 +746,7 @@ TEST_CASE("TimelineEventPacketTestBufferExhaustionZeroValue") std::vector buffer(512, 0); const uint64_t timestamp = 456789u; - const int threadId = armnnUtils::Threads::GetCurrentThreadId(); + const int threadId = arm::pipe::GetCurrentThreadId(); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = WriteTimelineEventBinary(timestamp, @@ -765,7 +764,7 @@ TEST_CASE("TimelineEventPacketTestBufferExhaustionFixedValue") std::vector buffer(10, 0); const uint64_t timestamp = 456789u; - const int threadId = armnnUtils::Threads::GetCurrentThreadId(); + const int threadId = arm::pipe::GetCurrentThreadId(); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = WriteTimelineEventBinary(timestamp, @@ -783,7 +782,7 @@ TEST_CASE("TimelineEventPacketTestFullConstructionOfData") std::vector buffer(512, 0); const uint64_t timestamp = 456789u; - const int threadId = armnnUtils::Threads::GetCurrentThreadId(); + const int threadId = arm::pipe::GetCurrentThreadId(); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = WriteTimelineEventBinary(timestamp, diff --git a/src/profiling/test/TimelineUtilityMethodsTests.cpp b/src/profiling/test/TimelineUtilityMethodsTests.cpp index 7e95df1c14..66cb0e92e8 100644 --- a/src/profiling/test/TimelineUtilityMethodsTests.cpp +++ b/src/profiling/test/TimelineUtilityMethodsTests.cpp @@ -28,7 +28,11 @@ TEST_CASE("CreateTypedLabelTest") { MockBufferManager mockBufferManager(1024); armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); std::unique_ptr sendTimelinePacket = std::make_unique(mockBufferManager); TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket); @@ -79,7 +83,11 @@ TEST_CASE("SendWellKnownLabelsAndEventClassesTest") { MockBufferManager mockBufferManager(1024); armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); SendTimelinePacket sendTimelinePacket(mockBufferManager); CHECK_NOTHROW(TimelineUtilityMethods::SendWellKnownLabelsAndEventClasses(sendTimelinePacket)); @@ -207,7 +215,11 @@ TEST_CASE("CreateNamedTypedChildEntityTest") { MockBufferManager mockBufferManager(1024); armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); std::unique_ptr sendTimelinePacket = std::make_unique(mockBufferManager); TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket); @@ -295,7 +307,11 @@ TEST_CASE("DeclareLabelTest") { MockBufferManager mockBufferManager(1024); armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); std::unique_ptr sendTimelinePacket = std::make_unique(mockBufferManager); TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket); @@ -325,7 +341,11 @@ TEST_CASE("CreateNameTypeEntityInvalidTest") { MockBufferManager mockBufferManager(1024); armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); std::unique_ptr sendTimelinePacket = std::make_unique(mockBufferManager); TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket); @@ -351,7 +371,11 @@ TEST_CASE("CreateNameTypeEntityTest") { MockBufferManager mockBufferManager(1024); armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); std::unique_ptr sendTimelinePacket = std::make_unique(mockBufferManager); TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket); @@ -419,7 +443,11 @@ TEST_CASE("RecordEventTest") { MockBufferManager mockBufferManager(1024); armnn::ArmNNProfilingServiceInitialiser initialiser; - ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); std::unique_ptr sendTimelinePacket = std::make_unique(mockBufferManager); TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket); // Generate first guid to ensure that the named typed entity guid is not 0 on local single test. diff --git a/tests/profiling/gatordmock/tests/GatordMockTests.cpp b/tests/profiling/gatordmock/tests/GatordMockTests.cpp index d4fbeb3151..41f4d743a1 100644 --- a/tests/profiling/gatordmock/tests/GatordMockTests.cpp +++ b/tests/profiling/gatordmock/tests/GatordMockTests.cpp @@ -10,6 +10,8 @@ #include #include +#include + #include #include @@ -255,7 +257,11 @@ TEST_CASE("GatorDMockEndToEnd") options.m_TimelineEnabled = true; armnn::ArmNNProfilingServiceInitialiser initialiser; - arm::pipe::ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser); + arm::pipe::ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, + initialiser, + arm::pipe::ARMNN_SOFTWARE_INFO, + arm::pipe::ARMNN_SOFTWARE_VERSION, + arm::pipe::ARMNN_HARDWARE_VERSION); profilingService.ResetExternalProfilingOptions(options, true); // Bring the profiling service to the "WaitingForAck" state -- cgit v1.2.1