aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFinn Williams <Finn.Williams@arm.com>2020-04-29 13:17:30 +0100
committerfinn.williams <finn.williams@arm.com>2020-05-07 13:56:43 +0000
commite09fc820968ee4de20df60e371088582a710bad0 (patch)
tree17047a89e67ff0265a801d79add45c263cab1259
parentec99f2907ceecf8045d1cf392a51e57d9fb6bb60 (diff)
downloadarmnn-e09fc820968ee4de20df60e371088582a710bad0.tar.gz
IVGCVSW-4730 Remove the duplication of PIPE_MAGIC in the code base
Change-Id: I41c6e917b29eee33360758b6c5afe5dadba89093 Signed-off-by: Finn Williams <Finn.Williams@arm.com>
-rw-r--r--CMakeLists.txt2
-rw-r--r--profiling/common/include/Constants.hpp10
-rw-r--r--profiling/server/src/basePipeServer/BasePipeServer.cpp6
-rw-r--r--profiling/server/src/basePipeServer/BasePipeServer.hpp1
-rw-r--r--src/profiling/FileOnlyProfilingConnection.cpp5
-rw-r--r--src/profiling/FileOnlyProfilingConnection.hpp2
-rw-r--r--src/profiling/SendCounterPacket.cpp5
-rw-r--r--src/profiling/SendCounterPacket.hpp2
-rw-r--r--src/profiling/test/SendCounterPacketTests.cpp5
9 files changed, 24 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dba41a3f55..eefa5e70bb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -252,7 +252,7 @@ list(APPEND armnn_sources
include/armnn/utility/StringUtils.hpp
profiling/common/include/ProfilingException.hpp
profiling/common/include/SocketConnectionException.hpp
- profiling/common/include/NetworkSockets.hpp
+ profiling/common/include/Constants.hpp
profiling/common/src/NetworkSockets.cpp
src/armnn/layers/LayerCloneBase.hpp
src/armnn/layers/LayerWithParameters.hpp
diff --git a/profiling/common/include/Constants.hpp b/profiling/common/include/Constants.hpp
new file mode 100644
index 0000000000..52e0e487a8
--- /dev/null
+++ b/profiling/common/include/Constants.hpp
@@ -0,0 +1,10 @@
+//
+// Copyright © 2020 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#pragma once
+
+namespace armnnProfiling
+{
+ static const unsigned int PIPE_MAGIC = 0x45495434;
+} \ No newline at end of file
diff --git a/profiling/server/src/basePipeServer/BasePipeServer.cpp b/profiling/server/src/basePipeServer/BasePipeServer.cpp
index 1d5e0b6414..7e8789aa2a 100644
--- a/profiling/server/src/basePipeServer/BasePipeServer.cpp
+++ b/profiling/server/src/basePipeServer/BasePipeServer.cpp
@@ -5,6 +5,8 @@
#include "BasePipeServer.hpp"
+#include "common/include/Constants.hpp"
+
#include <iostream>
#include <boost/cast.hpp>
#include <vector>
@@ -65,11 +67,11 @@ bool BasePipeServer::WaitForStreamMetaData()
EchoPacket(PacketDirection::ReceivedData, pipeMagic, 4);
// Before we interpret the length we need to read the pipe_magic word to determine endianness.
- if (ToUint32(&pipeMagic[0], TargetEndianness::BeWire) == PIPE_MAGIC)
+ if (ToUint32(&pipeMagic[0], TargetEndianness::BeWire) == armnnProfiling::PIPE_MAGIC)
{
m_Endianness = TargetEndianness::BeWire;
}
- else if (ToUint32(&pipeMagic[0], TargetEndianness::LeWire) == PIPE_MAGIC)
+ else if (ToUint32(&pipeMagic[0], TargetEndianness::LeWire) == armnnProfiling::PIPE_MAGIC)
{
m_Endianness = TargetEndianness::LeWire;
}
diff --git a/profiling/server/src/basePipeServer/BasePipeServer.hpp b/profiling/server/src/basePipeServer/BasePipeServer.hpp
index c03774e452..4e6e0c0e4b 100644
--- a/profiling/server/src/basePipeServer/BasePipeServer.hpp
+++ b/profiling/server/src/basePipeServer/BasePipeServer.hpp
@@ -107,7 +107,6 @@ private:
armnnUtils::Sockets::Socket m_ClientConnection;
bool m_EchoPackets;
TargetEndianness m_Endianness;
- static const uint32_t PIPE_MAGIC = 0x45495434;
uint32_t m_StreamMetaDataVersion;
uint32_t m_StreamMetaDataMaxDataLen;
diff --git a/src/profiling/FileOnlyProfilingConnection.cpp b/src/profiling/FileOnlyProfilingConnection.cpp
index 5947d2c081..1d4e23b7aa 100644
--- a/src/profiling/FileOnlyProfilingConnection.cpp
+++ b/src/profiling/FileOnlyProfilingConnection.cpp
@@ -7,6 +7,7 @@
#include "PacketVersionResolver.hpp"
#include <armnn/Exceptions.hpp>
+#include <common/include/Constants.hpp>
#include <algorithm>
#include <boost/numeric/conversion/cast.hpp>
@@ -59,11 +60,11 @@ bool FileOnlyProfilingConnection::WaitForStreamMeta(const unsigned char* buffer,
}
// Before we interpret the length we need to read the pipe_magic word to determine endianness.
- if (ToUint32(buffer + 8, TargetEndianness::BeWire) == PIPE_MAGIC)
+ if (ToUint32(buffer + 8, TargetEndianness::BeWire) == armnnProfiling::PIPE_MAGIC)
{
m_Endianness = TargetEndianness::BeWire;
}
- else if (ToUint32(buffer + 8, TargetEndianness::LeWire) == PIPE_MAGIC)
+ else if (ToUint32(buffer + 8, TargetEndianness::LeWire) == armnnProfiling::PIPE_MAGIC)
{
m_Endianness = TargetEndianness::LeWire;
}
diff --git a/src/profiling/FileOnlyProfilingConnection.hpp b/src/profiling/FileOnlyProfilingConnection.hpp
index 12ac27333d..466f4f1831 100644
--- a/src/profiling/FileOnlyProfilingConnection.hpp
+++ b/src/profiling/FileOnlyProfilingConnection.hpp
@@ -94,8 +94,6 @@ private:
void ForwardPacketToHandlers(Packet& packet);
void ServiceLocalHandlers();
- static const uint32_t PIPE_MAGIC = 0x45495434;
-
Runtime::CreationOptions::ExternalProfilingOptions m_Options;
bool m_QuietOp;
std::vector<uint16_t> m_IdList;
diff --git a/src/profiling/SendCounterPacket.cpp b/src/profiling/SendCounterPacket.cpp
index f251684f7b..d916dd8b97 100644
--- a/src/profiling/SendCounterPacket.cpp
+++ b/src/profiling/SendCounterPacket.cpp
@@ -10,6 +10,7 @@
#include <armnn/Conversion.hpp>
#include <Processes.hpp>
#include <armnn/utility/Assert.hpp>
+#include <common/include/Constants.hpp>
#include <boost/format.hpp>
#include <boost/numeric/conversion/cast.hpp>
@@ -24,8 +25,6 @@ namespace profiling
using boost::numeric_cast;
-const unsigned int SendCounterPacket::PIPE_MAGIC;
-
void SendCounterPacket::SendStreamMetaDataPacket()
{
const std::string info(GetSoftwareInfo());
@@ -81,7 +80,7 @@ void SendCounterPacket::SendStreamMetaDataPacket()
// Packet body
offset += sizeUint32;
- WriteUint32(writeBuffer, offset, PIPE_MAGIC); // pipe_magic
+ WriteUint32(writeBuffer, offset, armnnProfiling::PIPE_MAGIC); // pipe_magic
offset += sizeUint32;
WriteUint32(writeBuffer, offset, EncodeVersion(1, 0, 0)); // stream_metadata_version
offset += sizeUint32;
diff --git a/src/profiling/SendCounterPacket.hpp b/src/profiling/SendCounterPacket.hpp
index 1880a2a47d..4262c93676 100644
--- a/src/profiling/SendCounterPacket.hpp
+++ b/src/profiling/SendCounterPacket.hpp
@@ -40,8 +40,6 @@ public:
void SendPeriodicCounterSelectionPacket(uint32_t capturePeriod,
const std::vector<uint16_t>& selectedCounterIds) override;
- static const unsigned int PIPE_MAGIC = 0x45495434;
-
private:
template <typename ExceptionType>
void CancelOperationAndThrow(const std::string& errorMessage)
diff --git a/src/profiling/test/SendCounterPacketTests.cpp b/src/profiling/test/SendCounterPacketTests.cpp
index dd271c9594..9b3a86a5f4 100644
--- a/src/profiling/test/SendCounterPacketTests.cpp
+++ b/src/profiling/test/SendCounterPacketTests.cpp
@@ -18,6 +18,9 @@
#include <armnn/Conversion.hpp>
#include <armnn/Utils.hpp>
+#include <common/include/Constants.hpp>
+
+
#include <boost/test/unit_test.hpp>
#include <boost/numeric/conversion/cast.hpp>
@@ -324,7 +327,7 @@ BOOST_AUTO_TEST_CASE(SendStreamMetaDataPacketTest)
BOOST_TEST(headerWord1 == totalLength - (2 * sizeUint32)); // data length
uint32_t offset = sizeUint32 * 2;
- BOOST_TEST(ReadUint32(readBuffer2, offset) == SendCounterPacket::PIPE_MAGIC); // pipe_magic
+ BOOST_TEST(ReadUint32(readBuffer2, offset) == armnnProfiling::PIPE_MAGIC); // pipe_magic
offset += sizeUint32;
BOOST_TEST(ReadUint32(readBuffer2, offset) == EncodeVersion(1, 0, 0)); // stream_metadata_version
offset += sizeUint32;