aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/SendTimelinePacket.hpp
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-11-13 10:56:41 +0000
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-11-15 17:10:36 +0000
commit9723d0243463e3a32ed11ae1c38298343b4e8818 (patch)
tree336e01c0199657f4a0cf7e71acb056fba2c77a6f /src/profiling/SendTimelinePacket.hpp
parent87972be8d838f6fde6f6e98dd81c422e85457a5e (diff)
downloadarmnn-9723d0243463e3a32ed11ae1c38298343b4e8818.tar.gz
IVGCVSW-4074 Send Timeline message in RequestCounterDirectoryCommandHandler
* Added call to SendTimelineMessageDirectoryPackage in the handler * Updated the unit tests accordingly * Refactored SendTimelinePacket to remove macro Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: I7bb6f8575945b99a0e77ef30ecfe4dee3058669e
Diffstat (limited to 'src/profiling/SendTimelinePacket.hpp')
-rw-r--r--src/profiling/SendTimelinePacket.hpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/profiling/SendTimelinePacket.hpp b/src/profiling/SendTimelinePacket.hpp
index 77268a4eb5..4b2e06328b 100644
--- a/src/profiling/SendTimelinePacket.hpp
+++ b/src/profiling/SendTimelinePacket.hpp
@@ -9,6 +9,8 @@
#include "ISendTimelinePacket.hpp"
#include "ProfilingUtils.hpp"
+#include <boost/assert.hpp>
+
#include <memory>
namespace armnn
@@ -54,12 +56,52 @@ private:
/// Reserves maximum packet size from buffer
void ReserveBuffer();
+ template <typename Func, typename ... Params>
+ void ForwardWriteBinaryFunction(Func& func, Params&& ... params);
+
IBufferManager& m_BufferManager;
IPacketBufferPtr m_WriteBuffer;
unsigned int m_Offset;
unsigned int m_BufferSize;
};
+template <typename Func, typename ... Params>
+void SendTimelinePacket::ForwardWriteBinaryFunction(Func& func, Params&& ... params)
+{
+ try
+ {
+ ReserveBuffer();
+ BOOST_ASSERT(m_WriteBuffer);
+ unsigned int numberOfBytesWritten = 0;
+ while (true)
+ {
+ TimelinePacketStatus result = func(std::forward<Params>(params)...,
+ &m_WriteBuffer->GetWritableData()[m_Offset],
+ m_BufferSize,
+ numberOfBytesWritten);
+ switch (result)
+ {
+ case TimelinePacketStatus::BufferExhaustion:
+ Commit();
+ ReserveBuffer();
+ continue;
+
+ case TimelinePacketStatus::Error:
+ throw RuntimeException("Error processing while sending TimelineBinaryPacket", CHECK_LOCATION());
+
+ default:
+ m_Offset += numberOfBytesWritten;
+ m_BufferSize -= numberOfBytesWritten;
+ return;
+ }
+ }
+ }
+ catch (...)
+ {
+ throw RuntimeException("Error processing while sending TimelineBinaryPacket", CHECK_LOCATION());
+ }
+}
+
} // namespace profiling
} // namespace armnn