diff options
author | Jim Flynn <jim.flynn@arm.com> | 2020-07-20 16:57:44 +0100 |
---|---|---|
committer | Jim Flynn <jim.flynn@arm.com> | 2020-07-29 15:35:15 +0100 |
commit | bbfe603e5ae42317a2b67d713d00882bea341c88 (patch) | |
tree | 8d8a78d6836384fb92fb9741c865443624dfec68 /src/profiling/test | |
parent | a9c2ce123a6a5a68728d040a0323c482bbe46903 (diff) | |
download | armnn-bbfe603e5ae42317a2b67d713d00882bea341c88.tar.gz |
IVGCVSW-5166 Pull out the common and server side code into standalone libraries
Change-Id: I180f84c493a9b2be4b93b25d312ebdd9e71b1735
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
Diffstat (limited to 'src/profiling/test')
-rw-r--r-- | src/profiling/test/BufferTests.cpp | 10 | ||||
-rw-r--r-- | src/profiling/test/PrintPacketHeaderHandler.cpp | 5 | ||||
-rw-r--r-- | src/profiling/test/PrintPacketHeaderHandler.hpp | 7 | ||||
-rw-r--r-- | src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp | 12 | ||||
-rw-r--r-- | src/profiling/test/ProfilingMocks.hpp | 6 | ||||
-rw-r--r-- | src/profiling/test/ProfilingTests.cpp | 361 | ||||
-rw-r--r-- | src/profiling/test/ProfilingTests.hpp | 22 | ||||
-rw-r--r-- | src/profiling/test/RequestCountersPacketHandler.cpp | 10 | ||||
-rw-r--r-- | src/profiling/test/RequestCountersPacketHandler.hpp | 7 | ||||
-rw-r--r-- | src/profiling/test/SendCounterPacketTests.cpp | 32 | ||||
-rw-r--r-- | src/profiling/test/SendTimelinePacketTests.cpp | 28 | ||||
-rw-r--r-- | src/profiling/test/TestTimelinePacketHandler.cpp | 35 | ||||
-rw-r--r-- | src/profiling/test/TestTimelinePacketHandler.hpp | 21 | ||||
-rw-r--r-- | src/profiling/test/TimelineModel.cpp | 54 | ||||
-rw-r--r-- | src/profiling/test/TimelineModel.hpp | 34 | ||||
-rw-r--r-- | src/profiling/test/TimelinePacketTests.cpp | 10 |
16 files changed, 344 insertions, 310 deletions
diff --git a/src/profiling/test/BufferTests.cpp b/src/profiling/test/BufferTests.cpp index 804335138d..7a92ee19e5 100644 --- a/src/profiling/test/BufferTests.cpp +++ b/src/profiling/test/BufferTests.cpp @@ -7,6 +7,8 @@ #include "PacketBuffer.hpp" #include "ProfilingUtils.hpp" +#include <common/include/SwTrace.hpp> + #include <armnn/Exceptions.hpp> #include <boost/test/unit_test.hpp> @@ -380,8 +382,8 @@ BOOST_AUTO_TEST_CASE(ReadSwTraceMessageExceptionTest0) unsigned int uint32_t_size = sizeof(uint32_t); unsigned int offset = uint32_t_size; - BOOST_CHECK_THROW(ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()), - armnn::RuntimeException); + BOOST_CHECK_THROW(arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()), + arm::pipe::ProfilingException); } @@ -402,8 +404,8 @@ BOOST_AUTO_TEST_CASE(ReadSwTraceMessageExceptionTest1) unsigned int uint32_t_size = sizeof(uint32_t); unsigned int offset = uint32_t_size; - BOOST_CHECK_THROW(ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()), - armnn::RuntimeException); + BOOST_CHECK_THROW(arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()), + arm::pipe::ProfilingException); } diff --git a/src/profiling/test/PrintPacketHeaderHandler.cpp b/src/profiling/test/PrintPacketHeaderHandler.cpp index 24095d8250..f85a7b1fcb 100644 --- a/src/profiling/test/PrintPacketHeaderHandler.cpp +++ b/src/profiling/test/PrintPacketHeaderHandler.cpp @@ -1,11 +1,12 @@ // -// Copyright © 2020 Arm Ltd. All rights reserved. +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // #include "PrintPacketHeaderHandler.hpp" #include <iostream> +#include <sstream> namespace armnn { @@ -18,7 +19,7 @@ std::vector<uint32_t> PrintPacketHeaderHandler::GetHeadersAccepted() return std::vector<uint32_t>(); } -void PrintPacketHeaderHandler::HandlePacket(const Packet& packet) +void PrintPacketHeaderHandler::HandlePacket(const arm::pipe::Packet& packet) { std::stringstream ss; ss << "Handler Received Outgoing Packet [" << packet.GetPacketFamily() << ":" << packet.GetPacketId() << "]"; diff --git a/src/profiling/test/PrintPacketHeaderHandler.hpp b/src/profiling/test/PrintPacketHeaderHandler.hpp index 6564f3cea5..397da0b8ea 100644 --- a/src/profiling/test/PrintPacketHeaderHandler.hpp +++ b/src/profiling/test/PrintPacketHeaderHandler.hpp @@ -1,12 +1,13 @@ // -// Copyright © 2020 Arm Ltd. All rights reserved. +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // #pragma once #include <armnn/profiling/ILocalPacketHandler.hpp> -#include <Packet.hpp> + +#include <common/include/Packet.hpp> namespace armnn { @@ -18,7 +19,7 @@ class PrintPacketHeaderHandler : public ILocalPacketHandler { virtual std::vector<uint32_t> GetHeadersAccepted(); - virtual void HandlePacket(const Packet& packet); + virtual void HandlePacket(const arm::pipe::Packet& packet); }; } // namespace profiling diff --git a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp index 6784ddabcb..d6700bc41a 100644 --- a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp +++ b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2019 Arm Ltd. All rights reserved. +// Copyright © 2019 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -32,7 +32,7 @@ public: { // populate packet data and construct packet std::memcpy(m_PacketData.get(), g_DataPtr, g_DataLength); - m_Packet = std::make_unique<Packet>(0u, g_DataLength, m_PacketData); + m_Packet = std::make_unique<arm::pipe::Packet>(0u, g_DataLength, m_PacketData); } ~DummyProfilingConnection() = default; @@ -54,7 +54,7 @@ public: return true; } - Packet ReadPacket(uint32_t timeout) override + arm::pipe::Packet ReadPacket(uint32_t timeout) override { armnn::IgnoreUnused(timeout); return std::move(*m_Packet); @@ -63,7 +63,7 @@ public: private: bool m_Open; std::unique_ptr<unsigned char[]> m_PacketData; - std::unique_ptr<Packet> m_Packet; + std::unique_ptr<arm::pipe::Packet> m_Packet; }; std::vector<char> ReadDumpFile(const std::string& dumpFileName) @@ -105,8 +105,8 @@ BOOST_AUTO_TEST_CASE(DumpIncomingValidFile) ProfilingConnectionDumpToFileDecorator decorator(std::make_unique<DummyProfilingConnection>(), options, false); // NOTE: unique_ptr is needed here because operator=() is deleted for Packet - std::unique_ptr<Packet> packet; - BOOST_CHECK_NO_THROW(packet = std::make_unique<Packet>(decorator.ReadPacket(0))); + std::unique_ptr<arm::pipe::Packet> packet; + BOOST_CHECK_NO_THROW(packet = std::make_unique<arm::pipe::Packet>(decorator.ReadPacket(0))); decorator.Close(); diff --git a/src/profiling/test/ProfilingMocks.hpp b/src/profiling/test/ProfilingMocks.hpp index e4f71f932c..8bcf27a8d1 100644 --- a/src/profiling/test/ProfilingMocks.hpp +++ b/src/profiling/test/ProfilingMocks.hpp @@ -121,7 +121,7 @@ public: } } - bool WritePacket(Packet&& packet) + bool WritePacket(arm::pipe::Packet&& packet) { std::lock_guard<std::mutex> lock(m_Mutex); @@ -129,7 +129,7 @@ public: return true; } - Packet ReadPacket(uint32_t timeout) override + arm::pipe::Packet ReadPacket(uint32_t timeout) override { IgnoreUnused(timeout); @@ -156,7 +156,7 @@ public: private: bool m_IsOpen; std::vector<std::pair<PacketType, uint32_t>> m_WrittenData; - Packet m_Packet; + arm::pipe::Packet m_Packet; mutable std::mutex m_Mutex; }; diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index bc16bb952b..f616442df0 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -7,18 +7,15 @@ #include "ProfilingTestUtils.hpp" #include <backends/BackendProfiling.hpp> +#include <common/include/EncodeVersion.hpp> +#include <common/include/PacketVersionResolver.hpp> +#include <common/include/SwTrace.hpp> #include <CommandHandler.hpp> -#include <CommandHandlerKey.hpp> -#include <CommandHandlerRegistry.hpp> -#include <common/include/SocketConnectionException.hpp> #include <ConnectionAcknowledgedCommandHandler.hpp> #include <CounterDirectory.hpp> #include <CounterIdMap.hpp> -#include <EncodeVersion.hpp> #include <Holder.hpp> #include <ICounterValues.hpp> -#include <Packet.hpp> -#include <PacketVersionResolver.hpp> #include <PeriodicCounterCapture.hpp> #include <PeriodicCounterSelectionCommandHandler.hpp> #include <ProfilingStateMachine.hpp> @@ -37,6 +34,11 @@ #include <armnn/Utils.hpp> #include <armnn/utility/IgnoreUnused.hpp> +#include <common/include/CommandHandlerKey.hpp> +#include <common/include/CommandHandlerRegistry.hpp> +#include <common/include/SocketConnectionException.hpp> +#include <common/include/Packet.hpp> + #include <boost/numeric/conversion/cast.hpp> #include <cstdint> @@ -54,16 +56,16 @@ BOOST_AUTO_TEST_SUITE(ExternalProfiling) BOOST_AUTO_TEST_CASE(CheckCommandHandlerKeyComparisons) { - CommandHandlerKey testKey1_0(1, 1, 1); - CommandHandlerKey testKey1_1(1, 1, 1); - CommandHandlerKey testKey1_2(1, 2, 1); + arm::pipe::CommandHandlerKey testKey1_0(1, 1, 1); + arm::pipe::CommandHandlerKey testKey1_1(1, 1, 1); + arm::pipe::CommandHandlerKey testKey1_2(1, 2, 1); - CommandHandlerKey testKey0(0, 1, 1); - CommandHandlerKey testKey1(0, 1, 1); - CommandHandlerKey testKey2(0, 1, 1); - CommandHandlerKey testKey3(0, 0, 0); - CommandHandlerKey testKey4(0, 2, 2); - CommandHandlerKey testKey5(0, 0, 2); + arm::pipe::CommandHandlerKey testKey0(0, 1, 1); + arm::pipe::CommandHandlerKey testKey1(0, 1, 1); + arm::pipe::CommandHandlerKey testKey2(0, 1, 1); + arm::pipe::CommandHandlerKey testKey3(0, 0, 0); + arm::pipe::CommandHandlerKey testKey4(0, 2, 2); + arm::pipe::CommandHandlerKey testKey5(0, 0, 2); BOOST_CHECK(testKey1_0 > testKey0); BOOST_CHECK(testKey1_0 == testKey1_1); @@ -88,30 +90,32 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerKeyComparisons) BOOST_CHECK(testKey1.GetPacketId() == 1); BOOST_CHECK(testKey1.GetVersion() == 1); - std::vector<CommandHandlerKey> vect = { CommandHandlerKey(0, 0, 1), CommandHandlerKey(0, 2, 0), - CommandHandlerKey(0, 1, 0), CommandHandlerKey(0, 2, 1), - CommandHandlerKey(0, 1, 1), CommandHandlerKey(0, 0, 1), - CommandHandlerKey(0, 2, 0), CommandHandlerKey(0, 0, 0) }; + std::vector<arm::pipe::CommandHandlerKey> vect = { + arm::pipe::CommandHandlerKey(0, 0, 1), arm::pipe::CommandHandlerKey(0, 2, 0), + arm::pipe::CommandHandlerKey(0, 1, 0), arm::pipe::CommandHandlerKey(0, 2, 1), + arm::pipe::CommandHandlerKey(0, 1, 1), arm::pipe::CommandHandlerKey(0, 0, 1), + arm::pipe::CommandHandlerKey(0, 2, 0), arm::pipe::CommandHandlerKey(0, 0, 0) }; std::sort(vect.begin(), vect.end()); - std::vector<CommandHandlerKey> expectedVect = { CommandHandlerKey(0, 0, 0), CommandHandlerKey(0, 0, 1), - CommandHandlerKey(0, 0, 1), CommandHandlerKey(0, 1, 0), - CommandHandlerKey(0, 1, 1), CommandHandlerKey(0, 2, 0), - CommandHandlerKey(0, 2, 0), CommandHandlerKey(0, 2, 1) }; + std::vector<arm::pipe::CommandHandlerKey> expectedVect = { + arm::pipe::CommandHandlerKey(0, 0, 0), arm::pipe::CommandHandlerKey(0, 0, 1), + arm::pipe::CommandHandlerKey(0, 0, 1), arm::pipe::CommandHandlerKey(0, 1, 0), + arm::pipe::CommandHandlerKey(0, 1, 1), arm::pipe::CommandHandlerKey(0, 2, 0), + arm::pipe::CommandHandlerKey(0, 2, 0), arm::pipe::CommandHandlerKey(0, 2, 1) }; BOOST_CHECK(vect == expectedVect); } BOOST_AUTO_TEST_CASE(CheckPacketKeyComparisons) { - PacketKey key0(0, 0); - PacketKey key1(0, 0); - PacketKey key2(0, 1); - PacketKey key3(0, 2); - PacketKey key4(1, 0); - PacketKey key5(1, 0); - PacketKey key6(1, 1); + arm::pipe::PacketKey key0(0, 0); + arm::pipe::PacketKey key1(0, 0); + arm::pipe::PacketKey key2(0, 1); + arm::pipe::PacketKey key3(0, 2); + arm::pipe::PacketKey key4(1, 0); + arm::pipe::PacketKey key5(1, 0); + arm::pipe::PacketKey key6(1, 1); BOOST_CHECK(!(key0 < key1)); BOOST_CHECK(!(key0 > key1)); @@ -130,7 +134,7 @@ BOOST_AUTO_TEST_CASE(CheckPacketKeyComparisons) BOOST_AUTO_TEST_CASE(CheckCommandHandler) { - PacketVersionResolver packetVersionResolver; + arm::pipe::PacketVersionResolver packetVersionResolver; ProfilingStateMachine profilingStateMachine; TestProfilingConnectionBase testProfilingConnectionBase; @@ -147,7 +151,7 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandler) sendCounterPacket, sendTimelinePacket, profilingStateMachine, mockProfilingServiceStatus); - CommandHandlerRegistry commandHandlerRegistry; + arm::pipe::CommandHandlerRegistry commandHandlerRegistry; commandHandlerRegistry.RegisterFunctor(&connectionAcknowledgedCommandHandler); @@ -260,31 +264,31 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandler) BOOST_AUTO_TEST_CASE(CheckEncodeVersion) { - Version version1(12); + arm::pipe::Version version1(12); BOOST_CHECK(version1.GetMajor() == 0); BOOST_CHECK(version1.GetMinor() == 0); BOOST_CHECK(version1.GetPatch() == 12); - Version version2(4108); + arm::pipe::Version version2(4108); BOOST_CHECK(version2.GetMajor() == 0); BOOST_CHECK(version2.GetMinor() == 1); BOOST_CHECK(version2.GetPatch() == 12); - Version version3(4198412); + arm::pipe::Version version3(4198412); BOOST_CHECK(version3.GetMajor() == 1); BOOST_CHECK(version3.GetMinor() == 1); BOOST_CHECK(version3.GetPatch() == 12); - Version version4(0); + arm::pipe::Version version4(0); BOOST_CHECK(version4.GetMajor() == 0); BOOST_CHECK(version4.GetMinor() == 0); BOOST_CHECK(version4.GetPatch() == 0); - Version version5(1, 0, 0); + arm::pipe::Version version5(1, 0, 0); BOOST_CHECK(version5.GetEncodedValue() == 4194304); } @@ -295,7 +299,7 @@ BOOST_AUTO_TEST_CASE(CheckPacketClass) std::unique_ptr<unsigned char[]> packetData1 = std::make_unique<unsigned char[]>(0); std::unique_ptr<unsigned char[]> nullPacketData; - Packet packetTest0(472580096, length, packetData0); + arm::pipe::Packet packetTest0(472580096, length, packetData0); BOOST_CHECK(packetTest0.GetHeader() == 472580096); BOOST_CHECK(packetTest0.GetPacketFamily() == 7); @@ -304,15 +308,15 @@ BOOST_AUTO_TEST_CASE(CheckPacketClass) BOOST_CHECK(packetTest0.GetPacketType() == 3); BOOST_CHECK(packetTest0.GetPacketClass() == 5); - BOOST_CHECK_THROW(Packet packetTest1(472580096, 0, packetData1), armnn::Exception); - BOOST_CHECK_NO_THROW(Packet packetTest2(472580096, 0, nullPacketData)); + BOOST_CHECK_THROW(arm::pipe::Packet packetTest1(472580096, 0, packetData1), arm::pipe::InvalidArgumentException); + BOOST_CHECK_NO_THROW(arm::pipe::Packet packetTest2(472580096, 0, nullPacketData)); - Packet packetTest3(472580096, 0, nullPacketData); + arm::pipe::Packet packetTest3(472580096, 0, nullPacketData); BOOST_CHECK(packetTest3.GetLength() == 0); BOOST_CHECK(packetTest3.GetData() == nullptr); const unsigned char* packetTest0Data = packetTest0.GetData(); - Packet packetTest4(std::move(packetTest0)); + arm::pipe::Packet packetTest4(std::move(packetTest0)); BOOST_CHECK(packetTest0.GetData() == nullptr); BOOST_CHECK(packetTest4.GetData() == packetTest0Data); @@ -334,12 +338,15 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerFunctor) TestFunctorB testFunctorB(8, 963, version); TestFunctorC testFunctorC(5, 983, version); - CommandHandlerKey keyA(testFunctorA.GetFamilyId(), testFunctorA.GetPacketId(), testFunctorA.GetVersion()); - CommandHandlerKey keyB(testFunctorB.GetFamilyId(), testFunctorB.GetPacketId(), testFunctorB.GetVersion()); - CommandHandlerKey keyC(testFunctorC.GetFamilyId(), testFunctorC.GetPacketId(), testFunctorC.GetVersion()); + arm::pipe::CommandHandlerKey keyA( + testFunctorA.GetFamilyId(), testFunctorA.GetPacketId(), testFunctorA.GetVersion()); + arm::pipe::CommandHandlerKey keyB( + testFunctorB.GetFamilyId(), testFunctorB.GetPacketId(), testFunctorB.GetVersion()); + arm::pipe::CommandHandlerKey keyC( + testFunctorC.GetFamilyId(), testFunctorC.GetPacketId(), testFunctorC.GetVersion()); // Create the unwrapped map to simulate the Command Handler Registry - std::map<CommandHandlerKey, CommandHandlerFunctor*> registry; + std::map<arm::pipe::CommandHandlerKey, arm::pipe::CommandHandlerFunctor*> registry; registry.insert(std::make_pair(keyB, &testFunctorB)); registry.insert(std::make_pair(keyA, &testFunctorA)); @@ -357,22 +364,25 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerFunctor) std::unique_ptr<unsigned char[]> packetDataB; std::unique_ptr<unsigned char[]> packetDataC; - Packet packetA(500000000, 0, packetDataA); - Packet packetB(600000000, 0, packetDataB); - Packet packetC(400000000, 0, packetDataC); + arm::pipe::Packet packetA(500000000, 0, packetDataA); + arm::pipe::Packet packetB(600000000, 0, packetDataB); + arm::pipe::Packet packetC(400000000, 0, packetDataC); // Check the correct operator of derived class is called - registry.at(CommandHandlerKey(packetA.GetPacketFamily(), packetA.GetPacketId(), version))->operator()(packetA); + registry.at(arm::pipe::CommandHandlerKey( + packetA.GetPacketFamily(), packetA.GetPacketId(), version))->operator()(packetA); BOOST_CHECK(testFunctorA.GetCount() == 1); BOOST_CHECK(testFunctorB.GetCount() == 0); BOOST_CHECK(testFunctorC.GetCount() == 0); - registry.at(CommandHandlerKey(packetB.GetPacketFamily(), packetB.GetPacketId(), version))->operator()(packetB); + registry.at(arm::pipe::CommandHandlerKey( + packetB.GetPacketFamily(), packetB.GetPacketId(), version))->operator()(packetB); BOOST_CHECK(testFunctorA.GetCount() == 1); BOOST_CHECK(testFunctorB.GetCount() == 1); BOOST_CHECK(testFunctorC.GetCount() == 0); - registry.at(CommandHandlerKey(packetC.GetPacketFamily(), packetC.GetPacketId(), version))->operator()(packetC); + registry.at(arm::pipe::CommandHandlerKey( + packetC.GetPacketFamily(), packetC.GetPacketId(), version))->operator()(packetC); BOOST_CHECK(testFunctorA.GetCount() == 1); BOOST_CHECK(testFunctorB.GetCount() == 1); BOOST_CHECK(testFunctorC.GetCount() == 1); @@ -388,7 +398,7 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerRegistry) TestFunctorC testFunctorC(5, 983, version); // Create the Command Handler Registry - CommandHandlerRegistry registry; + arm::pipe::CommandHandlerRegistry registry; // Register multiple different derived classes registry.RegisterFunctor(&testFunctorA); @@ -399,9 +409,9 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerRegistry) std::unique_ptr<unsigned char[]> packetDataB; std::unique_ptr<unsigned char[]> packetDataC; - Packet packetA(500000000, 0, packetDataA); - Packet packetB(600000000, 0, packetDataB); - Packet packetC(400000000, 0, packetDataC); + arm::pipe::Packet packetA(500000000, 0, packetDataA); + arm::pipe::Packet packetB(600000000, 0, packetDataB); + arm::pipe::Packet packetC(400000000, 0, packetDataC); // Check the correct operator of derived class is called registry.GetFunctor(packetA.GetPacketFamily(), packetA.GetPacketId(), version)->operator()(packetA); @@ -427,7 +437,7 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerRegistry) BOOST_CHECK(testFunctorC.GetCount() == 2); // Check that non-existent key returns nullptr for its functor - BOOST_CHECK_THROW(registry.GetFunctor(0, 0, 0), armnn::Exception); + BOOST_CHECK_THROW(registry.GetFunctor(0, 0, 0), arm::pipe::ProfilingException); } BOOST_AUTO_TEST_CASE(CheckPacketVersionResolver) @@ -439,9 +449,9 @@ BOOST_AUTO_TEST_CASE(CheckPacketVersionResolver) std::numeric_limits<uint32_t>::max()); // NOTE: Expected version is always 1.0.0, regardless of packetId - const Version expectedVersion(1, 0, 0); + const arm::pipe::Version expectedVersion(1, 0, 0); - PacketVersionResolver packetVersionResolver; + arm::pipe::PacketVersionResolver packetVersionResolver; constexpr unsigned int numTests = 10u; @@ -449,7 +459,7 @@ BOOST_AUTO_TEST_CASE(CheckPacketVersionResolver) { const uint32_t familyId = distribution(generator); const uint32_t packetId = distribution(generator); - Version resolvedVersion = packetVersionResolver.ResolvePacketVersion(familyId, packetId); + arm::pipe::Version resolvedVersion = packetVersionResolver.ResolvePacketVersion(familyId, packetId); BOOST_TEST(resolvedVersion == expectedVersion); } @@ -1407,16 +1417,16 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) // Register a counter with a valid parent category name and not associated with a device const Counter* counterWoDevice = nullptr; BOOST_CHECK_NO_THROW(counterWoDevice = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, - 26, - categoryName, - 0, - 1, - 123.45f, - "valid name 3", - "valid description", - armnn::EmptyOptional(),// Units - armnn::EmptyOptional(),// Number of cores - 0)); // Device UID + 26, + categoryName, + 0, + 1, + 123.45f, + "valid name 3", + "valid description", + armnn::EmptyOptional(),// Units + armnn::EmptyOptional(),// Number of cores + 0)); // Device UID BOOST_CHECK(counterDirectory.GetCounterCount() == 3); BOOST_CHECK(counterWoDevice); BOOST_CHECK(counterWoDevice->m_Uid > counter->m_Uid); @@ -1468,9 +1478,9 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) 123.45f, "valid name 5", std::string("valid description"), - armnn::EmptyOptional(), // Units - armnn::EmptyOptional(), // Number of cores - device->m_Uid)); // Device UID + armnn::EmptyOptional(), // Units + armnn::EmptyOptional(), // Number of cores + device->m_Uid)); // Device UID BOOST_CHECK(counterDirectory.GetCounterCount() == 4); BOOST_CHECK(counterWDevice); BOOST_CHECK(counterWDevice->m_Uid > counter->m_Uid); @@ -1499,7 +1509,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) armnn::EmptyOptional(),// Units armnn::EmptyOptional(),// No of cores armnn::EmptyOptional(),// Device UID - 0)); // CounterSet UID + 0)); // CounterSet UID BOOST_CHECK(counterDirectory.GetCounterCount() == 5); BOOST_CHECK(counterWoCounterSet); BOOST_CHECK(counterWoCounterSet->m_Uid > counter->m_Uid); @@ -1615,18 +1625,19 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) const Counter* counterWMultiCoreDeviceWParentCategory = nullptr; uint16_t numberOfCourse = multiCoreDeviceWParentCategory->m_Cores; BOOST_CHECK_NO_THROW(counterWMultiCoreDeviceWParentCategory = - counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, - 100, - categoryName, - 0, - 1, - 123.45f, - "valid name 10", - "valid description", - armnn::EmptyOptional(), // Units - numberOfCourse, // Number of cores - armnn::EmptyOptional(), // Device UID - armnn::EmptyOptional()));// Counter set UID + counterDirectory.RegisterCounter( + armnn::profiling::BACKEND_ID, + 100, + categoryName, + 0, + 1, + 123.45f, + "valid name 10", + "valid description", + armnn::EmptyOptional(), // Units + numberOfCourse, // Number of cores + armnn::EmptyOptional(), // Device UID + armnn::EmptyOptional()));// Counter set UID BOOST_CHECK(counterDirectory.GetCounterCount() == 26); BOOST_CHECK(counterWMultiCoreDeviceWParentCategory); BOOST_CHECK(counterWMultiCoreDeviceWParentCategory->m_Uid > counter->m_Uid); @@ -1718,10 +1729,10 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) BOOST_CHECK_NO_THROW(anotherCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, 24, anotherCategoryName, 1, 0, .00043f, "valid name", "valid description", - armnn::EmptyOptional(), // Units - armnn::EmptyOptional(), // Number of cores - device->m_Uid, // Device UID - counterSet->m_Uid)); // Counter set UID + armnn::EmptyOptional(), // Units + armnn::EmptyOptional(), // Number of cores + device->m_Uid, // Device UID + counterSet->m_Uid)); // Counter set UID BOOST_CHECK(counterDirectory.GetCounterCount() == 29); BOOST_CHECK(anotherCounter); BOOST_CHECK(anotherCounter->m_MaxCounterUid == anotherCounter->m_Uid); @@ -1804,7 +1815,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData) offset += sizeOfUint16; WriteUint16(data1, offset, 5000); - Packet packetA(packetId, dataLength1, uniqueData1); + arm::pipe::Packet packetA(packetId, dataLength1, uniqueData1); PeriodicCounterSelectionCommandHandler commandHandler(familyId, packetId, version, backendProfilingContext, counterIdMap, holder, 10000u, captureThread, @@ -1859,7 +1870,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData) WriteUint32(reinterpret_cast<unsigned char*>(uniqueData2.get()), 0, period2); - Packet packetB(packetId, dataLength2, uniqueData2); + arm::pipe::Packet packetB(packetId, dataLength2, uniqueData2); commandHandler(packetB); @@ -1911,7 +1922,7 @@ BOOST_AUTO_TEST_CASE(CheckTimelineActivationAndDeactivation) std::atomic<bool> m_timelineReporting; }; - PacketVersionResolver packetVersionResolver; + arm::pipe::PacketVersionResolver packetVersionResolver; BufferManager bufferManager(512); SendTimelinePacket sendTimelinePacket(bufferManager); @@ -1936,7 +1947,7 @@ BOOST_AUTO_TEST_CASE(CheckTimelineActivationAndDeactivation) uint32_t packetHeader1 = ConstructHeader(packetFamily1, packetId1); // Create the ActivateTimelineReportingPacket - Packet ActivateTimelineReportingPacket(packetHeader1); // Length == 0 + arm::pipe::Packet ActivateTimelineReportingPacket(packetHeader1); // Length == 0 BOOST_CHECK_THROW( activateTimelineReportingCommandHandler.operator()(ActivateTimelineReportingPacket), armnn::Exception); @@ -1968,7 +1979,7 @@ BOOST_AUTO_TEST_CASE(CheckTimelineActivationAndDeactivation) uint32_t packetHeader2 = ConstructHeader(packetFamily2, packetId2); // Create the DeactivateTimelineReportingPacket - Packet deactivateTimelineReportingPacket(packetHeader2); // Length == 0 + arm::pipe::Packet deactivateTimelineReportingPacket(packetHeader2); // Length == 0 stateMachine.Reset(); BOOST_CHECK_THROW( @@ -2036,7 +2047,7 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged) offset += sizeOfUint16; WriteUint16(data1, offset, 5000); - Packet packetA(connectionPacketId, dataLength1, uniqueData1); + arm::pipe::Packet packetA(connectionPacketId, dataLength1, uniqueData1); ProfilingStateMachine profilingState(ProfilingState::Uninitialised); BOOST_CHECK(profilingState.GetCurrentState() == ProfilingState::Uninitialised); @@ -2076,7 +2087,7 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged) // command handler received different packet const uint32_t differentPacketId = 0x40000; - Packet packetB(differentPacketId, dataLength1, uniqueData1); + arm::pipe::Packet packetB(differentPacketId, dataLength1, uniqueData1); profilingState.TransitionToState(ProfilingState::NotConnected); profilingState.TransitionToState(ProfilingState::WaitingForAck); ConnectionAcknowledgedCommandHandler differentCommandHandler(packetFamilyId, @@ -2093,7 +2104,7 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged) BOOST_AUTO_TEST_CASE(CheckSocketConnectionException) { // Check that creating a SocketProfilingConnection armnnProfiling in an exception as the Gator UDS doesn't exist. - BOOST_CHECK_THROW(new SocketProfilingConnection(), armnnProfiling::SocketConnectionException); + BOOST_CHECK_THROW(new SocketProfilingConnection(), arm::pipe::SocketConnectionException); } BOOST_AUTO_TEST_CASE(CheckSocketConnectionException2) @@ -2102,7 +2113,7 @@ BOOST_AUTO_TEST_CASE(CheckSocketConnectionException2) { new SocketProfilingConnection(); } - catch (const armnnProfiling::SocketConnectionException& ex) + catch (const arm::pipe::SocketConnectionException& ex) { BOOST_CHECK(ex.GetSocketFd() == 0); BOOST_CHECK(ex.GetErrorNo() == 111); @@ -2116,13 +2127,13 @@ BOOST_AUTO_TEST_CASE(SwTraceIsValidCharTest) // Only ASCII 7-bit encoding supported for (unsigned char c = 0; c < 128; c++) { - BOOST_CHECK(SwTraceCharPolicy::IsValidChar(c)); + BOOST_CHECK(arm::pipe::SwTraceCharPolicy::IsValidChar(c)); } // Not ASCII for (unsigned char c = 255; c >= 128; c++) { - BOOST_CHECK(!SwTraceCharPolicy::IsValidChar(c)); + BOOST_CHECK(!arm::pipe::SwTraceCharPolicy::IsValidChar(c)); } } @@ -2132,81 +2143,81 @@ BOOST_AUTO_TEST_CASE(SwTraceIsValidNameCharTest) const unsigned char validChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"; for (unsigned char i = 0; i < sizeof(validChars) / sizeof(validChars[0]) - 1; i++) { - BOOST_CHECK(SwTraceNameCharPolicy::IsValidChar(validChars[i])); + BOOST_CHECK(arm::pipe::SwTraceNameCharPolicy::IsValidChar(validChars[i])); } // Non alpha-numeric chars for (unsigned char c = 0; c < 48; c++) { - BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c)); + BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c)); } for (unsigned char c = 58; c < 65; c++) { - BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c)); + BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c)); } for (unsigned char c = 91; c < 95; c++) { - BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c)); + BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c)); } for (unsigned char c = 96; c < 97; c++) { - BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c)); + BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c)); } for (unsigned char c = 123; c < 128; c++) { - BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c)); + BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c)); } // Not ASCII for (unsigned char c = 255; c >= 128; c++) { - BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c)); + BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c)); } } BOOST_AUTO_TEST_CASE(IsValidSwTraceStringTest) { // Valid SWTrace strings - BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("")); - BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("_")); - BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("0123")); - BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("valid_string")); - BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("VALID_string_456")); - BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>(" ")); - BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("valid string")); - BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("!$%")); - BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("valid|\\~string#123")); + BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("")); + BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("_")); + BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("0123")); + BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("valid_string")); + BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("VALID_string_456")); + BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(" ")); + BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("valid string")); + BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("!$%")); + BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("valid|\\~string#123")); // Invalid SWTrace strings - BOOST_CHECK(!IsValidSwTraceString<SwTraceCharPolicy>("€£")); - BOOST_CHECK(!IsValidSwTraceString<SwTraceCharPolicy>("invalid‡string")); - BOOST_CHECK(!IsValidSwTraceString<SwTraceCharPolicy>("12Ž34")); + BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("€£")); + BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("invalid‡string")); + BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("12Ž34")); } BOOST_AUTO_TEST_CASE(IsValidSwTraceNameStringTest) { // Valid SWTrace name strings - BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>("")); - BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>("_")); - BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>("0123")); - BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>("valid_string")); - BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>("VALID_string_456")); + BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("")); + BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("_")); + BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("0123")); + BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("valid_string")); + BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("VALID_string_456")); // Invalid SWTrace name strings - BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>(" ")); - BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("invalid string")); - BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("!$%")); - BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("invalid|\\~string#123")); - BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("€£")); - BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("invalid‡string")); - BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("12Ž34")); + BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(" ")); + BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid string")); + BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("!$%")); + BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid|\\~string#123")); + BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("€£")); + BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid‡string")); + BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("12Ž34")); } template <typename SwTracePolicy> void StringToSwTraceStringTestHelper(const std::string& testString, std::vector<uint32_t> buffer, size_t expectedSize) { // Convert the test string to a SWTrace string - BOOST_CHECK(StringToSwTraceString<SwTracePolicy>(testString, buffer)); + BOOST_CHECK(arm::pipe::StringToSwTraceString<SwTracePolicy>(testString, buffer)); // The buffer must contain at least the length of the string BOOST_CHECK(!buffer.empty()); @@ -2230,22 +2241,22 @@ BOOST_AUTO_TEST_CASE(StringToSwTraceStringTest) std::vector<uint32_t> buffer; // Valid SWTrace strings (expected size in words) - StringToSwTraceStringTestHelper<SwTraceCharPolicy>("", buffer, 2); - StringToSwTraceStringTestHelper<SwTraceCharPolicy>("_", buffer, 2); - StringToSwTraceStringTestHelper<SwTraceCharPolicy>("0123", buffer, 3); - StringToSwTraceStringTestHelper<SwTraceCharPolicy>("valid_string", buffer, 5); - StringToSwTraceStringTestHelper<SwTraceCharPolicy>("VALID_string_456", buffer, 6); - StringToSwTraceStringTestHelper<SwTraceCharPolicy>(" ", buffer, 2); - StringToSwTraceStringTestHelper<SwTraceCharPolicy>("valid string", buffer, 5); - StringToSwTraceStringTestHelper<SwTraceCharPolicy>("!$%", buffer, 2); - StringToSwTraceStringTestHelper<SwTraceCharPolicy>("valid|\\~string#123", buffer, 6); + StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("", buffer, 2); + StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("_", buffer, 2); + StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("0123", buffer, 3); + StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("valid_string", buffer, 5); + StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("VALID_string_456", buffer, 6); + StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>(" ", buffer, 2); + StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("valid string", buffer, 5); + StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("!$%", buffer, 2); + StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("valid|\\~string#123", buffer, 6); // Invalid SWTrace strings - BOOST_CHECK(!StringToSwTraceString<SwTraceCharPolicy>("€£", buffer)); + BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>("€£", buffer)); BOOST_CHECK(buffer.empty()); - BOOST_CHECK(!StringToSwTraceString<SwTraceCharPolicy>("invalid‡string", buffer)); + BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>("invalid‡string", buffer)); BOOST_CHECK(buffer.empty()); - BOOST_CHECK(!StringToSwTraceString<SwTraceCharPolicy>("12Ž34", buffer)); + BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>("12Ž34", buffer)); BOOST_CHECK(buffer.empty()); } @@ -2254,26 +2265,26 @@ BOOST_AUTO_TEST_CASE(StringToSwTraceNameStringTest) std::vector<uint32_t> buffer; // Valid SWTrace namestrings (expected size in words) - StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("", buffer, 2); - StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("_", buffer, 2); - StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("0123", buffer, 3); - StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("valid_string", buffer, 5); - StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("VALID_string_456", buffer, 6); + StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("", buffer, 2); + StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("_", buffer, 2); + StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("0123", buffer, 3); + StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("valid_string", buffer, 5); + StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("VALID_string_456", buffer, 6); // Invalid SWTrace namestrings - BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>(" ", buffer)); + BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>(" ", buffer)); BOOST_CHECK(buffer.empty()); - BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("invalid string", buffer)); + BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid string", buffer)); BOOST_CHECK(buffer.empty()); - BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("!$%", buffer)); + BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("!$%", buffer)); BOOST_CHECK(buffer.empty()); - BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("invalid|\\~string#123", buffer)); + BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid|\\~string#123", buffer)); BOOST_CHECK(buffer.empty()); - BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("€£", buffer)); + BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("€£", buffer)); BOOST_CHECK(buffer.empty()); - BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("invalid‡string", buffer)); + BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid‡string", buffer)); BOOST_CHECK(buffer.empty()); - BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("12Ž34", buffer)); + BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("12Ž34", buffer)); BOOST_CHECK(buffer.empty()); } @@ -2414,7 +2425,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1) const uint32_t wrongPacketId = 47; const uint32_t wrongHeader = (wrongPacketId & 0x000003FF) << 16; - Packet wrongPacket(wrongHeader); + arm::pipe::Packet wrongPacket(wrongHeader); profilingStateMachine.TransitionToState(ProfilingState::Uninitialised); BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state @@ -2427,7 +2438,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1) const uint32_t rightHeader = (packetId & 0x000003FF) << 16; - Packet rightPacket(rightHeader); + arm::pipe::Packet rightPacket(rightHeader); BOOST_CHECK_NO_THROW(commandHandler(rightPacket)); // Right packet @@ -2473,7 +2484,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2) RequestCounterDirectoryCommandHandler commandHandler(familyId, packetId, version, counterDirectory, sendCounterPacket, sendTimelinePacket, profilingStateMachine); const uint32_t header = (packetId & 0x000003FF) << 16; - const Packet packet(header); + const arm::pipe::Packet packet(header); const Device* device = counterDirectory.RegisterDevice("deviceA", 1); BOOST_CHECK(device != nullptr); @@ -2587,7 +2598,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodConnectionAcknowledgedPacket) uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16); // Create the Connection Acknowledged Packet - Packet connectionAcknowledgedPacket(header); + arm::pipe::Packet connectionAcknowledgedPacket(header); // Write the packet to the mock profiling connection mockProfilingConnection->WritePacket(std::move(connectionAcknowledgedPacket)); @@ -2643,7 +2654,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodRequestCounterDirectoryPacket) uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16); // Create the Request Counter Directory packet - Packet requestCounterDirectoryPacket(header); + arm::pipe::Packet requestCounterDirectoryPacket(header); // Write the packet to the mock profiling connection mockProfilingConnection->WritePacket(std::move(requestCounterDirectoryPacket)); @@ -2720,8 +2731,9 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadPeriodicCounterSelectionPacketInval WriteUint16(data.get(), 6, counterUidB); // Create the Periodic Counter Selection packet - Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter - // Capture thread + // Length > 0, this will start the Period Counter Capture thread + arm::pipe::Packet periodicCounterSelectionPacket(header, length, data); + // Write the packet to the mock profiling connection mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket)); @@ -2783,7 +2795,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketNoCo uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16); // Create the Periodic Counter Selection packet - Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters + // Length == 0, this will disable the collection of counters + arm::pipe::Packet periodicCounterSelectionPacket(header); // Write the packet to the mock profiling connection mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket)); @@ -2861,8 +2874,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketSing WriteUint16(data.get(), 4, counterUid); // Create the Periodic Counter Selection packet - Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter - // Capture thread + // Length > 0, this will start the Period Counter Capture thread + arm::pipe::Packet periodicCounterSelectionPacket(header, length, data); // Write the packet to the mock profiling connection mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket)); @@ -2940,8 +2953,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketMult WriteUint16(data.get(), 6, counterUidB); // Create the Periodic Counter Selection packet - Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter - // Capture thread + // Length > 0, this will start the Period Counter Capture thread + arm::pipe::Packet periodicCounterSelectionPacket(header, length, data); // Write the packet to the mock profiling connection mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket)); @@ -3061,7 +3074,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPerJobCounterSelectionPacket) uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16); // Create the Per-Job Counter Selection packet - Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters + // Length == 0, this will disable the collection of counters + arm::pipe::Packet periodicCounterSelectionPacket(header); // Write the packet to the mock profiling connection mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket)); @@ -3218,7 +3232,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadConnectionAcknowledgedPacket) uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16); // Create the Connection Acknowledged Packet - Packet connectionAcknowledgedPacket(header); + arm::pipe::Packet connectionAcknowledgedPacket(header); // Write an invalid "Connection Acknowledged" packet into the mock profiling connection, to simulate an invalid // reply from an external profiling service mockProfilingConnection->WritePacket(std::move(connectionAcknowledgedPacket)); @@ -3282,7 +3296,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadRequestCounterDirectoryPacket) uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16); // Create the Request Counter Directory packet - Packet requestCounterDirectoryPacket(header); + arm::pipe::Packet requestCounterDirectoryPacket(header); // Write the packet to the mock profiling connection mockProfilingConnection->WritePacket(std::move(requestCounterDirectoryPacket)); @@ -3347,7 +3361,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadPeriodicCounterSelectionPacket) uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16); // Create the Periodic Counter Selection packet - Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters + // Length == 0, this will disable the collection of counters + arm::pipe::Packet periodicCounterSelectionPacket(header); // Write the packet to the mock profiling connection mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket)); diff --git a/src/profiling/test/ProfilingTests.hpp b/src/profiling/test/ProfilingTests.hpp index c350fd2860..f96a1c89ab 100644 --- a/src/profiling/test/ProfilingTests.hpp +++ b/src/profiling/test/ProfilingTests.hpp @@ -10,10 +10,12 @@ #include <armnn/Logging.hpp> #include <armnn/utility/PolymorphicDowncast.hpp> -#include <CommandHandlerFunctor.hpp> #include <IProfilingConnection.hpp> #include <ProfilingService.hpp> +#include <common/include/CommandHandlerFunctor.hpp> + + #include <boost/test/unit_test.hpp> #include <chrono> @@ -82,14 +84,14 @@ public: return false; } - Packet ReadPacket(uint32_t timeout) override + arm::pipe::Packet ReadPacket(uint32_t timeout) override { // First time we're called return a connection ack packet. After that always timeout. if (m_FirstCall) { m_FirstCall = false; // Return connection acknowledged packet - return Packet(65536); + return arm::pipe::Packet(65536); } else { @@ -108,7 +110,7 @@ public: : m_ReadRequests(0) {} - Packet ReadPacket(uint32_t timeout) override + arm::pipe::Packet ReadPacket(uint32_t timeout) override { // Return connection acknowledged packet after three timeouts if (m_ReadRequests % 3 == 0) @@ -118,7 +120,7 @@ public: throw armnn::TimeoutException("Simulate a timeout error\n"); } - return Packet(65536); + return arm::pipe::Packet(65536); } int ReadCalledCount() @@ -137,7 +139,7 @@ public: : m_ReadRequests(0) {} - Packet ReadPacket(uint32_t timeout) override + arm::pipe::Packet ReadPacket(uint32_t timeout) override { IgnoreUnused(timeout); ++m_ReadRequests; @@ -156,7 +158,7 @@ private: class TestProfilingConnectionBadAckPacket : public TestProfilingConnectionBase { public: - Packet ReadPacket(uint32_t timeout) override + arm::pipe::Packet ReadPacket(uint32_t timeout) override { IgnoreUnused(timeout); // Connection Acknowledged Packet header (word 0, word 1 is always zero): @@ -168,18 +170,18 @@ public: uint32_t packetId = 37; // Wrong packet id!!! uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16); - return Packet(header); + return arm::pipe::Packet(header); } }; -class TestFunctorA : public CommandHandlerFunctor +class TestFunctorA : public arm::pipe::CommandHandlerFunctor { public: using CommandHandlerFunctor::CommandHandlerFunctor; int GetCount() { return m_Count; } - void operator()(const Packet& packet) override + void operator()(const arm::pipe::Packet& packet) override { IgnoreUnused(packet); m_Count++; diff --git a/src/profiling/test/RequestCountersPacketHandler.cpp b/src/profiling/test/RequestCountersPacketHandler.cpp index 76c4b0cdc6..230c38857f 100644 --- a/src/profiling/test/RequestCountersPacketHandler.cpp +++ b/src/profiling/test/RequestCountersPacketHandler.cpp @@ -1,12 +1,12 @@ // -// Copyright © 2020 Arm Ltd. All rights reserved. +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // #include "RequestCountersPacketHandler.hpp" #include "DirectoryCaptureCommandHandler.hpp" -#include "PacketVersionResolver.hpp" +#include <common/include/PacketVersionResolver.hpp> #include <common/include/ProfilingException.hpp> @@ -23,13 +23,13 @@ std::vector<uint32_t> RequestCountersPacketHandler::GetHeadersAccepted() return headers; } -void RequestCountersPacketHandler::HandlePacket(const Packet& packet) +void RequestCountersPacketHandler::HandlePacket(const arm::pipe::Packet& packet) { if (packet.GetHeader() != m_CounterDirectoryMessageHeader) { return; } - armnn::profiling::PacketVersionResolver packetVersionResolver; + arm::pipe::PacketVersionResolver packetVersionResolver; DirectoryCaptureCommandHandler directoryCaptureCommandHandler( 0, 2, packetVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue()); directoryCaptureCommandHandler.operator()(packet); @@ -69,7 +69,7 @@ void RequestCountersPacketHandler::SendCounterSelectionPacket() offset += uint16_t_size; } - Packet packet(0x40000, bodySize, uniqueData); + arm::pipe::Packet packet(0x40000, bodySize, uniqueData); m_Connection->ReturnPacket(packet); } diff --git a/src/profiling/test/RequestCountersPacketHandler.hpp b/src/profiling/test/RequestCountersPacketHandler.hpp index 203edcc9df..b5e48626a7 100644 --- a/src/profiling/test/RequestCountersPacketHandler.hpp +++ b/src/profiling/test/RequestCountersPacketHandler.hpp @@ -1,5 +1,5 @@ // -// Copyright © 2020 Arm Ltd. All rights reserved. +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -7,9 +7,10 @@ #include <armnn/Types.hpp> #include <armnn/profiling/ILocalPacketHandler.hpp> -#include "Packet.hpp" #include "ProfilingUtils.hpp" +#include <common/include/Packet.hpp> + namespace armnn { @@ -26,7 +27,7 @@ public: std::vector<uint32_t> GetHeadersAccepted() override; // ILocalPacketHandler - void HandlePacket(const Packet& packet) override; // ILocalPacketHandler + void HandlePacket(const arm::pipe::Packet& packet) override; // ILocalPacketHandler void SetConnection(IInternalProfilingConnection* profilingConnection) override // ILocalPacketHandler { diff --git a/src/profiling/test/SendCounterPacketTests.cpp b/src/profiling/test/SendCounterPacketTests.cpp index c5f9177c90..87cfb5bf58 100644 --- a/src/profiling/test/SendCounterPacketTests.cpp +++ b/src/profiling/test/SendCounterPacketTests.cpp @@ -9,7 +9,7 @@ #include <BufferManager.hpp> #include <CounterDirectory.hpp> -#include <EncodeVersion.hpp> +#include <common/include/EncodeVersion.hpp> #include <ProfilingUtils.hpp> #include <SendCounterPacket.hpp> #include <Processes.hpp> @@ -325,19 +325,19 @@ BOOST_AUTO_TEST_CASE(SendStreamMetaDataPacketTest) // Timeline Message Directory (packet_family = 1, packet_class = 0, packet_type = 0) Version 1.0.0 // Timeline Message (packet_family = 1, packet_class = 0, packet_type = 1) Version 1.0.0 std::vector<std::pair<uint32_t, uint32_t>> packetVersions; - packetVersions.push_back(std::make_pair(ConstructHeader(0, 0), EncodeVersion(1, 0, 0))); - packetVersions.push_back(std::make_pair(ConstructHeader(0, 1), EncodeVersion(1, 0, 0))); - packetVersions.push_back(std::make_pair(ConstructHeader(0, 2), EncodeVersion(1, 0, 0))); - packetVersions.push_back(std::make_pair(ConstructHeader(0, 3), EncodeVersion(1, 0, 0))); - packetVersions.push_back(std::make_pair(ConstructHeader(0, 4), EncodeVersion(1, 0, 0))); - packetVersions.push_back(std::make_pair(ConstructHeader(0, 5), EncodeVersion(1, 0, 0))); - packetVersions.push_back(std::make_pair(ConstructHeader(0, 6), EncodeVersion(1, 0, 0))); - packetVersions.push_back(std::make_pair(ConstructHeader(0, 7), EncodeVersion(1, 0, 0))); - packetVersions.push_back(std::make_pair(ConstructHeader(3, 0, 0), EncodeVersion(1, 0, 0))); - packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 0), EncodeVersion(1, 0, 0))); - packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 1), EncodeVersion(1, 0, 0))); - packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 0), EncodeVersion(1, 0, 0))); - packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 1), EncodeVersion(1, 0, 0))); + packetVersions.push_back(std::make_pair(ConstructHeader(0, 0), arm::pipe::EncodeVersion(1, 0, 0))); + packetVersions.push_back(std::make_pair(ConstructHeader(0, 1), arm::pipe::EncodeVersion(1, 0, 0))); + packetVersions.push_back(std::make_pair(ConstructHeader(0, 2), arm::pipe::EncodeVersion(1, 0, 0))); + packetVersions.push_back(std::make_pair(ConstructHeader(0, 3), arm::pipe::EncodeVersion(1, 0, 0))); + packetVersions.push_back(std::make_pair(ConstructHeader(0, 4), arm::pipe::EncodeVersion(1, 0, 0))); + packetVersions.push_back(std::make_pair(ConstructHeader(0, 5), arm::pipe::EncodeVersion(1, 0, 0))); + packetVersions.push_back(std::make_pair(ConstructHeader(0, 6), arm::pipe::EncodeVersion(1, 0, 0))); + packetVersions.push_back(std::make_pair(ConstructHeader(0, 7), arm::pipe::EncodeVersion(1, 0, 0))); + packetVersions.push_back(std::make_pair(ConstructHeader(3, 0, 0), arm::pipe::EncodeVersion(1, 0, 0))); + packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 0), arm::pipe::EncodeVersion(1, 0, 0))); + packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 1), arm::pipe::EncodeVersion(1, 0, 0))); + packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 0), arm::pipe::EncodeVersion(1, 0, 0))); + packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 1), arm::pipe::EncodeVersion(1, 0, 0))); uint32_t packetEntries = static_cast<uint32_t>(packetVersions.size()); @@ -359,9 +359,9 @@ BOOST_AUTO_TEST_CASE(SendStreamMetaDataPacketTest) BOOST_TEST(headerWord1 == totalLength - (2 * sizeUint32)); // data length uint32_t offset = sizeUint32 * 2; - BOOST_TEST(ReadUint32(readBuffer2, offset) == armnnProfiling::PIPE_MAGIC); // pipe_magic + BOOST_TEST(ReadUint32(readBuffer2, offset) == arm::pipe::PIPE_MAGIC); // pipe_magic offset += sizeUint32; - BOOST_TEST(ReadUint32(readBuffer2, offset) == EncodeVersion(1, 0, 0)); // stream_metadata_version + BOOST_TEST(ReadUint32(readBuffer2, offset) == arm::pipe::EncodeVersion(1, 0, 0)); // stream_metadata_version offset += sizeUint32; BOOST_TEST(ReadUint32(readBuffer2, offset) == MAX_METADATA_PACKET_LENGTH); // max_data_len offset += sizeUint32; diff --git a/src/profiling/test/SendTimelinePacketTests.cpp b/src/profiling/test/SendTimelinePacketTests.cpp index 5e9f6bddea..7b68bb9753 100644 --- a/src/profiling/test/SendTimelinePacketTests.cpp +++ b/src/profiling/test/SendTimelinePacketTests.cpp @@ -6,14 +6,16 @@ #include "ProfilingMocks.hpp" #include <BufferManager.hpp> -#include <Threads.hpp> +#include <LabelsAndEventClasses.hpp> #include <ProfilingService.hpp> #include <ProfilingUtils.hpp> #include <SendTimelinePacket.hpp> +#include <Threads.hpp> #include <TimelinePacketWriterFactory.hpp> +#include <common/include/SwTrace.hpp> + #include <boost/test/unit_test.hpp> -#include <LabelsAndEventClasses.hpp> #include <functional> #include <Runtime.hpp> @@ -72,9 +74,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest) BOOST_CHECK(DeclCount == 5); offset += uint32_t_size; - SwTraceMessage swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), - offset, - packetBuffer->GetSize()); + arm::pipe::SwTraceMessage swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(), + offset, + packetBuffer->GetSize()); BOOST_CHECK(swTraceMessage.m_Id == 0); BOOST_CHECK(swTraceMessage.m_Name == "declareLabel"); @@ -86,7 +88,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest) BOOST_CHECK(swTraceMessage.m_ArgNames[0] == "guid"); BOOST_CHECK(swTraceMessage.m_ArgNames[1] == "value"); - swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()); + swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(), + offset, + packetBuffer->GetSize()); BOOST_CHECK(swTraceMessage.m_Id == 1); BOOST_CHECK(swTraceMessage.m_Name == "declareEntity"); @@ -96,7 +100,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest) BOOST_CHECK(swTraceMessage.m_ArgNames.size() == 1); BOOST_CHECK(swTraceMessage.m_ArgNames[0] == "guid"); - swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()); + swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(), + offset, + packetBuffer->GetSize()); BOOST_CHECK(swTraceMessage.m_Id == 2); BOOST_CHECK(swTraceMessage.m_Name == "declareEventClass"); @@ -108,7 +114,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest) BOOST_CHECK(swTraceMessage.m_ArgNames[0] == "guid"); BOOST_CHECK(swTraceMessage.m_ArgNames[1] == "nameGuid"); - swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()); + swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(), + offset, + packetBuffer->GetSize()); BOOST_CHECK(swTraceMessage.m_Id == 3); BOOST_CHECK(swTraceMessage.m_Name == "declareRelationship"); @@ -126,7 +134,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest) BOOST_CHECK(swTraceMessage.m_ArgNames[3] == "tailGuid"); BOOST_CHECK(swTraceMessage.m_ArgNames[4] == "attributeGuid"); - swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()); + swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(), + offset, + packetBuffer->GetSize()); BOOST_CHECK(swTraceMessage.m_Id == 4); BOOST_CHECK(swTraceMessage.m_Name == "declareEvent"); diff --git a/src/profiling/test/TestTimelinePacketHandler.cpp b/src/profiling/test/TestTimelinePacketHandler.cpp index ccb806b238..df847d4c7c 100644 --- a/src/profiling/test/TestTimelinePacketHandler.cpp +++ b/src/profiling/test/TestTimelinePacketHandler.cpp @@ -7,11 +7,8 @@ #include "IProfilingConnection.hpp" #include <LabelsAndEventClasses.hpp> -#include <armnn/utility/IgnoreUnused.hpp> - #include <chrono> #include <iostream> -#include <sstream> namespace armnn { @@ -27,7 +24,7 @@ std::vector<uint32_t> TestTimelinePacketHandler::GetHeadersAccepted() return headers; } -void TestTimelinePacketHandler::HandlePacket(const Packet& packet) +void TestTimelinePacketHandler::HandlePacket(const arm::pipe::Packet& packet) { if (packet.GetHeader() == m_DirectoryHeader) { @@ -79,44 +76,46 @@ void TestTimelinePacketHandler::SetInferenceComplete() m_InferenceCompletedConditionVariable.notify_one(); } -void TestTimelinePacketHandler::ProcessDirectoryPacket(const Packet& packet) +void TestTimelinePacketHandler::ProcessDirectoryPacket(const arm::pipe::Packet& packet) { m_DirectoryDecoder(packet); } -void TestTimelinePacketHandler::ProcessMessagePacket(const Packet& packet) +void TestTimelinePacketHandler::ProcessMessagePacket(const arm::pipe::Packet& packet) { m_Decoder(packet); } // TimelineMessageDecoder functions -ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEntity(const Entity& entity) +arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEntity(const Entity& entity) { m_TimelineModel.AddEntity(entity.m_Guid); - return ITimelineDecoder::TimelineStatus::TimelineStatus_Success; + return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success; } -ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEventClass( - const ITimelineDecoder::EventClass& eventClass) +arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEventClass( + const arm::pipe::ITimelineDecoder::EventClass& eventClass) { m_TimelineModel.AddEventClass(eventClass); - return ITimelineDecoder::TimelineStatus::TimelineStatus_Success; + return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success; } -ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEvent(const ITimelineDecoder::Event& event) +arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEvent( + const arm::pipe::ITimelineDecoder::Event& event) { m_TimelineModel.AddEvent(event); - return ITimelineDecoder::TimelineStatus::TimelineStatus_Success; + return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success; } -ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateLabel(const ITimelineDecoder::Label& label) +arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateLabel( + const arm::pipe::ITimelineDecoder::Label& label) { m_TimelineModel.AddLabel(label); - return ITimelineDecoder::TimelineStatus::TimelineStatus_Success; + return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success; } -ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateRelationship( - const ITimelineDecoder::Relationship& relationship) +arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateRelationship( + const arm::pipe::ITimelineDecoder::Relationship& relationship) { m_TimelineModel.AddRelationship(relationship); // check to see if this is an execution link to an inference of event class end of life @@ -133,7 +132,7 @@ ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateRelationship( } } } - return ITimelineDecoder::TimelineStatus::TimelineStatus_Success; + return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success; } } // namespace profiling diff --git a/src/profiling/test/TestTimelinePacketHandler.hpp b/src/profiling/test/TestTimelinePacketHandler.hpp index 08239fc38f..ab6eee5121 100644 --- a/src/profiling/test/TestTimelinePacketHandler.hpp +++ b/src/profiling/test/TestTimelinePacketHandler.hpp @@ -6,14 +6,15 @@ #pragma once #include <armnn/profiling/ILocalPacketHandler.hpp> -#include <armnn/profiling/ITimelineDecoder.hpp> -#include <Packet.hpp> +#include <server/include/timelineDecoder/ITimelineDecoder.hpp> #include "ProfilingUtils.hpp" -#include "TimelineCaptureCommandHandler.hpp" -#include "TimelineDirectoryCaptureCommandHandler.hpp" +#include <server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp> +#include <server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp> #include "TimelineModel.hpp" +#include <common/include/Packet.hpp> + #include <condition_variable> #include <map> #include <mutex> @@ -27,7 +28,7 @@ namespace profiling // forward declaration of class class TestTimelinePacketHandler; -class TimelineMessageDecoder : public ITimelineDecoder +class TimelineMessageDecoder : public arm::pipe::ITimelineDecoder { public: TimelineMessageDecoder(TimelineModel& model) : m_PacketHandler(nullptr), m_TimelineModel(model) {} @@ -57,7 +58,7 @@ public: virtual std::vector<uint32_t> GetHeadersAccepted() override; // ILocalPacketHandler - virtual void HandlePacket(const Packet& packet) override; // ILocalPacketHandler + virtual void HandlePacket(const arm::pipe::Packet& packet) override; // ILocalPacketHandler void Stop(); @@ -72,8 +73,8 @@ public: } private: - void ProcessDirectoryPacket(const Packet& packet); - void ProcessMessagePacket(const Packet& packet); + void ProcessDirectoryPacket(const arm::pipe::Packet& packet); + void ProcessMessagePacket(const arm::pipe::Packet& packet); IInternalProfilingConnection* m_Connection; std::mutex m_InferenceCompletedMutex; std::condition_variable m_InferenceCompletedConditionVariable; @@ -82,8 +83,8 @@ private: uint32_t m_DirectoryHeader; uint32_t m_MessageHeader; TimelineMessageDecoder m_MessageDecoder; - timelinedecoder::TimelineCaptureCommandHandler m_Decoder; - timelinedecoder::TimelineDirectoryCaptureCommandHandler m_DirectoryDecoder; + arm::pipe::TimelineCaptureCommandHandler m_Decoder; + arm::pipe::TimelineDirectoryCaptureCommandHandler m_DirectoryDecoder; }; } // namespace profiling diff --git a/src/profiling/test/TimelineModel.cpp b/src/profiling/test/TimelineModel.cpp index 2e4fd06013..1f02addcf9 100644 --- a/src/profiling/test/TimelineModel.cpp +++ b/src/profiling/test/TimelineModel.cpp @@ -14,7 +14,7 @@ namespace armnn namespace profiling { -void TimelineModel::AddLabel(const ITimelineDecoder::Label& label) +void TimelineModel::AddLabel(const arm::pipe::ITimelineDecoder::Label& label) { m_LabelMap.emplace(label.m_Guid, label); } @@ -50,14 +50,14 @@ Entity* TimelineModel::FindEntity(uint64_t id) } } -void TimelineModel::AddRelationship(const ITimelineDecoder::Relationship& relationship) +void TimelineModel::AddRelationship(const arm::pipe::ITimelineDecoder::Relationship& relationship) { m_Relationships.emplace(relationship.m_Guid, relationship); - if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::LabelLink) + if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::LabelLink) { HandleLabelLink(relationship); } - else if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::RetentionLink) + else if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink) { // Take care of the special case of a connection between layers in ArmNN // modelled by a retention link between two layer entities with an attribute GUID @@ -79,16 +79,16 @@ void TimelineModel::AddRelationship(const ITimelineDecoder::Relationship& relati // report unknown relationship type std::stringstream ss; ss << "Encountered a RetentionLink of unknown type [" << relationship.m_AttributeGuid << "]"; - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); } } - else if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::ExecutionLink) + else if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink) { HandleExecutionLink(relationship); } } -void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relationship) +void TimelineModel::HandleLabelLink(const arm::pipe::ITimelineDecoder::Relationship& relationship) { Entity* entity = FindEntity(relationship.m_HeadGuid); // we have a label attribute of an entity @@ -101,7 +101,7 @@ void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relati std::stringstream ss; ss << "could not find label link [" << relationship.m_Guid << "] value [" << relationship.m_TailGuid << "]"; - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); } if (relationship.m_AttributeGuid != 0) { @@ -112,7 +112,7 @@ void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relati std::stringstream ss; ss << "could not find label link [" << relationship.m_Guid << "] attribute [" << relationship.m_AttributeGuid << "]"; - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); } } else @@ -120,7 +120,7 @@ void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relati //report an error std::stringstream ss; ss << "label link [" << relationship.m_Guid << "] has a zero attribute guid"; - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); } if (entity != nullptr && attribute != nullptr && value != nullptr) { @@ -148,11 +148,11 @@ void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relati { ss << "attribute [" << *attribute << "] "; } - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); } } -void TimelineModel::HandleConnection(const ITimelineDecoder::Relationship& relationship) +void TimelineModel::HandleConnection(const arm::pipe::ITimelineDecoder::Relationship& relationship) { Entity* outputLayer = FindEntity(relationship.m_HeadGuid); if (outputLayer == nullptr) @@ -160,7 +160,7 @@ void TimelineModel::HandleConnection(const ITimelineDecoder::Relationship& relat std::stringstream ss; ss << "could not find output entity [" << relationship.m_HeadGuid << "]"; ss << " of connection [" << relationship.m_Guid << "]"; - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); return; } Entity* inputLayer = FindEntity(relationship.m_TailGuid); @@ -169,14 +169,14 @@ void TimelineModel::HandleConnection(const ITimelineDecoder::Relationship& relat std::stringstream ss; ss << "could not find input entity [" << relationship.m_TailGuid << "]"; ss << " of connection [" << relationship.m_Guid << "]"; - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); return; } Connection connection(relationship.m_Guid, outputLayer, inputLayer); outputLayer->AddConnection(connection); } -void TimelineModel::HandleChild(const ITimelineDecoder::Relationship& relationship) +void TimelineModel::HandleChild(const arm::pipe::ITimelineDecoder::Relationship& relationship) { Entity* parentEntity = FindEntity(relationship.m_HeadGuid); if (parentEntity == nullptr) @@ -184,7 +184,7 @@ void TimelineModel::HandleChild(const ITimelineDecoder::Relationship& relationsh std::stringstream ss; ss << "could not find parent entity [" << relationship.m_HeadGuid << "]"; ss << " of child relationship [" << relationship.m_Guid << "]"; - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); return; } Entity* childEntity = FindEntity(relationship.m_TailGuid); @@ -193,13 +193,13 @@ void TimelineModel::HandleChild(const ITimelineDecoder::Relationship& relationsh std::stringstream ss; ss << "could not find child entity [" << relationship.m_TailGuid << "]"; ss << " of child relationship [" << relationship.m_Guid << "]"; - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); return; } parentEntity->AddChild(childEntity); } -void TimelineModel::HandleExecutionOf(const ITimelineDecoder::Relationship& relationship) +void TimelineModel::HandleExecutionOf(const arm::pipe::ITimelineDecoder::Relationship& relationship) { Entity* parentEntity = FindEntity(relationship.m_HeadGuid); if (parentEntity == nullptr) @@ -207,7 +207,7 @@ void TimelineModel::HandleExecutionOf(const ITimelineDecoder::Relationship& rela std::stringstream ss; ss << "could not find parent entity [" << relationship.m_HeadGuid << "]"; ss << " of execution relationship [" << relationship.m_Guid << "]"; - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); return; } Entity* executedEntity = FindEntity(relationship.m_TailGuid); @@ -216,13 +216,13 @@ void TimelineModel::HandleExecutionOf(const ITimelineDecoder::Relationship& rela std::stringstream ss; ss << "could not find executed entity [" << relationship.m_TailGuid << "]"; ss << " of execution relationship [" << relationship.m_Guid << "]"; - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); return; } parentEntity->AddExecution(executedEntity); } -void TimelineModel::HandleExecutionLink(const ITimelineDecoder::Relationship& relationship) +void TimelineModel::HandleExecutionLink(const arm::pipe::ITimelineDecoder::Relationship& relationship) { // entityGuid, Entity* parentEntity = FindEntity(relationship.m_HeadGuid); @@ -231,7 +231,7 @@ void TimelineModel::HandleExecutionLink(const ITimelineDecoder::Relationship& re std::stringstream ss; ss << "could not find entity [" << relationship.m_HeadGuid << "]"; ss << " of ExecutionLink [" << relationship.m_Guid << "]"; - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); return; } // eventGuid, @@ -241,7 +241,7 @@ void TimelineModel::HandleExecutionLink(const ITimelineDecoder::Relationship& re std::stringstream ss; ss << "could not find event [" << relationship.m_TailGuid << "]"; ss << " of ExecutionLink [" << relationship.m_Guid << "]"; - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); return; } // eventClassGuid @@ -251,7 +251,7 @@ void TimelineModel::HandleExecutionLink(const ITimelineDecoder::Relationship& re std::stringstream ss; ss << "could not find event class [" << relationship.m_TailGuid << "]"; ss << " of ExecutionLink [" << relationship.m_Guid << "]"; - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); return; } eventObj->SetEventClass(eventClassObj); @@ -277,7 +277,7 @@ bool TimelineModel::IsInferenceGuid(uint64_t guid) const return it != m_InferenceGuids.end(); } -void TimelineModel::AddEventClass(const ITimelineDecoder::EventClass& eventClass) +void TimelineModel::AddEventClass(const arm::pipe::ITimelineDecoder::EventClass& eventClass) { std::string* eventClassName = FindLabel(eventClass.m_NameGuid); if (eventClassName != nullptr) @@ -290,7 +290,7 @@ void TimelineModel::AddEventClass(const ITimelineDecoder::EventClass& eventClass std::stringstream ss; ss << "could not find name [" << eventClass.m_NameGuid << "]"; ss << " of of event class [" << eventClass.m_Guid << "]"; - m_Errors.push_back(armnnProfiling::ProfilingException(ss.str())); + m_Errors.push_back(arm::pipe::ProfilingException(ss.str())); } } @@ -307,7 +307,7 @@ EventClassObj* TimelineModel::FindEventClass(uint64_t id) } } -void TimelineModel::AddEvent(const ITimelineDecoder::Event& event) +void TimelineModel::AddEvent(const arm::pipe::ITimelineDecoder::Event& event) { EventObj evt(event.m_Guid, event.m_TimeStamp, event.m_ThreadId); m_Events.emplace(event.m_Guid, evt); diff --git a/src/profiling/test/TimelineModel.hpp b/src/profiling/test/TimelineModel.hpp index a6d62ce3e8..ccbec7b01d 100644 --- a/src/profiling/test/TimelineModel.hpp +++ b/src/profiling/test/TimelineModel.hpp @@ -5,8 +5,8 @@ #pragma once -#include <armnn/profiling/ITimelineDecoder.hpp> #include <common/include/ProfilingException.hpp> +#include <server/include/timelineDecoder/ITimelineDecoder.hpp> #include <map> #include <sstream> @@ -17,7 +17,7 @@ namespace armnn namespace profiling { -using LabelMap = std::map<uint64_t, ITimelineDecoder::Label>; +using LabelMap = std::map<uint64_t, arm::pipe::ITimelineDecoder::Label>; using Attribute = std::pair<std::string, std::string>; using Attributes = std::map<std::string, Attribute>; class Entity; @@ -31,13 +31,13 @@ public: { std::stringstream ss; ss << "connection [" << guid << "] head cannot be null"; - throw armnnProfiling::ProfilingException(ss.str()); + throw arm::pipe::ProfilingException(ss.str()); } if (tail == nullptr) { std::stringstream ss; ss << "connection [" << guid << "] tail cannot be null"; - throw armnnProfiling::ProfilingException(ss.str()); + throw arm::pipe::ProfilingException(ss.str()); } } @@ -136,8 +136,8 @@ private: using Entities = std::map<uint64_t, Entity>; struct ModelRelationship { - ModelRelationship(const ITimelineDecoder::Relationship& relationship) : m_Relationship(relationship) {} - ITimelineDecoder::Relationship m_Relationship; + ModelRelationship(const arm::pipe::ITimelineDecoder::Relationship& relationship) : m_Relationship(relationship) {} + arm::pipe::ITimelineDecoder::Relationship m_Relationship; std::vector<Entity*> m_RelatedEntities; }; using Relationships = std::map<uint64_t, ModelRelationship>; @@ -146,35 +146,35 @@ using Events = std::map<uint64_t, EventObj>; class TimelineModel { public: - void AddLabel(const ITimelineDecoder::Label& label); + void AddLabel(const arm::pipe::ITimelineDecoder::Label& label); std::string* FindLabel(uint64_t guid); void AddEntity(uint64_t guid); Entity* FindEntity(uint64_t id); - void AddRelationship(const ITimelineDecoder::Relationship& relationship); + void AddRelationship(const arm::pipe::ITimelineDecoder::Relationship& relationship); ModelRelationship* FindRelationship(uint64_t id); const LabelMap& GetLabelMap() const {return m_LabelMap;} const Entities& GetEntities() const {return m_Entities;} - const std::vector<armnnProfiling::ProfilingException>& GetErrors() const {return m_Errors;} + const std::vector<arm::pipe::ProfilingException>& GetErrors() const {return m_Errors;} bool IsInferenceGuid(uint64_t guid) const; - void AddEventClass(const ITimelineDecoder::EventClass& eventClass); + void AddEventClass(const arm::pipe::ITimelineDecoder::EventClass& eventClass); const EventClasses& GetEventClasses() const {return m_EventClasses;} EventClassObj* FindEventClass(uint64_t id); - void AddEvent(const ITimelineDecoder::Event& event); + void AddEvent(const arm::pipe::ITimelineDecoder::Event& event); EventObj* FindEvent(uint64_t id); private: LabelMap m_LabelMap; Entities m_Entities; Relationships m_Relationships; - std::vector<armnnProfiling::ProfilingException> m_Errors; + std::vector<arm::pipe::ProfilingException> m_Errors; std::vector<uint64_t> m_InferenceGuids; EventClasses m_EventClasses; Events m_Events; - void HandleLabelLink(const ITimelineDecoder::Relationship& relationship); - void HandleConnection(const ITimelineDecoder::Relationship& relationship); - void HandleChild(const ITimelineDecoder::Relationship& relationship); - void HandleExecutionOf(const ITimelineDecoder::Relationship& relationship); - void HandleExecutionLink(const ITimelineDecoder::Relationship& relationship); + void HandleLabelLink(const arm::pipe::ITimelineDecoder::Relationship& relationship); + void HandleConnection(const arm::pipe::ITimelineDecoder::Relationship& relationship); + void HandleChild(const arm::pipe::ITimelineDecoder::Relationship& relationship); + void HandleExecutionOf(const arm::pipe::ITimelineDecoder::Relationship& relationship); + void HandleExecutionLink(const arm::pipe::ITimelineDecoder::Relationship& relationship); }; std::vector<std::string> GetModelDescription(const TimelineModel& model); diff --git a/src/profiling/test/TimelinePacketTests.cpp b/src/profiling/test/TimelinePacketTests.cpp index 71c6915a8c..4f056ce761 100644 --- a/src/profiling/test/TimelinePacketTests.cpp +++ b/src/profiling/test/TimelinePacketTests.cpp @@ -6,6 +6,8 @@ #include <Threads.hpp> #include <ProfilingUtils.hpp> +#include <common/include/SwTrace.hpp> + #include <boost/test/unit_test.hpp> #include <boost/numeric/conversion/cast.hpp> @@ -524,7 +526,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction) // Check the ui_name std::vector<uint32_t> swTraceString; - StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString); + arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(label, swTraceString); offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size; uint32_t swTraceUINameLength = ReadUint32(buffer.data(), offset); BOOST_CHECK(swTraceUINameLength == 14); // ui_name length including the null-terminator @@ -536,7 +538,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction) swTraceUINameLength - 1) == 0); // The length of the label // Check arg_types - StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString); + arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(label, swTraceString); offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size; uint32_t swTraceArgTypesLength = ReadUint32(buffer.data(), offset); BOOST_CHECK(swTraceArgTypesLength == 3); // arg_types length including the null-terminator @@ -548,7 +550,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction) swTraceArgTypesLength - 1) == 0); // The length of the label // Check arg_names - StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString); + arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(label, swTraceString); offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size; uint32_t swTraceArgNamesLength = ReadUint32(buffer.data(), offset); BOOST_CHECK(swTraceArgNamesLength == 11); // arg_names length including the null-terminator @@ -560,7 +562,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction) swTraceArgNamesLength - 1) == 0); // The length of the label // Check second message decl_id - StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString); + arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(label, swTraceString); offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size; readDeclId = ReadUint32(buffer.data(), offset); BOOST_CHECK(readDeclId == 1); |