From: Finn Williams Date: Wed, 29 Apr 2020 12:17:30 +0000 (+0100) Subject: IVGCVSW-4730 Remove the duplication of PIPE_MAGIC in the code base X-Git-Tag: submit/tizen/20200730.023729~73 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e09fc820968ee4de20df60e371088582a710bad0;p=platform%2Fupstream%2Farmnn.git IVGCVSW-4730 Remove the duplication of PIPE_MAGIC in the code base Change-Id: I41c6e917b29eee33360758b6c5afe5dadba89093 Signed-off-by: Finn Williams --- diff --git a/CMakeLists.txt b/CMakeLists.txt index dba41a3..eefa5e7 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 0000000..52e0e48 --- /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 1d5e0b6..7e8789a 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 #include #include @@ -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 c03774e..4e6e0c0 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 5947d2c..1d4e23b 100644 --- a/src/profiling/FileOnlyProfilingConnection.cpp +++ b/src/profiling/FileOnlyProfilingConnection.cpp @@ -7,6 +7,7 @@ #include "PacketVersionResolver.hpp" #include +#include #include #include @@ -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 12ac273..466f4f1 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 m_IdList; diff --git a/src/profiling/SendCounterPacket.cpp b/src/profiling/SendCounterPacket.cpp index f251684..d916dd8 100644 --- a/src/profiling/SendCounterPacket.cpp +++ b/src/profiling/SendCounterPacket.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -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 1880a2a..4262c93 100644 --- a/src/profiling/SendCounterPacket.hpp +++ b/src/profiling/SendCounterPacket.hpp @@ -40,8 +40,6 @@ public: void SendPeriodicCounterSelectionPacket(uint32_t capturePeriod, const std::vector& selectedCounterIds) override; - static const unsigned int PIPE_MAGIC = 0x45495434; - private: template void CancelOperationAndThrow(const std::string& errorMessage) diff --git a/src/profiling/test/SendCounterPacketTests.cpp b/src/profiling/test/SendCounterPacketTests.cpp index dd271c9..9b3a86a 100644 --- a/src/profiling/test/SendCounterPacketTests.cpp +++ b/src/profiling/test/SendCounterPacketTests.cpp @@ -18,6 +18,9 @@ #include #include +#include + + #include #include @@ -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;