diff options
Diffstat (limited to 'src/profiling')
23 files changed, 396 insertions, 146 deletions
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 <ArmNNProfilingServiceInitialiser.hpp> -#include <armnn/profiling/ArmNNProfiling.hpp> - #include <common/include/ProfilingException.hpp> #include <fmt/format.h> @@ -54,10 +51,10 @@ void ActivateTimelineReportingCommandHandler::operator()(const arm::pipe::Packet m_TimelineReporting = true; - armnn::ArmNNProfilingServiceInitialiser initialiser; - std::unique_ptr<IProfilingService> 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<IReportStructure&> reportStructure, std::atomic<bool>& 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<bool>& m_TimelineReporting; INotifyBackends& m_BackendNotifier; + IProfilingService& m_ProfilingService; arm::pipe::Optional<IReportStructure&> 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> IProfilingService::CreateProfilingService( uint16_t maxGlobalCounterId, IInitialiseProfilingService& initialiser, + const std::string& softwareInfo, + const std::string& softwareVersion, + const std::string& hardwareVersion, arm::pipe::Optional<IReportStructure&> reportStructure) { - return std::make_unique<ProfilingService>(maxGlobalCounterId, initialiser, reportStructure); + return std::make_unique<ProfilingService>(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<IProfilingService> CreateProfilingService( uint16_t maxGlobalCounterId, IInitialiseProfilingService& initialiser, + const std::string& softwareInfo, + const std::string& softwareVersion, + const std::string& hardwareVersion, arm::pipe::Optional<IReportStructure&> reportStructure = arm::pipe::EmptyOptional()); virtual ~IProfilingService() {}; virtual std::unique_ptr<ISendTimelinePacket> 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 <common/include/CommandHandlerFunctor.hpp> #include <common/include/Logging.hpp> 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 <armnn/profiling/ArmNNProfiling.hpp> #include <armnn/backends/profiling/IBackendProfilingContext.hpp> @@ -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<IReportStructure&> 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 <common/include/Assert.hpp> #include <common/include/CommonProfilingUtils.hpp> +#include <common/include/NumericCast.hpp> #include <common/include/ProfilingException.hpp> #include <common/include/SwTrace.hpp> #include <armnn/Version.hpp> -#include <WallClockTimer.hpp> - - -#include <common/include/NumericCast.hpp> - #include <fstream> #include <iostream> #include <limits> @@ -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<uint32_t, uint32_t> 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<uint32_t>(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<uint32_t>(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<uint32_t>; using IndexValuePairsVector = std::vector<CounterValue>; - 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 <common/include/LabelsAndEventClasses.hpp> - - -#include <armnnUtils/Threads.hpp> +#include <common/include/Threads.hpp> 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 <armnn/Types.hpp> - 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 <SendCounterPacket.hpp> #include <SendThread.hpp> +#include <armnn/BackendId.hpp> +#include <armnn/profiling/ArmNNProfiling.hpp> + #include <common/include/Assert.hpp> #include <common/include/IgnoreUnused.hpp> #include <common/include/NumericCast.hpp> @@ -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 <armnn/profiling/ArmNNProfiling.hpp> #include <ProfilingService.hpp> -#include <armnnUtils/Threads.hpp> #include <common/include/Assert.hpp> #include <common/include/LabelsAndEventClasses.hpp> #include <common/include/NumericCast.hpp> #include <common/include/Processes.hpp> +#include <common/include/Threads.hpp> #include <TestUtils.hpp> @@ -27,9 +27,9 @@ uint32_t GetStreamMetaDataPacketSize() { uint32_t sizeUint32 = sizeof(uint32_t); uint32_t payloadSize = 0; - payloadSize += arm::pipe::numeric_cast<uint32_t>(GetSoftwareInfo().size()) + 1; - payloadSize += arm::pipe::numeric_cast<uint32_t>(GetHardwareVersion().size()) + 1; - payloadSize += arm::pipe::numeric_cast<uint32_t>(GetSoftwareVersion().size()) + 1; + payloadSize += arm::pipe::numeric_cast<uint32_t>(arm::pipe::ARMNN_SOFTWARE_INFO.size()) + 1; + payloadSize += arm::pipe::numeric_cast<uint32_t>(arm::pipe::ARMNN_HARDWARE_VERSION.size()) + 1; + payloadSize += arm::pipe::numeric_cast<uint32_t>(arm::pipe::ARMNN_SOFTWARE_VERSION.size()) + 1; payloadSize += arm::pipe::numeric_cast<uint32_t>(GetProcessName().size()) + 1; // Add packetVersionEntries @@ -128,7 +128,11 @@ ProfilingGuid VerifyTimelineLabelBinaryPacketData(arm::pipe::Optional<ProfilingG else { 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(readProfilingGuid == profilingService.GetStaticId(label)); } @@ -343,7 +347,7 @@ ProfilingGuid VerifyTimelineEventBinaryPacket(arm::pipe::Optional<uint64_t> 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 <BufferManager.hpp> #include <ProfilingService.hpp> +#include <armnn/profiling/ArmNNProfiling.hpp> + #include <common/include/Optional.hpp> #include <common/include/ProfilingGuid.hpp> @@ -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<uint32_t>(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<uint16_t> 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<uint16_t> 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 <IProfilingConnection.hpp> #include <ProfilingService.hpp> +#include <armnn/profiling/ArmNNProfiling.hpp> + #include <common/include/CommandHandlerFunctor.hpp> #include <common/include/Logging.hpp> @@ -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<uint16_t> 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<uint64_t >(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<uint32_t>(GetSoftwareInfo().size()) + 1; - uint32_t hardwareVersionSize = arm::pipe::numeric_cast<uint32_t>(GetHardwareVersion().size()) + 1; - uint32_t softwareVersionSize = arm::pipe::numeric_cast<uint32_t>(GetSoftwareVersion().size()) + 1; + uint32_t infoSize = arm::pipe::numeric_cast<uint32_t>(arm::pipe::ARMNN_SOFTWARE_INFO.size()) + 1; + uint32_t hardwareVersionSize = arm::pipe::numeric_cast<uint32_t>(arm::pipe::ARMNN_HARDWARE_VERSION.size()) + 1; + uint32_t softwareVersionSize = arm::pipe::numeric_cast<uint32_t>(arm::pipe::ARMNN_SOFTWARE_VERSION.size()) + 1; uint32_t processNameSize = arm::pipe::numeric_cast<uint32_t>(processName.size()) + 1; // Supported Packets @@ -340,7 +362,10 @@ TEST_CASE("SendStreamMetaDataPacketTest") uint32_t packetEntries = static_cast<uint32_t>(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<uint32_t>(pid)); offset += sizeUint32; uint32_t poolOffset = 10 * sizeUint32; @@ -390,19 +415,22 @@ TEST_CASE("SendStreamMetaDataPacketTest") offset += sizeUint32; if (infoSize) { - CHECK(strcmp(reinterpret_cast<const char *>(&readData2[offset]), GetSoftwareInfo().c_str()) == 0); + CHECK(strcmp(reinterpret_cast<const char *>(&readData2[offset]), + arm::pipe::ARMNN_SOFTWARE_INFO.c_str()) == 0); offset += infoSize; } if (hardwareVersionSize) { - CHECK(strcmp(reinterpret_cast<const char *>(&readData2[offset]), GetHardwareVersion().c_str()) == 0); + CHECK(strcmp(reinterpret_cast<const char *>(&readData2[offset]), + arm::pipe::ARMNN_HARDWARE_VERSION.c_str()) == 0); offset += hardwareVersionSize; } if (softwareVersionSize) { - CHECK(strcmp(reinterpret_cast<const char *>(&readData2[offset]), GetSoftwareVersion().c_str()) == 0); + CHECK(strcmp(reinterpret_cast<const char *>(&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 <ProfilingUtils.hpp> #include <IProfilingConnectionFactory.hpp> +#include <armnn/profiling/ArmNNProfiling.hpp> + #include <common/include/IgnoreUnused.hpp> #include <common/include/NumericCast.hpp> @@ -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 <ProfilingUtils.hpp> #include <SendTimelinePacket.hpp> #include <armnn/profiling/ArmNNProfiling.hpp> -#include <armnnUtils/Threads.hpp> #include <TimelinePacketWriterFactory.hpp> -#include <common/include/SwTrace.hpp> #include <common/include/LabelsAndEventClasses.hpp> +#include <common/include/SwTrace.hpp> +#include <common/include/Threads.hpp> #include <doctest/doctest.h> @@ -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<ISendTimelinePacket> 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 <ProfilingUtils.hpp> -#include <armnnUtils/Threads.hpp> - #include <common/include/NumericCast.hpp> #include <common/include/SwTrace.hpp> +#include <common/include/Threads.hpp> #include <doctest/doctest.h> @@ -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<unsigned char> 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<unsigned char> 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<unsigned char> 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<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(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<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(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<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(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<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(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<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(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<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager); TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket); // Generate first guid to ensure that the named typed entity guid is not 0 on local single test. |