From 397043fa3d900430e9e0f6d328b76898f9613388 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Thu, 17 Oct 2019 17:37:10 +0100 Subject: IVGCVSW-4002 Add FamilyId to CommandHandlerKey Change-Id: I0bb0bf77da2bcd7f4746078c4ccee9acc98638a7 Signed-off-by: Jim Flynn --- src/profiling/CommandHandler.cpp | 4 +- src/profiling/CommandHandlerFunctor.cpp | 5 ++ src/profiling/CommandHandlerFunctor.hpp | 7 +- src/profiling/CommandHandlerKey.cpp | 22 +++-- src/profiling/CommandHandlerKey.hpp | 5 +- src/profiling/CommandHandlerRegistry.cpp | 13 +-- src/profiling/CommandHandlerRegistry.hpp | 4 +- .../ConnectionAcknowledgedCommandHandler.hpp | 5 +- .../PerJobCounterSelectionCommandHandler.hpp | 9 +- .../PeriodicCounterSelectionCommandHandler.hpp | 5 +- src/profiling/ProfilingService.hpp | 12 ++- .../RequestCounterDirectoryCommandHandler.hpp | 5 +- src/profiling/test/ProfilingTests.cpp | 95 +++++++++++++--------- tests/profiling/gatordmock/GatordMockMain.cpp | 4 +- tests/profiling/gatordmock/GatordMockService.cpp | 3 +- .../PeriodicCounterCaptureCommandHandler.hpp | 9 +- .../PeriodicCounterSelectionResponseHandler.hpp | 7 +- .../profiling/gatordmock/tests/GatordMockTests.cpp | 6 +- 18 files changed, 138 insertions(+), 82 deletions(-) diff --git a/src/profiling/CommandHandler.cpp b/src/profiling/CommandHandler.cpp index b0603b0ed5..2e22be35a5 100644 --- a/src/profiling/CommandHandler.cpp +++ b/src/profiling/CommandHandler.cpp @@ -58,7 +58,9 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection) Version version = m_PacketVersionResolver.ResolvePacketVersion(packet.GetPacketId()); CommandHandlerFunctor* commandHandlerFunctor = - m_CommandHandlerRegistry.GetFunctor(packet.GetPacketId(), version.GetEncodedValue()); + m_CommandHandlerRegistry.GetFunctor(packet.GetPacketFamily(), + packet.GetPacketId(), + version.GetEncodedValue()); BOOST_ASSERT(commandHandlerFunctor); commandHandlerFunctor->operator()(packet); } diff --git a/src/profiling/CommandHandlerFunctor.cpp b/src/profiling/CommandHandlerFunctor.cpp index 894e2d440f..7f836cba2f 100644 --- a/src/profiling/CommandHandlerFunctor.cpp +++ b/src/profiling/CommandHandlerFunctor.cpp @@ -11,6 +11,11 @@ namespace armnn namespace profiling { +uint32_t CommandHandlerFunctor::GetFamilyId() const +{ + return m_FamilyId; +} + uint32_t CommandHandlerFunctor::GetPacketId() const { return m_PacketId; diff --git a/src/profiling/CommandHandlerFunctor.hpp b/src/profiling/CommandHandlerFunctor.hpp index 7aaab58d15..4d6dfa080a 100644 --- a/src/profiling/CommandHandlerFunctor.hpp +++ b/src/profiling/CommandHandlerFunctor.hpp @@ -18,11 +18,13 @@ namespace profiling class CommandHandlerFunctor { public: - CommandHandlerFunctor(uint32_t packetId, uint32_t version) - : m_PacketId(packetId) + CommandHandlerFunctor(uint32_t familyId, uint32_t packetId, uint32_t version) + : m_FamilyId(familyId), + m_PacketId(packetId) , m_Version(version) {} + uint32_t GetFamilyId() const; uint32_t GetPacketId() const; uint32_t GetVersion() const; @@ -31,6 +33,7 @@ public: virtual ~CommandHandlerFunctor() {} private: + uint32_t m_FamilyId; uint32_t m_PacketId; uint32_t m_Version; }; diff --git a/src/profiling/CommandHandlerKey.cpp b/src/profiling/CommandHandlerKey.cpp index 66b20c57cc..4d7e11a7e0 100644 --- a/src/profiling/CommandHandlerKey.cpp +++ b/src/profiling/CommandHandlerKey.cpp @@ -11,6 +11,11 @@ namespace armnn namespace profiling { +uint32_t CommandHandlerKey::GetFamilyId() const +{ + return m_FamilyId; +} + uint32_t CommandHandlerKey::GetPacketId() const { return m_PacketId; @@ -24,16 +29,21 @@ uint32_t CommandHandlerKey::GetVersion() const bool CommandHandlerKey::operator<(const CommandHandlerKey& rhs) const { bool result = true; - - if (m_PacketId == rhs.m_PacketId) + if (m_FamilyId == rhs.m_FamilyId) { - result = m_Version < rhs.m_Version; + if (m_PacketId == rhs.m_PacketId) + { + result = m_Version < rhs.m_Version; + } + else if (m_PacketId > rhs.m_PacketId) + { + result = false; + } } - else if (m_PacketId > rhs.m_PacketId) + else if (m_FamilyId > rhs.m_FamilyId) { result = false; } - return result; } @@ -54,7 +64,7 @@ bool CommandHandlerKey::operator>=(const CommandHandlerKey& rhs) const bool CommandHandlerKey::operator==(const CommandHandlerKey& rhs) const { - return m_PacketId == rhs.m_PacketId && m_Version == rhs.m_Version; + return m_FamilyId == rhs.m_FamilyId && m_PacketId == rhs.m_PacketId && m_Version == rhs.m_Version; } bool CommandHandlerKey::operator!=(const CommandHandlerKey& rhs) const diff --git a/src/profiling/CommandHandlerKey.hpp b/src/profiling/CommandHandlerKey.hpp index 1ec5f5171f..247f67925b 100644 --- a/src/profiling/CommandHandlerKey.hpp +++ b/src/profiling/CommandHandlerKey.hpp @@ -16,8 +16,10 @@ namespace profiling class CommandHandlerKey { public: - CommandHandlerKey(uint32_t packetId, uint32_t version) : m_PacketId(packetId), m_Version(version) {}; + CommandHandlerKey(uint32_t familyId, uint32_t packetId, uint32_t version) + : m_FamilyId(familyId), m_PacketId(packetId), m_Version(version) {}; + uint32_t GetFamilyId() const; uint32_t GetPacketId() const; uint32_t GetVersion() const; @@ -29,6 +31,7 @@ public: bool operator!=(const CommandHandlerKey& rhs) const; private: + uint32_t m_FamilyId; uint32_t m_PacketId; uint32_t m_Version; }; diff --git a/src/profiling/CommandHandlerRegistry.cpp b/src/profiling/CommandHandlerRegistry.cpp index bd9b318835..8070afe623 100644 --- a/src/profiling/CommandHandlerRegistry.cpp +++ b/src/profiling/CommandHandlerRegistry.cpp @@ -14,11 +14,14 @@ namespace armnn namespace profiling { -void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor, uint32_t packetId, uint32_t version) +void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor, + uint32_t familyId, + uint32_t packetId, + uint32_t version) { BOOST_ASSERT_MSG(functor, "Provided functor should not be a nullptr"); - CommandHandlerKey key(packetId, version); + CommandHandlerKey key(familyId, packetId, version); registry[key] = functor; } @@ -26,12 +29,12 @@ void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor) { BOOST_ASSERT_MSG(functor, "Provided functor should not be a nullptr"); - RegisterFunctor(functor, functor->GetPacketId(), functor->GetVersion()); + RegisterFunctor(functor, functor->GetFamilyId(), functor->GetPacketId(), functor->GetVersion()); } -CommandHandlerFunctor* CommandHandlerRegistry::GetFunctor(uint32_t packetId, uint32_t version) const +CommandHandlerFunctor* CommandHandlerRegistry::GetFunctor(uint32_t familyId,uint32_t packetId, uint32_t version) const { - CommandHandlerKey key(packetId, version); + CommandHandlerKey key(familyId, packetId, version); // Check that the requested key exists if (registry.find(key) == registry.end()) diff --git a/src/profiling/CommandHandlerRegistry.hpp b/src/profiling/CommandHandlerRegistry.hpp index 9d514bfcc3..43419deea4 100644 --- a/src/profiling/CommandHandlerRegistry.hpp +++ b/src/profiling/CommandHandlerRegistry.hpp @@ -34,11 +34,11 @@ class CommandHandlerRegistry public: CommandHandlerRegistry() = default; - void RegisterFunctor(CommandHandlerFunctor* functor, uint32_t packetId, uint32_t version); + void RegisterFunctor(CommandHandlerFunctor* functor, uint32_t familyId, uint32_t packetId, uint32_t version); void RegisterFunctor(CommandHandlerFunctor* functor); - CommandHandlerFunctor* GetFunctor(uint32_t packetId, uint32_t version) const; + CommandHandlerFunctor* GetFunctor(uint32_t familyId, uint32_t packetId, uint32_t version) const; private: std::unordered_map registry; diff --git a/src/profiling/ConnectionAcknowledgedCommandHandler.hpp b/src/profiling/ConnectionAcknowledgedCommandHandler.hpp index d0dc07ae00..255fcf645a 100644 --- a/src/profiling/ConnectionAcknowledgedCommandHandler.hpp +++ b/src/profiling/ConnectionAcknowledgedCommandHandler.hpp @@ -19,10 +19,11 @@ class ConnectionAcknowledgedCommandHandler final : public CommandHandlerFunctor { public: - ConnectionAcknowledgedCommandHandler(uint32_t packetId, + ConnectionAcknowledgedCommandHandler(uint32_t familyId, + uint32_t packetId, uint32_t version, ProfilingStateMachine& profilingStateMachine) - : CommandHandlerFunctor(packetId, version) + : CommandHandlerFunctor(familyId, packetId, version) , m_StateMachine(profilingStateMachine) {} diff --git a/src/profiling/PerJobCounterSelectionCommandHandler.hpp b/src/profiling/PerJobCounterSelectionCommandHandler.hpp index 6caa08d68e..738a4762f9 100644 --- a/src/profiling/PerJobCounterSelectionCommandHandler.hpp +++ b/src/profiling/PerJobCounterSelectionCommandHandler.hpp @@ -19,10 +19,11 @@ class PerJobCounterSelectionCommandHandler : public CommandHandlerFunctor { public: - PerJobCounterSelectionCommandHandler(uint32_t packetId, - uint32_t version, - const ProfilingStateMachine& profilingStateMachine) - : CommandHandlerFunctor(packetId, version) + PerJobCounterSelectionCommandHandler(uint32_t familyId, + uint32_t packetId, + uint32_t version, + const ProfilingStateMachine& profilingStateMachine) + : CommandHandlerFunctor(familyId, packetId, version) , m_StateMachine(profilingStateMachine) {} diff --git a/src/profiling/PeriodicCounterSelectionCommandHandler.hpp b/src/profiling/PeriodicCounterSelectionCommandHandler.hpp index 1da08e3c7a..e2738f8643 100644 --- a/src/profiling/PeriodicCounterSelectionCommandHandler.hpp +++ b/src/profiling/PeriodicCounterSelectionCommandHandler.hpp @@ -22,14 +22,15 @@ class PeriodicCounterSelectionCommandHandler : public CommandHandlerFunctor { public: - PeriodicCounterSelectionCommandHandler(uint32_t packetId, + PeriodicCounterSelectionCommandHandler(uint32_t familyId, + uint32_t packetId, uint32_t version, Holder& captureDataHolder, IPeriodicCounterCapture& periodicCounterCapture, const IReadCounterValues& readCounterValue, ISendCounterPacket& sendCounterPacket, const ProfilingStateMachine& profilingStateMachine) - : CommandHandlerFunctor(packetId, version) + : CommandHandlerFunctor(familyId, packetId, version) , m_CaptureDataHolder(captureDataHolder) , m_PeriodicCounterCapture(periodicCounterCapture) , m_ReadCounterValues(readCounterValue) diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp index dda37dddf2..ea11442ba7 100644 --- a/src/profiling/ProfilingService.hpp +++ b/src/profiling/ProfilingService.hpp @@ -121,22 +121,26 @@ protected: , m_BufferManager() , m_SendCounterPacket(m_StateMachine, m_BufferManager) , m_PeriodicCounterCapture(m_Holder, m_SendCounterPacket, *this) - , m_ConnectionAcknowledgedCommandHandler(1, + , m_ConnectionAcknowledgedCommandHandler(0, + 1, m_PacketVersionResolver.ResolvePacketVersion(1).GetEncodedValue(), m_StateMachine) - , m_RequestCounterDirectoryCommandHandler(3, + , m_RequestCounterDirectoryCommandHandler(0, + 3, m_PacketVersionResolver.ResolvePacketVersion(3).GetEncodedValue(), m_CounterDirectory, m_SendCounterPacket, m_StateMachine) - , m_PeriodicCounterSelectionCommandHandler(4, + , m_PeriodicCounterSelectionCommandHandler(0, + 4, m_PacketVersionResolver.ResolvePacketVersion(4).GetEncodedValue(), m_Holder, m_PeriodicCounterCapture, *this, m_SendCounterPacket, m_StateMachine) - , m_PerJobCounterSelectionCommandHandler(5, + , m_PerJobCounterSelectionCommandHandler(0, + 5, m_PacketVersionResolver.ResolvePacketVersion(4).GetEncodedValue(), m_StateMachine) { diff --git a/src/profiling/RequestCounterDirectoryCommandHandler.hpp b/src/profiling/RequestCounterDirectoryCommandHandler.hpp index 02bf64d17a..907be89a22 100644 --- a/src/profiling/RequestCounterDirectoryCommandHandler.hpp +++ b/src/profiling/RequestCounterDirectoryCommandHandler.hpp @@ -20,12 +20,13 @@ class RequestCounterDirectoryCommandHandler : public CommandHandlerFunctor { public: - RequestCounterDirectoryCommandHandler(uint32_t packetId, + RequestCounterDirectoryCommandHandler(uint32_t familyId, + uint32_t packetId, uint32_t version, ICounterDirectory& counterDirectory, ISendCounterPacket& sendCounterPacket, ProfilingStateMachine& profilingStateMachine) - : CommandHandlerFunctor(packetId, version) + : CommandHandlerFunctor(familyId, packetId, version) , m_CounterDirectory(counterDirectory) , m_SendCounterPacket(sendCounterPacket) , m_StateMachine(profilingStateMachine) diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index 50af75eeea..c2550986ab 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -43,12 +43,20 @@ BOOST_AUTO_TEST_SUITE(ExternalProfiling) BOOST_AUTO_TEST_CASE(CheckCommandHandlerKeyComparisons) { - CommandHandlerKey testKey0(1, 1); - CommandHandlerKey testKey1(1, 1); - CommandHandlerKey testKey2(1, 1); - CommandHandlerKey testKey3(0, 0); - CommandHandlerKey testKey4(2, 2); - CommandHandlerKey testKey5(0, 2); + CommandHandlerKey testKey1_0(1, 1, 1); + CommandHandlerKey testKey1_1(1, 1, 1); + 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); + + BOOST_CHECK(testKey1_0 > testKey0); + BOOST_CHECK(testKey1_0 == testKey1_1); + BOOST_CHECK(testKey1_0 < testKey1_2); BOOST_CHECK(testKey1testKey3); @@ -71,18 +79,18 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerKeyComparisons) std::vector vect = { - CommandHandlerKey(0,1), CommandHandlerKey(2,0), CommandHandlerKey(1,0), - CommandHandlerKey(2,1), CommandHandlerKey(1,1), CommandHandlerKey(0,1), - CommandHandlerKey(2,0), CommandHandlerKey(0,0) + 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::sort(vect.begin(), vect.end()); std::vector expectedVect = { - CommandHandlerKey(0,0), CommandHandlerKey(0,1), CommandHandlerKey(0,1), - CommandHandlerKey(1,0), CommandHandlerKey(1,1), CommandHandlerKey(2,0), - CommandHandlerKey(2,0), CommandHandlerKey(2,1) + 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) }; BOOST_CHECK(vect == expectedVect); @@ -97,7 +105,7 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandler) TestProfilingConnectionTimeoutError testProfilingConnectionTimeOutError; TestProfilingConnectionArmnnError testProfilingConnectionArmnnError; - ConnectionAcknowledgedCommandHandler connectionAcknowledgedCommandHandler(1, 4194304, profilingStateMachine); + ConnectionAcknowledgedCommandHandler connectionAcknowledgedCommandHandler(0, 1, 4194304, profilingStateMachine); CommandHandlerRegistry commandHandlerRegistry; commandHandlerRegistry.RegisterFunctor(&connectionAcknowledgedCommandHandler); @@ -238,13 +246,13 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerFunctor) // Hard code the version as it will be the same during a single profiling session uint32_t version = 1; - TestFunctorA testFunctorA(461, version); - TestFunctorB testFunctorB(963, version); - TestFunctorC testFunctorC(983, version); + TestFunctorA testFunctorA(7, 461, version); + TestFunctorB testFunctorB(8, 963, version); + TestFunctorC testFunctorC(5, 983, version); - CommandHandlerKey keyA(testFunctorA.GetPacketId(), testFunctorA.GetVersion()); - CommandHandlerKey keyB(testFunctorB.GetPacketId(), testFunctorB.GetVersion()); - CommandHandlerKey keyC(testFunctorC.GetPacketId(), testFunctorC.GetVersion()); + CommandHandlerKey keyA(testFunctorA.GetFamilyId(), testFunctorA.GetPacketId(), testFunctorA.GetVersion()); + CommandHandlerKey keyB(testFunctorB.GetFamilyId(), testFunctorB.GetPacketId(), testFunctorB.GetVersion()); + CommandHandlerKey keyC(testFunctorC.GetFamilyId(), testFunctorC.GetPacketId(), testFunctorC.GetVersion()); // Create the unwrapped map to simulate the Command Handler Registry std::map registry; @@ -255,11 +263,11 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerFunctor) // Check the order of the map is correct auto it = registry.begin(); - BOOST_CHECK(it->first==keyA); + BOOST_CHECK(it->first==keyC); // familyId == 5 it++; - BOOST_CHECK(it->first==keyB); + BOOST_CHECK(it->first==keyA); // familyId == 7 it++; - BOOST_CHECK(it->first==keyC); + BOOST_CHECK(it->first==keyB); // familyId == 8 std::unique_ptr packetDataA; std::unique_ptr packetDataB; @@ -270,17 +278,17 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerFunctor) Packet packetC(400000000, 0, packetDataC); // Check the correct operator of derived class is called - registry.at(CommandHandlerKey(packetA.GetPacketId(), version))->operator()(packetA); + registry.at(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.GetPacketId(), version))->operator()(packetB); + registry.at(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.GetPacketId(), version))->operator()(packetC); + registry.at(CommandHandlerKey(packetC.GetPacketFamily(), packetC.GetPacketId(), version))->operator()(packetC); BOOST_CHECK(testFunctorA.GetCount() == 1); BOOST_CHECK(testFunctorB.GetCount() == 1); BOOST_CHECK(testFunctorC.GetCount() == 1); @@ -291,9 +299,9 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerRegistry) // Hard code the version as it will be the same during a single profiling session uint32_t version = 1; - TestFunctorA testFunctorA(461, version); - TestFunctorB testFunctorB(963, version); - TestFunctorC testFunctorC(983, version); + TestFunctorA testFunctorA(7, 461, version); + TestFunctorB testFunctorB(8, 963, version); + TestFunctorC testFunctorC(5, 983, version); // Create the Command Handler Registry CommandHandlerRegistry registry; @@ -312,30 +320,30 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerRegistry) Packet packetC(400000000, 0, packetDataC); // Check the correct operator of derived class is called - registry.GetFunctor(packetA.GetPacketId(), version)->operator()(packetA); + registry.GetFunctor(packetA.GetPacketFamily(), packetA.GetPacketId(), version)->operator()(packetA); BOOST_CHECK(testFunctorA.GetCount() == 1); BOOST_CHECK(testFunctorB.GetCount() == 0); BOOST_CHECK(testFunctorC.GetCount() == 0); - registry.GetFunctor(packetB.GetPacketId(), version)->operator()(packetB); + registry.GetFunctor(packetB.GetPacketFamily(), packetB.GetPacketId(), version)->operator()(packetB); BOOST_CHECK(testFunctorA.GetCount() == 1); BOOST_CHECK(testFunctorB.GetCount() == 1); BOOST_CHECK(testFunctorC.GetCount() == 0); - registry.GetFunctor(packetC.GetPacketId(), version)->operator()(packetC); + registry.GetFunctor(packetC.GetPacketFamily(), packetC.GetPacketId(), version)->operator()(packetC); BOOST_CHECK(testFunctorA.GetCount() == 1); BOOST_CHECK(testFunctorB.GetCount() == 1); BOOST_CHECK(testFunctorC.GetCount() == 1); // Re-register an existing key with a new function - registry.RegisterFunctor(&testFunctorC, testFunctorA.GetPacketId(), version); - registry.GetFunctor(packetA.GetPacketId(), version)->operator()(packetC); + registry.RegisterFunctor(&testFunctorC, testFunctorA.GetFamilyId(), testFunctorA.GetPacketId(), version); + registry.GetFunctor(packetA.GetPacketFamily(), packetA.GetPacketId(), version)->operator()(packetC); BOOST_CHECK(testFunctorA.GetCount() == 1); BOOST_CHECK(testFunctorB.GetCount() == 1); BOOST_CHECK(testFunctorC.GetCount() == 2); // Check that non-existent key returns nullptr for its functor - BOOST_CHECK_THROW(registry.GetFunctor(0, 0), armnn::Exception); + BOOST_CHECK_THROW(registry.GetFunctor(0, 0, 0), armnn::Exception); } BOOST_AUTO_TEST_CASE(CheckPacketVersionResolver) @@ -1698,7 +1706,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData) uint16_t GetCounterCount() const override { return 0; } uint32_t GetCounterValue(uint16_t counterUid) const override { return 0; } }; - + const uint32_t familyId = 0; const uint32_t packetId = 0x40000; uint32_t version = 1; @@ -1727,7 +1735,8 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData) Packet packetA(packetId, dataLength1, uniqueData1); - PeriodicCounterSelectionCommandHandler commandHandler(packetId, + PeriodicCounterSelectionCommandHandler commandHandler(familyId, + packetId, version, holder, captureThread, @@ -1813,6 +1822,7 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged) { using boost::numeric_cast; + const uint32_t packetFamilyId = 0; const uint32_t connectionPacketId = 0x10000; const uint32_t version = 1; @@ -1838,7 +1848,7 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged) ProfilingStateMachine profilingState(ProfilingState::Uninitialised); BOOST_CHECK(profilingState.GetCurrentState() == ProfilingState::Uninitialised); - ConnectionAcknowledgedCommandHandler commandHandler(connectionPacketId, version, profilingState); + ConnectionAcknowledgedCommandHandler commandHandler(packetFamilyId, connectionPacketId, version, profilingState); // command handler received packet on ProfilingState::Uninitialised BOOST_CHECK_THROW(commandHandler(packetA), armnn::Exception); @@ -1863,7 +1873,8 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged) Packet packetB(differentPacketId, dataLength1, uniqueData1); profilingState.TransitionToState(ProfilingState::NotConnected); profilingState.TransitionToState(ProfilingState::WaitingForAck); - ConnectionAcknowledgedCommandHandler differentCommandHandler(differentPacketId, version, profilingState); + ConnectionAcknowledgedCommandHandler differentCommandHandler( + packetFamilyId, differentPacketId, version, profilingState); BOOST_CHECK_THROW(differentCommandHandler(packetB), armnn::Exception); } @@ -2145,13 +2156,15 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1) { using boost::numeric_cast; + const uint32_t familyId = 0; const uint32_t packetId = 3; const uint32_t version = 1; ProfilingStateMachine profilingStateMachine; CounterDirectory counterDirectory; MockBufferManager mockBuffer(1024); SendCounterPacket sendCounterPacket(profilingStateMachine, mockBuffer); - RequestCounterDirectoryCommandHandler commandHandler(packetId, + RequestCounterDirectoryCommandHandler commandHandler(familyId, + packetId, version, counterDirectory, sendCounterPacket, @@ -2195,13 +2208,15 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2) { using boost::numeric_cast; + const uint32_t familyId = 0; const uint32_t packetId = 3; const uint32_t version = 1; ProfilingStateMachine profilingStateMachine; CounterDirectory counterDirectory; MockBufferManager mockBuffer(1024); SendCounterPacket sendCounterPacket(profilingStateMachine, mockBuffer); - RequestCounterDirectoryCommandHandler commandHandler(packetId, + RequestCounterDirectoryCommandHandler commandHandler(familyId, + packetId, version, counterDirectory, sendCounterPacket, diff --git a/tests/profiling/gatordmock/GatordMockMain.cpp b/tests/profiling/gatordmock/GatordMockMain.cpp index 002d6c7c5a..2423493491 100644 --- a/tests/profiling/gatordmock/GatordMockMain.cpp +++ b/tests/profiling/gatordmock/GatordMockMain.cpp @@ -29,10 +29,10 @@ int main(int argc, char* argv[]) // This functor will receive back the selection response packet. armnn::gatordmock::PeriodicCounterSelectionResponseHandler periodicCounterSelectionResponseHandler( - 4, packetVersionResolver.ResolvePacketVersion(4).GetEncodedValue()); + 0, 4, packetVersionResolver.ResolvePacketVersion(4).GetEncodedValue()); // This functor will receive the counter data. armnn::gatordmock::PeriodicCounterCaptureCommandHandler counterCaptureCommandHandler( - 0, packetVersionResolver.ResolvePacketVersion(0).GetEncodedValue()); + 1, 0, packetVersionResolver.ResolvePacketVersion(0).GetEncodedValue()); // Register different derived functors registry.RegisterFunctor(&periodicCounterSelectionResponseHandler); diff --git a/tests/profiling/gatordmock/GatordMockService.cpp b/tests/profiling/gatordmock/GatordMockService.cpp index 4b9d7524f3..2697b2f3e9 100644 --- a/tests/profiling/gatordmock/GatordMockService.cpp +++ b/tests/profiling/gatordmock/GatordMockService.cpp @@ -324,7 +324,8 @@ armnn::profiling::Packet GatordMockService::ReceivePacket() // Pass packet into the handler registry m_PacketsReceivedCount.operator++(std::memory_order::memory_order_release); m_HandlerRegistry - .GetFunctor(packetRx.GetPacketId(), + .GetFunctor(packetRx.GetPacketFamily(), + packetRx.GetPacketId(), packetVersionResolver.ResolvePacketVersion(packetRx.GetPacketId()).GetEncodedValue()) ->operator()(packetRx); diff --git a/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp b/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp index b2fd48f4e8..4135a2fb06 100644 --- a/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp +++ b/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp @@ -29,13 +29,16 @@ class PeriodicCounterCaptureCommandHandler : public profiling::CommandHandlerFun public: /** - * + * @param familyId The family of the packets this handler will service * @param packetId The id of packets this handler will process. * @param version The version of that id. * @param quietOperation Optional parameter to turn off printouts. This is useful for unittests. */ - PeriodicCounterCaptureCommandHandler(uint32_t packetId, uint32_t version, bool quietOperation = false) - : CommandHandlerFunctor(packetId, version) + PeriodicCounterCaptureCommandHandler(uint32_t familyId, + uint32_t packetId, + uint32_t version, + bool quietOperation = false) + : CommandHandlerFunctor(familyId, packetId, version) , m_QuietOperation(quietOperation) {} diff --git a/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp b/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp index e1172e2d68..faf9792ac0 100644 --- a/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp +++ b/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp @@ -26,8 +26,11 @@ public: * @param version The version of that id. * @param quietOperation Optional parameter to turn off printouts. This is useful for unittests. */ - PeriodicCounterSelectionResponseHandler(uint32_t packetId, uint32_t version, bool quietOperation = true) - : CommandHandlerFunctor(packetId, version) + PeriodicCounterSelectionResponseHandler(uint32_t familyId, + uint32_t packetId, + uint32_t version, + bool quietOperation = true) + : CommandHandlerFunctor(familyId, packetId, version) , m_QuietOperation(quietOperation) {} diff --git a/tests/profiling/gatordmock/tests/GatordMockTests.cpp b/tests/profiling/gatordmock/tests/GatordMockTests.cpp index 3f58f39124..eb4b1783a4 100644 --- a/tests/profiling/gatordmock/tests/GatordMockTests.cpp +++ b/tests/profiling/gatordmock/tests/GatordMockTests.cpp @@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(CounterCaptureHandlingTest) profiling::Packet packet2(headerWord1, dataLength, uniqueData2); uint32_t version = 1; - gatordmock::PeriodicCounterCaptureCommandHandler commandHandler(headerWord1, version, true); + gatordmock::PeriodicCounterCaptureCommandHandler commandHandler(0, 4, version, false); // Simulate two separate packets coming in to calculate period commandHandler(packet1); @@ -123,14 +123,14 @@ BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd) // performance data. // Initialise functors and register into the CommandHandlerRegistry - uint32_t counterCaptureHeader = ConstructHeader(1, 0); uint32_t version = 1; // Create the Command Handler Registry profiling::CommandHandlerRegistry registry; // Update with derived functors - gatordmock::PeriodicCounterCaptureCommandHandler counterCaptureCommandHandler(counterCaptureHeader, version, true); + gatordmock::PeriodicCounterCaptureCommandHandler counterCaptureCommandHandler(0, 4, version, false); + // Register different derived functors registry.RegisterFunctor(&counterCaptureCommandHandler); -- cgit v1.2.1