aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/SendCounterPacket.cpp
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-09-05 12:02:04 +0100
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-09-09 16:47:50 +0000
commit149528e88c081e71fc7ec78e0c301eb2e487adfc (patch)
treea287157d725f3186c44f9c8f71141cd694333249 /src/profiling/SendCounterPacket.cpp
parenta85e215dd1b027c5ef88621d1b4d5f6e078605da (diff)
downloadarmnn-149528e88c081e71fc7ec78e0c301eb2e487adfc.tar.gz
IVGCVSW-3691 Basic refactoring in view of upcoming work in the profiler
Change-Id: Iea4550b864fc2adb04a3a2411a7ead06b1f60ab9 Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Diffstat (limited to 'src/profiling/SendCounterPacket.cpp')
-rw-r--r--src/profiling/SendCounterPacket.cpp58
1 files changed, 25 insertions, 33 deletions
diff --git a/src/profiling/SendCounterPacket.cpp b/src/profiling/SendCounterPacket.cpp
index 61d32da0bc..94a5db223e 100644
--- a/src/profiling/SendCounterPacket.cpp
+++ b/src/profiling/SendCounterPacket.cpp
@@ -13,9 +13,7 @@
#include <boost/numeric/conversion/cast.hpp>
#include <boost/core/ignore_unused.hpp>
-#include <iostream>
-#include <unistd.h>
-#include <string.h>
+#include <cstring>
namespace armnn
{
@@ -69,17 +67,14 @@ void SendCounterPacket::SendStreamMetaDataPacket()
if (reserved < totalSize)
{
- // Cancel the operation.
- m_Buffer.Commit(0);
- throw RuntimeException(boost::str(boost::format("No space left in buffer. Unable to reserve (%1%) bytes.")
- % totalSize));
+ CancelOperationAndThrow<BufferExhaustion>(
+ boost::str(boost::format("No space left in buffer. Unable to reserve (%1%) bytes.")
+ % totalSize));
}
if (writeBuffer == nullptr)
{
- // Cancel the operation.
- m_Buffer.Commit(0);
- throw RuntimeException("Error reserving buffer memory.");
+ CancelOperationAndThrow<RuntimeException>("Error reserving buffer memory.");
}
try
@@ -121,27 +116,32 @@ void SendCounterPacket::SendStreamMetaDataPacket()
// Pool
- if (infoSize) {
+ if (infoSize)
+ {
memcpy(&writeBuffer[offset], info.c_str(), infoSize);
offset += infoSize;
}
- if (hardwareVersionSize) {
+ if (hardwareVersionSize)
+ {
memcpy(&writeBuffer[offset], hardwareVersion.c_str(), hardwareVersionSize);
offset += hardwareVersionSize;
}
- if (softwareVersionSize) {
+ if (softwareVersionSize)
+ {
memcpy(&writeBuffer[offset], softwareVersion.c_str(), softwareVersionSize);
offset += softwareVersionSize;
}
- if (processNameSize) {
+ if (processNameSize)
+ {
memcpy(&writeBuffer[offset], processName.c_str(), processNameSize);
offset += processNameSize;
}
- if (packetVersionEntries) {
+ if (packetVersionEntries)
+ {
// Packet Version Count
WriteUint32(writeBuffer, offset, packetVersionEntries << 16);
@@ -160,15 +160,13 @@ void SendCounterPacket::SendStreamMetaDataPacket()
}
catch(...)
{
- // Cancel the operation.
- m_Buffer.Commit(0);
- throw RuntimeException("Error processing packet.");
+ CancelOperationAndThrow<RuntimeException>("Error processing packet.");
}
m_Buffer.Commit(totalSize);
}
-void SendCounterPacket::SendCounterDirectoryPacket(const Category& category, const std::vector<Counter>& counters)
+void SendCounterPacket::SendCounterDirectoryPacket(const CounterDirectory& counterDirectory)
{
throw armnn::UnimplementedException();
}
@@ -189,17 +187,14 @@ void SendCounterPacket::SendPeriodicCounterCapturePacket(uint64_t timestamp, con
if (reserved < totalSize)
{
- // Cancel the operation.
- m_Buffer.Commit(0);
- throw profiling::BufferExhaustion(
- boost::str(boost::format("No space left in buffer. Unable to reserve (%1%) bytes.") % totalSize));
+ CancelOperationAndThrow<BufferExhaustion>(
+ boost::str(boost::format("No space left in buffer. Unable to reserve (%1%) bytes.")
+ % totalSize));
}
if (writeBuffer == nullptr)
{
- // Cancel the operation.
- m_Buffer.Commit(0);
- throw RuntimeException("Error reserving buffer memory.");
+ CancelOperationAndThrow<RuntimeException>("Error reserving buffer memory.");
}
// Create header.
@@ -242,17 +237,14 @@ void SendCounterPacket::SendPeriodicCounterSelectionPacket(uint32_t capturePerio
if (reserved < totalSize)
{
- // Cancel the operation.
- m_Buffer.Commit(0);
- throw RuntimeException(boost::str(boost::format("No space left in buffer. Unable to reserve (%1%) bytes.")
+ CancelOperationAndThrow<BufferExhaustion>(
+ boost::str(boost::format("No space left in buffer. Unable to reserve (%1%) bytes.")
% totalSize));
}
if (writeBuffer == nullptr)
{
- // Cancel the operation.
- m_Buffer.Commit(0);
- throw RuntimeException("Error reserving buffer memory.");
+ CancelOperationAndThrow<RuntimeException>("Error reserving buffer memory.");
}
// Create header.
@@ -282,4 +274,4 @@ void SendCounterPacket::SetReadyToRead()
} // namespace profiling
-} // namespace armnn \ No newline at end of file
+} // namespace armnn