aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/RequestCounterDirectoryCommandHandler.cpp
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-10-10 14:30:29 +0100
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-10-10 14:30:56 +0100
commit8efc500a7465c03877db8bbe443134f2b1bbc1af (patch)
treefcf4f4a56fa5f20ace8a1e5dfc175cecfd2373a7 /src/profiling/RequestCounterDirectoryCommandHandler.cpp
parenta3600ba71978225e4d21399fb781d4850f2bb25f (diff)
downloadarmnn-8efc500a7465c03877db8bbe443134f2b1bbc1af.tar.gz
IVGCVSW-3963 Implement the Request Counter Directory Handler
* Integrated the RequestCounterDirectoryCommandHandler in the ProfilingService class * Code refactoring * Added/Updated unit tests Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: I60d9f8acf166e29b3dabc921dbdb8149461bd85f
Diffstat (limited to 'src/profiling/RequestCounterDirectoryCommandHandler.cpp')
-rw-r--r--src/profiling/RequestCounterDirectoryCommandHandler.cpp36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/profiling/RequestCounterDirectoryCommandHandler.cpp b/src/profiling/RequestCounterDirectoryCommandHandler.cpp
index 0fdcf10de4..e85acb4215 100644
--- a/src/profiling/RequestCounterDirectoryCommandHandler.cpp
+++ b/src/profiling/RequestCounterDirectoryCommandHandler.cpp
@@ -5,7 +5,7 @@
#include "RequestCounterDirectoryCommandHandler.hpp"
-#include <boost/assert.hpp>
+#include <boost/format.hpp>
namespace armnn
{
@@ -15,10 +15,36 @@ namespace profiling
void RequestCounterDirectoryCommandHandler::operator()(const Packet& packet)
{
- BOOST_ASSERT(packet.GetLength() == 0);
-
- // Write packet to Counter Stream Buffer
- m_SendCounterPacket.SendCounterDirectoryPacket(m_CounterDirectory);
+ ProfilingState currentState = m_StateMachine.GetCurrentState();
+ switch (currentState)
+ {
+ case ProfilingState::Uninitialised:
+ case ProfilingState::NotConnected:
+ case ProfilingState::WaitingForAck:
+ throw RuntimeException(boost::str(boost::format("Request Counter Directory Handler invoked while in an "
+ "wrong state: %1%")
+ % GetProfilingStateName(currentState)));
+ case ProfilingState::Active:
+ // Process the packet
+ if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 3u))
+ {
+ throw armnn::InvalidArgumentException(boost::str(boost::format("Expected Packet family = 0, id = 3 but "
+ "received family = %1%, id = %2%")
+ % packet.GetPacketFamily()
+ % packet.GetPacketId()));
+ }
+
+ // Write a Counter Directory packet to the Counter Stream Buffer
+ m_SendCounterPacket.SendCounterDirectoryPacket(m_CounterDirectory);
+
+ // Notify the Send Thread that new data is available in the Counter Stream Buffer
+ m_SendCounterPacket.SetReadyToRead();
+
+ break;
+ default:
+ throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1%")
+ % static_cast<int>(currentState)));
+ }
}
} // namespace profiling