IVGCVSW-4002 Add FamilyId to CommandHandlerKey
authorJim Flynn <jim.flynn@arm.com>
Thu, 17 Oct 2019 16:37:10 +0000 (17:37 +0100)
committerJim Flynn <jim.flynn@arm.com>
Fri, 18 Oct 2019 08:58:17 +0000 (09:58 +0100)
Change-Id: I0bb0bf77da2bcd7f4746078c4ccee9acc98638a7
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
18 files changed:
src/profiling/CommandHandler.cpp
src/profiling/CommandHandlerFunctor.cpp
src/profiling/CommandHandlerFunctor.hpp
src/profiling/CommandHandlerKey.cpp
src/profiling/CommandHandlerKey.hpp
src/profiling/CommandHandlerRegistry.cpp
src/profiling/CommandHandlerRegistry.hpp
src/profiling/ConnectionAcknowledgedCommandHandler.hpp
src/profiling/PerJobCounterSelectionCommandHandler.hpp
src/profiling/PeriodicCounterSelectionCommandHandler.hpp
src/profiling/ProfilingService.hpp
src/profiling/RequestCounterDirectoryCommandHandler.hpp
src/profiling/test/ProfilingTests.cpp
tests/profiling/gatordmock/GatordMockMain.cpp
tests/profiling/gatordmock/GatordMockService.cpp
tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp
tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp
tests/profiling/gatordmock/tests/GatordMockTests.cpp

index b0603b0..2e22be3 100644 (file)
@@ -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);
         }
index 894e2d4..7f836cb 100644 (file)
@@ -11,6 +11,11 @@ namespace armnn
 namespace profiling
 {
 
+uint32_t CommandHandlerFunctor::GetFamilyId() const
+{
+    return m_FamilyId;
+}
+
 uint32_t CommandHandlerFunctor::GetPacketId() const
 {
     return m_PacketId;
index 7aaab58..4d6dfa0 100644 (file)
@@ -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;
 };
index 66b20c5..4d7e11a 100644 (file)
@@ -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
index 1ec5f51..247f679 100644 (file)
@@ -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;
 };
index bd9b318..8070afe 100644 (file)
@@ -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())
index 9d514bf..43419de 100644 (file)
@@ -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<CommandHandlerKey, CommandHandlerFunctor*, CommandHandlerHash> registry;
index d0dc07a..255fcf6 100644 (file)
@@ -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)
     {}
 
index 6caa08d..738a476 100644 (file)
@@ -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)
     {}
 
index 1da08e3..e2738f8 100644 (file)
@@ -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)
index dda37dd..ea11442 100644 (file)
@@ -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)
     {
index 02bf64d..907be89 100644 (file)
@@ -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)
index 50af75e..c255098 100644 (file)
@@ -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(testKey1<testKey4);
     BOOST_CHECK(testKey1>testKey3);
@@ -71,18 +79,18 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerKeyComparisons)
 
     std::vector<CommandHandlerKey> 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<CommandHandlerKey> 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<CommandHandlerKey, CommandHandlerFunctor*> 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<unsigned char[]> packetDataA;
     std::unique_ptr<unsigned char[]> 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,
index 002d6c7..2423493 100644 (file)
@@ -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);
index 4b9d752..2697b2f 100644 (file)
@@ -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);
 
index b2fd48f..4135a2f 100644 (file)
@@ -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)
     {}
 
index e1172e2..faf9792 100644 (file)
@@ -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)
     {}
 
index 3f58f39..eb4b178 100644 (file)
@@ -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);