aboutsummaryrefslogtreecommitdiff
path: root/profiling
diff options
context:
space:
mode:
authorFinn Williams <Finn.Williams@arm.com>2020-05-07 10:38:15 +0100
committerJim Flynn <jim.flynn@arm.com>2020-05-12 22:00:17 +0000
commit0c8cb99db6dd8b1ea073ef7227b2872a3cb0b269 (patch)
tree3a2301175e09d7e6f2f5feb2d8c6f8a184493b4c /profiling
parentd6cb30e7052891996efa41f608fffe4fa62d2094 (diff)
downloadarmnn-0c8cb99db6dd8b1ea073ef7227b2872a3cb0b269.tar.gz
IVGCVSW-4731 Move Packet.hpp to profiling/common/include
* Refactor profiling cmake to fix inconsistencies/issues with includes Signed-off-by: Finn Williams <Finn.Williams@arm.com> Change-Id: I0836762d4c72e25754a28162ec54c8e332422a02
Diffstat (limited to 'profiling')
-rw-r--r--profiling/common/include/Packet.hpp89
-rw-r--r--profiling/server/src/basePipeServer/BasePipeServer.hpp6
-rw-r--r--profiling/server/src/basePipeServer/CMakeLists.txt17
-rw-r--r--profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp2
4 files changed, 104 insertions, 10 deletions
diff --git a/profiling/common/include/Packet.hpp b/profiling/common/include/Packet.hpp
new file mode 100644
index 0000000000..c1f2796804
--- /dev/null
+++ b/profiling/common/include/Packet.hpp
@@ -0,0 +1,89 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <armnn/Exceptions.hpp>
+
+#include <memory>
+
+namespace armnn
+{
+
+namespace profiling
+{
+
+class Packet
+{
+public:
+ Packet()
+ : m_Header(0)
+ , m_Length(0)
+ , m_Data(nullptr)
+ {}
+
+ Packet(uint32_t header)
+ : m_Header(header)
+ , m_Length(0)
+ , m_Data(nullptr)
+ {
+ m_PacketId = ((header >> 16) & 1023);
+ m_PacketFamily = (header >> 26);
+ }
+
+ Packet(uint32_t header, uint32_t length, std::unique_ptr<unsigned char[]>& data)
+ : m_Header(header)
+ , m_Length(length)
+ , m_Data(std::move(data))
+ {
+ m_PacketId = ((header >> 16) & 1023);
+ m_PacketFamily = (header >> 26);
+
+ if (length == 0 && m_Data != nullptr)
+ {
+ throw armnn::InvalidArgumentException("Data should be null when length is zero");
+ }
+ }
+
+ Packet(Packet&& other)
+ : m_Header(other.m_Header)
+ , m_PacketFamily(other.m_PacketFamily)
+ , m_PacketId(other.m_PacketId)
+ , m_Length(other.m_Length)
+ , m_Data(std::move(other.m_Data))
+ {
+ other.m_Header = 0;
+ other.m_PacketFamily = 0;
+ other.m_PacketId = 0;
+ other.m_Length = 0;
+ }
+
+ ~Packet() = default;
+
+ Packet(const Packet& other) = delete;
+ Packet& operator=(const Packet&) = delete;
+ Packet& operator=(Packet&&) = default;
+
+ uint32_t GetHeader() const { return m_Header; }
+ uint32_t GetPacketFamily() const { return m_PacketFamily; }
+ uint32_t GetPacketId() const { return m_PacketId; }
+ uint32_t GetPacketClass() const { return m_PacketId >> 3; }
+ uint32_t GetPacketType() const { return m_PacketId & 7; }
+ uint32_t GetLength() const { return m_Length; }
+ const unsigned char* GetData() const { return m_Data.get(); }
+
+ bool IsEmpty() { return m_Header == 0 && m_Length == 0; }
+
+private:
+ uint32_t m_Header;
+ uint32_t m_PacketFamily;
+ uint32_t m_PacketId;
+ uint32_t m_Length;
+ std::unique_ptr<unsigned char[]> m_Data;
+};
+
+} // namespace profiling
+
+} // namespace armnn
diff --git a/profiling/server/src/basePipeServer/BasePipeServer.hpp b/profiling/server/src/basePipeServer/BasePipeServer.hpp
index 4e6e0c0e4b..bef9d29f44 100644
--- a/profiling/server/src/basePipeServer/BasePipeServer.hpp
+++ b/profiling/server/src/basePipeServer/BasePipeServer.hpp
@@ -5,9 +5,9 @@
#pragma once
-#include "common/include/NetworkSockets.hpp"
-#include "../../../../src/profiling/Packet.hpp"
-#include "common/include/SocketConnectionException.hpp"
+#include <NetworkSockets.hpp>
+#include <Packet.hpp>
+#include <SocketConnectionException.hpp>
#include <string>
#include <atomic>
diff --git a/profiling/server/src/basePipeServer/CMakeLists.txt b/profiling/server/src/basePipeServer/CMakeLists.txt
index e535cf2e66..b2cb82d816 100644
--- a/profiling/server/src/basePipeServer/CMakeLists.txt
+++ b/profiling/server/src/basePipeServer/CMakeLists.txt
@@ -6,15 +6,20 @@
if(BUILD_BASE_PIPE_SERVER)
set(BasePipeServer_sources)
list(APPEND BasePipeServer_sources
- BasePipeServer.cpp
- BasePipeServer.hpp
- ConnectionHandler.cpp
- ConnectionHandler.hpp
- )
+ BasePipeServer.cpp
+ BasePipeServer.hpp
+ ConnectionHandler.cpp
+ ConnectionHandler.hpp)
- include_directories(src/armnnUtils src/profiling)
+ include_directories(${PROJECT_SOURCE_DIR}/profiling/common/include)
+
+ if (BUILD_UNIT_TESTS)
+ target_include_directories(UnitTests PRIVATE ${PROJECT_SOURCE_DIR}/profiling/server/src/basePipeServer)
+ target_include_directories(UnitTests PUBLIC ${PROJECT_SOURCE_DIR}/profiling/common/include)
+ endif()
add_library_ex(armnnBasePipeServer SHARED ${BasePipeServer_sources})
+
set_target_properties(armnnBasePipeServer PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set_target_properties(armnnBasePipeServer PROPERTIES VERSION ${GENERIC_LIB_VERSION}
SOVERSION ${GENERIC_LIB_SOVERSION})
diff --git a/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp b/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp
index c85bbe72d3..c97fecd94d 100644
--- a/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp
+++ b/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: MIT
//
-#include "../ConnectionHandler.hpp"
+#include <ConnectionHandler.hpp>
#include <SocketProfilingConnection.hpp>
#include <Processes.hpp>