aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Flynn <jim.flynn@arm.com>2020-07-20 16:57:44 +0100
committerJim Flynn <jim.flynn@arm.com>2020-07-29 15:35:15 +0100
commitbbfe603e5ae42317a2b67d713d00882bea341c88 (patch)
tree8d8a78d6836384fb92fb9741c865443624dfec68
parenta9c2ce123a6a5a68728d040a0323c482bbe46903 (diff)
downloadarmnn-bbfe603e5ae42317a2b67d713d00882bea341c88.tar.gz
IVGCVSW-5166 Pull out the common and server side code into standalone libraries
Change-Id: I180f84c493a9b2be4b93b25d312ebdd9e71b1735 Signed-off-by: Jim Flynn <jim.flynn@arm.com>
-rw-r--r--Android.mk18
-rw-r--r--CMakeLists.txt26
-rw-r--r--cmake/GlobalConfig.cmake37
-rw-r--r--include/armnn/Conversion.hpp2
-rw-r--r--include/armnn/Logging.hpp2
-rw-r--r--include/armnn/profiling/ILocalPacketHandler.hpp16
-rw-r--r--include/armnn/utility/Assert.hpp2
-rw-r--r--include/armnn/utility/IgnoreUnused.hpp2
-rw-r--r--include/armnn/utility/NumericCast.hpp2
-rw-r--r--profiling/CMakeLists.txt36
-rwxr-xr-xprofiling/buildpipe.sh91
-rw-r--r--profiling/common/include/Assert.hpp24
-rw-r--r--profiling/common/include/CommandHandlerFunctor.hpp (renamed from src/profiling/CommandHandlerFunctor.hpp)13
-rw-r--r--profiling/common/include/CommandHandlerKey.hpp (renamed from src/profiling/CommandHandlerKey.hpp)10
-rw-r--r--profiling/common/include/CommandHandlerRegistry.hpp (renamed from src/profiling/CommandHandlerRegistry.hpp)18
-rw-r--r--profiling/common/include/CommonProfilingUtils.hpp38
-rw-r--r--profiling/common/include/Constants.hpp10
-rw-r--r--profiling/common/include/Conversion.hpp43
-rw-r--r--profiling/common/include/EncodeVersion.hpp (renamed from src/profiling/EncodeVersion.hpp)10
-rw-r--r--profiling/common/include/IgnoreUnused.hpp18
-rw-r--r--profiling/common/include/Logging.hpp182
-rw-r--r--profiling/common/include/NetworkSockets.hpp19
-rw-r--r--profiling/common/include/NumericCast.hpp128
-rw-r--r--profiling/common/include/Packet.hpp14
-rw-r--r--profiling/common/include/PacketVersionResolver.hpp (renamed from src/profiling/PacketVersionResolver.hpp)10
-rw-r--r--profiling/common/include/ProfilingException.hpp63
-rw-r--r--profiling/common/include/SocketConnectionException.hpp27
-rw-r--r--profiling/common/include/SwTrace.hpp139
-rw-r--r--profiling/common/include/WindowsWrapper.hpp (renamed from src/armnnUtils/WindowsWrapper.hpp)15
-rw-r--r--profiling/common/src/CMakeLists.txt30
-rw-r--r--profiling/common/src/CommandHandlerFunctor.cpp (renamed from src/profiling/CommandHandlerFunctor.cpp)10
-rw-r--r--profiling/common/src/CommandHandlerKey.cpp (renamed from src/profiling/CommandHandlerKey.cpp)10
-rw-r--r--profiling/common/src/CommandHandlerRegistry.cpp (renamed from src/profiling/CommandHandlerRegistry.cpp)34
-rw-r--r--profiling/common/src/CommonProfilingUtils.cpp145
-rw-r--r--profiling/common/src/NetworkSockets.cpp51
-rw-r--r--profiling/common/src/PacketVersionResolver.cpp (renamed from src/profiling/PacketVersionResolver.cpp)14
-rw-r--r--profiling/common/src/SwTrace.cpp128
-rw-r--r--profiling/server/include/basePipeServer/BasePipeServer.hpp (renamed from profiling/server/src/basePipeServer/BasePipeServer.hpp)30
-rw-r--r--profiling/server/include/basePipeServer/ConnectionHandler.hpp (renamed from profiling/server/src/basePipeServer/ConnectionHandler.hpp)14
-rw-r--r--profiling/server/include/timelineDecoder/ITimelineDecoder.hpp (renamed from include/armnn/profiling/ITimelineDecoder.hpp)13
-rw-r--r--profiling/server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp (renamed from src/timelineDecoder/TimelineCaptureCommandHandler.hpp)22
-rw-r--r--profiling/server/include/timelineDecoder/TimelineDecoder.hpp (renamed from src/timelineDecoder/TimelineDecoder.hpp)14
-rw-r--r--profiling/server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp (renamed from src/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp)24
-rw-r--r--profiling/server/src/basePipeServer/BasePipeServer.cpp63
-rw-r--r--profiling/server/src/basePipeServer/CMakeLists.txt48
-rw-r--r--profiling/server/src/basePipeServer/ConnectionHandler.cpp23
-rw-r--r--profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp8
-rw-r--r--profiling/server/src/timelineDecoder/CMakeLists.txt44
-rw-r--r--profiling/server/src/timelineDecoder/TimelineCaptureCommandHandler.cpp (renamed from src/timelineDecoder/TimelineCaptureCommandHandler.cpp)54
-rw-r--r--profiling/server/src/timelineDecoder/TimelineDecoder.cpp (renamed from src/timelineDecoder/TimelineDecoder.cpp)71
-rw-r--r--profiling/server/src/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp (renamed from src/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp)47
-rw-r--r--profiling/server/src/timelineDecoder/tests/TimelineTests.cpp (renamed from src/timelineDecoder/tests/TimelineTests.cpp)114
-rw-r--r--profiling/toolchain-x86-ubuntu-mingw64.cmake28
-rw-r--r--src/armnn/Logging.cpp4
-rw-r--r--src/armnn/test/UnitTests.cpp4
-rw-r--r--src/armnn/test/UnitTests.hpp2
-rw-r--r--src/armnnUtils/Processes.cpp2
-rw-r--r--src/armnnUtils/Threads.cpp2
-rw-r--r--src/backends/backendsCommon/test/BackendProfilingTests.cpp8
-rw-r--r--src/profiling/ActivateTimelineReportingCommandHandler.cpp4
-rw-r--r--src/profiling/ActivateTimelineReportingCommandHandler.hpp10
-rw-r--r--src/profiling/CommandHandler.cpp27
-rw-r--r--src/profiling/CommandHandler.hpp15
-rw-r--r--src/profiling/ConnectionAcknowledgedCommandHandler.cpp2
-rw-r--r--src/profiling/ConnectionAcknowledgedCommandHandler.hpp9
-rw-r--r--src/profiling/CounterDirectory.cpp19
-rw-r--r--src/profiling/CounterDirectory.hpp12
-rw-r--r--src/profiling/DeactivateTimelineReportingCommandHandler.cpp4
-rw-r--r--src/profiling/DeactivateTimelineReportingCommandHandler.hpp11
-rw-r--r--src/profiling/DirectoryCaptureCommandHandler.cpp7
-rw-r--r--src/profiling/DirectoryCaptureCommandHandler.hpp11
-rw-r--r--src/profiling/FileOnlyProfilingConnection.cpp32
-rw-r--r--src/profiling/FileOnlyProfilingConnection.hpp19
-rw-r--r--src/profiling/IProfilingConnection.hpp5
-rw-r--r--src/profiling/PerJobCounterSelectionCommandHandler.cpp15
-rw-r--r--src/profiling/PerJobCounterSelectionCommandHandler.hpp11
-rw-r--r--src/profiling/PeriodicCounterSelectionCommandHandler.cpp6
-rw-r--r--src/profiling/PeriodicCounterSelectionCommandHandler.hpp14
-rw-r--r--src/profiling/ProfilingConnectionDumpToFileDecorator.cpp8
-rw-r--r--src/profiling/ProfilingConnectionDumpToFileDecorator.hpp6
-rw-r--r--src/profiling/ProfilingConnectionFactory.cpp2
-rw-r--r--src/profiling/ProfilingConnectionFactory.hpp2
-rw-r--r--src/profiling/ProfilingService.cpp2
-rw-r--r--src/profiling/ProfilingService.hpp34
-rw-r--r--src/profiling/ProfilingUtils.cpp227
-rw-r--r--src/profiling/ProfilingUtils.hpp120
-rw-r--r--src/profiling/RequestCounterDirectoryCommandHandler.cpp2
-rw-r--r--src/profiling/RequestCounterDirectoryCommandHandler.hpp9
-rw-r--r--src/profiling/SendCounterPacket.cpp45
-rw-r--r--src/profiling/SendThread.cpp7
-rw-r--r--src/profiling/SocketProfilingConnection.cpp51
-rw-r--r--src/profiling/SocketProfilingConnection.hpp6
-rw-r--r--src/profiling/test/BufferTests.cpp10
-rw-r--r--src/profiling/test/PrintPacketHeaderHandler.cpp5
-rw-r--r--src/profiling/test/PrintPacketHeaderHandler.hpp7
-rw-r--r--src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp12
-rw-r--r--src/profiling/test/ProfilingMocks.hpp6
-rw-r--r--src/profiling/test/ProfilingTests.cpp361
-rw-r--r--src/profiling/test/ProfilingTests.hpp22
-rw-r--r--src/profiling/test/RequestCountersPacketHandler.cpp10
-rw-r--r--src/profiling/test/RequestCountersPacketHandler.hpp7
-rw-r--r--src/profiling/test/SendCounterPacketTests.cpp32
-rw-r--r--src/profiling/test/SendTimelinePacketTests.cpp28
-rw-r--r--src/profiling/test/TestTimelinePacketHandler.cpp35
-rw-r--r--src/profiling/test/TestTimelinePacketHandler.hpp21
-rw-r--r--src/profiling/test/TimelineModel.cpp54
-rw-r--r--src/profiling/test/TimelineModel.hpp34
-rw-r--r--src/profiling/test/TimelinePacketTests.cpp10
-rw-r--r--src/timelineDecoder/CMakeLists.txt26
-rw-r--r--src/timelineDecoder/JSONTimelineDecoder.cpp1
-rw-r--r--src/timelineDecoder/JSONTimelineDecoder.hpp4
-rw-r--r--src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp348
-rw-r--r--tests/profiling/gatordmock/CommandFileParser.cpp2
-rw-r--r--tests/profiling/gatordmock/CommandFileParser.hpp2
-rw-r--r--tests/profiling/gatordmock/CommandLineProcessor.cpp2
-rw-r--r--tests/profiling/gatordmock/CommandLineProcessor.hpp2
-rw-r--r--tests/profiling/gatordmock/CounterDirectory.hpp7
-rw-r--r--tests/profiling/gatordmock/GatordMockMain.cpp10
-rw-r--r--tests/profiling/gatordmock/GatordMockService.cpp36
-rw-r--r--tests/profiling/gatordmock/GatordMockService.hpp51
-rw-r--r--tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp40
-rw-r--r--tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp12
-rw-r--r--tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.cpp8
-rw-r--r--tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp10
-rw-r--r--tests/profiling/gatordmock/StreamMetadataCommandHandler.cpp35
-rw-r--r--tests/profiling/gatordmock/StreamMetadataCommandHandler.hpp12
-rw-r--r--tests/profiling/gatordmock/StubCommandHandler.hpp12
-rw-r--r--tests/profiling/gatordmock/tests/GatordMockTests.cpp36
-rw-r--r--third-party/fmt/src/format.cc69
129 files changed, 2626 insertions, 1583 deletions
diff --git a/Android.mk b/Android.mk
index 781aba6d45..2d3aa96d9c 100644
--- a/Android.mk
+++ b/Android.mk
@@ -92,7 +92,16 @@ LOCAL_C_INCLUDES := \
LOCAL_SRC_FILES := \
$(ARMNN_BACKEND_SOURCES) \
+ profiling/common/src/CommandHandlerFunctor.cpp \
+ profiling/common/src/CommandHandlerKey.cpp \
+ profiling/common/src/CommandHandlerRegistry.cpp \
+ profiling/common/src/CommonProfilingUtils.cpp \
profiling/common/src/NetworkSockets.cpp \
+ profiling/common/src/PacketVersionResolver.cpp \
+ profiling/common/src/SwTrace.cpp \
+ profiling/server/src/timelineDecoder/TimelineCaptureCommandHandler.cpp \
+ profiling/server/src/timelineDecoder/TimelineDecoder.cpp \
+ profiling/server/src/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp \
src/armnn/BackendHelper.cpp \
src/armnn/BackendRegistry.cpp \
src/armnn/Descriptors.cpp \
@@ -199,9 +208,6 @@ LOCAL_SRC_FILES := \
src/profiling/ActivateTimelineReportingCommandHandler.cpp \
src/profiling/BufferManager.cpp \
src/profiling/CommandHandler.cpp \
- src/profiling/CommandHandlerFunctor.cpp \
- src/profiling/CommandHandlerKey.cpp \
- src/profiling/CommandHandlerRegistry.cpp \
src/profiling/ConnectionAcknowledgedCommandHandler.cpp \
src/profiling/CounterDirectory.cpp \
src/profiling/CounterIdMap.cpp \
@@ -211,7 +217,6 @@ LOCAL_SRC_FILES := \
src/profiling/Holder.cpp \
src/profiling/LabelsAndEventClasses.cpp \
src/profiling/PacketBuffer.cpp \
- src/profiling/PacketVersionResolver.cpp \
src/profiling/PeriodicCounterCapture.cpp \
src/profiling/PeriodicCounterSelectionCommandHandler.cpp \
src/profiling/PerJobCounterSelectionCommandHandler.cpp \
@@ -228,10 +233,7 @@ LOCAL_SRC_FILES := \
src/profiling/SocketProfilingConnection.cpp \
src/profiling/TimelinePacketWriterFactory.cpp \
src/profiling/TimelineUtilityMethods.cpp \
- src/profiling/backends/BackendProfiling.cpp \
- src/timelineDecoder/TimelineCaptureCommandHandler.cpp \
- src/timelineDecoder/TimelineDecoder.cpp \
- src/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp
+ src/profiling/backends/BackendProfiling.cpp
LOCAL_STATIC_LIBRARIES := \
arm_compute_library \
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 556beb71a8..1c7258f30f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright © 2020 Arm Ltd. and Contributors All rights reserved.
+# Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
# Copyright 2020 NXP
# SPDX-License-Identifier: MIT
#
@@ -75,7 +75,6 @@ list(APPEND armnnUtils_sources
src/armnnUtils/Threads.hpp
src/armnnUtils/Threads.cpp
src/armnnUtils/Transpose.cpp
- src/armnnUtils/WindowsWrapper.hpp
)
add_library_ex(armnnUtils STATIC ${armnnUtils_sources})
@@ -252,12 +251,6 @@ list(APPEND armnn_sources
include/armnn/utility/NumericCast.hpp
include/armnn/utility/PolymorphicDowncast.hpp
include/armnn/utility/StringUtils.hpp
- profiling/common/include/Packet.hpp
- profiling/common/include/ProfilingException.hpp
- profiling/common/include/SocketConnectionException.hpp
- profiling/common/include/Constants.hpp
- profiling/common/include/NetworkSockets.hpp
- profiling/common/src/NetworkSockets.cpp
src/armnn/layers/LayerCloneBase.hpp
src/armnn/layers/LayerWithParameters.hpp
src/armnn/layers/ActivationLayer.hpp
@@ -478,12 +471,6 @@ list(APPEND armnn_sources
src/profiling/BufferManager.hpp
src/profiling/CommandHandler.cpp
src/profiling/CommandHandler.hpp
- src/profiling/CommandHandlerFunctor.cpp
- src/profiling/CommandHandlerFunctor.hpp
- src/profiling/CommandHandlerKey.cpp
- src/profiling/CommandHandlerKey.hpp
- src/profiling/CommandHandlerRegistry.cpp
- src/profiling/CommandHandlerRegistry.hpp
src/profiling/ConnectionAcknowledgedCommandHandler.cpp
src/profiling/ConnectionAcknowledgedCommandHandler.hpp
src/profiling/CounterDirectory.cpp
@@ -494,7 +481,6 @@ list(APPEND armnn_sources
src/profiling/DeactivateTimelineReportingCommandHandler.hpp
src/profiling/DirectoryCaptureCommandHandler.cpp
src/profiling/DirectoryCaptureCommandHandler.hpp
- src/profiling/EncodeVersion.hpp
src/profiling/FileOnlyProfilingConnection.cpp
src/profiling/FileOnlyProfilingConnection.hpp
src/profiling/Holder.cpp
@@ -517,8 +503,6 @@ list(APPEND armnn_sources
src/profiling/NullProfilingConnection.hpp
src/profiling/PacketBuffer.cpp
src/profiling/PacketBuffer.hpp
- src/profiling/PacketVersionResolver.cpp
- src/profiling/PacketVersionResolver.hpp
src/profiling/PeriodicCounterCapture.hpp
src/profiling/PeriodicCounterCapture.cpp
src/profiling/PeriodicCounterSelectionCommandHandler.cpp
@@ -558,6 +542,7 @@ list(APPEND armnn_sources
third-party/fmt/core.h
third-party/fmt/format.h
third-party/fmt/format-inl.h
+ third-party/fmt/src/format.cc
third-party/ghc/filesystem.hpp
third-party/half/half.hpp
)
@@ -587,7 +572,7 @@ target_include_directories(armnn PRIVATE src/backends)
target_include_directories(armnn PRIVATE src/profiling)
target_include_directories(armnn PRIVATE profiling/common/include)
-target_link_libraries(armnn armnnUtils)
+target_link_libraries(armnn armnnUtils pipeCommon)
target_link_libraries(armnn ${CMAKE_DL_LIBS})
if ("${CMAKE_SYSTEM_NAME}" STREQUAL Windows)
@@ -925,7 +910,7 @@ if(BUILD_UNIT_TESTS)
if(BUILD_TIMELINE_DECODER)
list(APPEND unittest_sources
src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp
- src/timelineDecoder/tests/TimelineTests.cpp
+ profiling/server/src/timelineDecoder/tests/TimelineTests.cpp
)
endif()
@@ -971,6 +956,7 @@ if(BUILD_UNIT_TESTS)
if(BUILD_TIMELINE_DECODER)
target_link_libraries(UnitTests timelineDecoder)
+ target_link_libraries(UnitTests jsonTimelineDecoder)
endif()
if(BUILD_TF_LITE_PARSER)
@@ -1045,6 +1031,8 @@ if(BUILD_BASE_PIPE_SERVER)
endif()
if(BUILD_TIMELINE_DECODER)
+ add_subdirectory(profiling/server/src/timelineDecoder)
+ add_subdirectory(profiling/common/src)
add_subdirectory(src/timelineDecoder)
endif()
diff --git a/cmake/GlobalConfig.cmake b/cmake/GlobalConfig.cmake
index 142e536912..e5a586631c 100644
--- a/cmake/GlobalConfig.cmake
+++ b/cmake/GlobalConfig.cmake
@@ -1,5 +1,5 @@
#
-# Copyright © 2020 Arm Ltd. All rights reserved.
+# Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
# Copyright 2020 NXP
# SPDX-License-Identifier: MIT
#
@@ -33,6 +33,8 @@ option(SHARED_BOOST "Use dynamic linking for boost libraries" OFF)
option(BUILD_BASE_PIPE_SERVER "Build the server to handle external profiling pipe traffic" ON)
option(BUILD_PYTHON_WHL "Build Python wheel package" OFF)
option(BUILD_PYTHON_SRC "Build Python source package" OFF)
+option(BUILD_STATIC_PIPE_LIBS "Build Static PIPE libraries" OFF)
+option(BUILD_PIPE_ONLY "Build the PIPE libraries only" OFF)
include(SelectLibraryConfigurations)
@@ -121,25 +123,32 @@ endif()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
-# Boost
-if(SHARED_BOOST)
+if (NOT BUILD_PIPE_ONLY)
+ # Boost
+ message(STATUS "Finding Boost")
+ if(SHARED_BOOST)
add_definitions(-DBOOST_ALL_DYN_LINK)
set(Boost_USE_STATIC_LIBS OFF)
-else()
+ else()
set(Boost_USE_STATIC_LIBS ON)
+ endif()
+ add_definitions("-DBOOST_ALL_NO_LIB") # Turn off auto-linking as we specify the libs manually
+ find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework filesystem system program_options)
+ include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
+ link_directories(${Boost_LIBRARY_DIRS})
endif()
-add_definitions("-DBOOST_ALL_NO_LIB") # Turn off auto-linking as we specify the libs manually
-find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework filesystem system program_options)
-include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
-link_directories(${Boost_LIBRARY_DIRS})
-# cxxopts (Alternative to boost::program_options)
-find_path(CXXOPTS_INCLUDE cxxopts/cxxopts.hpp PATHS third-party)
-include_directories(SYSTEM "${CXXOPTS_INCLUDE}")
+if (NOT BUILD_PIPE_ONLY)
+ # cxxopts (Alternative to boost::program_options)
+ find_path(CXXOPTS_INCLUDE cxxopts/cxxopts.hpp PATHS third-party)
+ include_directories(SYSTEM "${CXXOPTS_INCLUDE}")
+endif()
-# ghc (Alternative to boost::filesystem)
-find_path(GHC_INCLUDE ghc/filesystem.hpp PATHS third-party)
-include_directories(SYSTEM "${GHC_INCLUDE}")
+if (NOT BUILD_PIPE_ONLY)
+ # ghc (Alternative to boost::filesystem)
+ find_path(GHC_INCLUDE ghc/filesystem.hpp PATHS third-party)
+ include_directories(SYSTEM "${GHC_INCLUDE}")
+endif()
# pthread
find_package (Threads)
diff --git a/include/armnn/Conversion.hpp b/include/armnn/Conversion.hpp
index e2bccd0372..24c1d7c85a 100644
--- a/include/armnn/Conversion.hpp
+++ b/include/armnn/Conversion.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/include/armnn/Logging.hpp b/include/armnn/Logging.hpp
index 84152e543e..27971c56e4 100644
--- a/include/armnn/Logging.hpp
+++ b/include/armnn/Logging.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/include/armnn/profiling/ILocalPacketHandler.hpp b/include/armnn/profiling/ILocalPacketHandler.hpp
index 158c0eb852..af1b0f88b8 100644
--- a/include/armnn/profiling/ILocalPacketHandler.hpp
+++ b/include/armnn/profiling/ILocalPacketHandler.hpp
@@ -12,6 +12,15 @@
#include <memory>
#include <vector>
+// forward declare to prevent a circular dependency
+namespace arm
+{
+namespace pipe
+{
+ class Packet;
+} // namespace pipe
+} // namespace arm
+
namespace armnn
{
@@ -24,9 +33,6 @@ enum class TargetEndianness
LeWire
};
-// forward declare to prevent a circular dependency
-class Packet;
-
// the handlers need to be able to do two
// things to service the FileOnlyProfilingConnection
// and any other implementation of IProfilingConnection
@@ -39,7 +45,7 @@ public:
virtual void SetEndianess(const TargetEndianness& endianness) = 0;
- virtual void ReturnPacket(Packet& packet) = 0;
+ virtual void ReturnPacket(arm::pipe::Packet& packet) = 0;
virtual void Close() = 0;
};
@@ -56,7 +62,7 @@ public:
virtual std::vector<uint32_t> GetHeadersAccepted() = 0;
/// process the packet
- virtual void HandlePacket(const Packet& packet) = 0;
+ virtual void HandlePacket(const arm::pipe::Packet& packet) = 0;
/// Set a profiling connection on the handler. Only need to implement this
/// function if the handler will be writing data back to the profiled application.
diff --git a/include/armnn/utility/Assert.hpp b/include/armnn/utility/Assert.hpp
index 455775f9b7..3c336b36f5 100644
--- a/include/armnn/utility/Assert.hpp
+++ b/include/armnn/utility/Assert.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/include/armnn/utility/IgnoreUnused.hpp b/include/armnn/utility/IgnoreUnused.hpp
index 1f9bbe7a28..1534f774b9 100644
--- a/include/armnn/utility/IgnoreUnused.hpp
+++ b/include/armnn/utility/IgnoreUnused.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/include/armnn/utility/NumericCast.hpp b/include/armnn/utility/NumericCast.hpp
index 62c7d11543..af34013c30 100644
--- a/include/armnn/utility/NumericCast.hpp
+++ b/include/armnn/utility/NumericCast.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/profiling/CMakeLists.txt b/profiling/CMakeLists.txt
new file mode 100644
index 0000000000..f9ffd66433
--- /dev/null
+++ b/profiling/CMakeLists.txt
@@ -0,0 +1,36 @@
+#
+# Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+# SPDX-License-Identifier: MIT
+#
+cmake_minimum_required (VERSION 3.0.2) # 3.0.2 required for return() statement used in AddDllCopyCommands.cmake
+project(pipe)
+
+set(additional_cmake_files)
+list(APPEND additional_cmake_files
+ ../cmake/ArmnnVersion.cmake
+ ../cmake/Utils.cmake
+ ../cmake/GlobalConfig.cmake
+ ../cmake/AddDllCopyCommands.cmake)
+
+foreach(cmake_file ${additional_cmake_files})
+ include(${cmake_file})
+endforeach()
+
+# Include the additional cmake files in their own target so that they will appear nicely in IDEs
+add_custom_target(AdditionalCMakeFiles SOURCES ${additional_cmake_files})
+
+include(GNUInstallDirs)
+
+include_directories(SYSTEM common/include)
+include_directories(SYSTEM ${PROJECT_SOURCE_DIR})
+
+set(BUILD_UNIT_TESTS 0)
+
+if(BUILD_TIMELINE_DECODER)
+ add_subdirectory(server/src/timelineDecoder)
+ add_subdirectory(common/src)
+endif()
+
+if(BUILD_BASE_PIPE_SERVER)
+ add_subdirectory(server/src/basePipeServer)
+endif()
diff --git a/profiling/buildpipe.sh b/profiling/buildpipe.sh
new file mode 100755
index 0000000000..611b7b96e0
--- /dev/null
+++ b/profiling/buildpipe.sh
@@ -0,0 +1,91 @@
+#!/bin/bash
+#
+# Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+# SPDX-License-Identifier: MIT
+#
+
+SOURCE="${BASH_SOURCE[0]}"
+while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
+ TARGET="$(readlink "$SOURCE")"
+ if [[ $TARGET == /* ]]; then
+ # "SOURCE '$SOURCE' is an absolute symlink to '$TARGET'"
+ SOURCE="$TARGET"
+ else
+ DIR="$( dirname "$SOURCE" )"
+ # "SOURCE '$SOURCE' is a relative symlink to '$TARGET' (relative to '$DIR')"
+ SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
+ fi
+done
+RDIR="$( dirname "$SOURCE" )"
+DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
+
+CMD=$( basename $0 )
+
+usage() {
+ echo "Usage: $CMD [options]"
+ echo "Options: -t(type) <Debug or Release>"
+ echo " -c(lean) build"
+ echo " -s(tatic libraries) <1 or 0>"
+ echo " -w(indows) build"
+ exit 1
+}
+# defaults
+TYPE=Release
+CLEAN=0
+STATIC=0
+WINDOWS=0
+
+# Parse the command line
+while getopts "whct:s:" opt; do
+ case "$opt" in
+ h|\?) usage;;
+ t) TYPE=$OPTARG;;
+ c) CLEAN=1;;
+ s) STATIC=$OPTARG;;
+ w) WINDOWS=1;;
+ esac
+done
+shift $((OPTIND - 1))
+
+if [ $CLEAN == 1 ]; then
+ echo "removing ${DIR}/build"
+ rm -rf ${DIR}/build
+fi
+
+BUILD_DIR="build"
+[ -d build ] || mkdir build
+echo $WINDOWS
+if [ "$WINDOWS" -eq "1" ]; then
+ echo "doing windows"
+ cd $BUILD_DIR
+ [ -d windows ] || mkdir windows
+ BUILD_DIR=$BUILD_DIR/windows
+ cd $DIR
+fi
+# lower case TYPE in a posix compliant manner
+LC_TYPE=$(echo "$TYPE" | tr '[:upper:]' '[:lower:]')
+if [ ${LC_TYPE} == "debug" ]; then
+ DEBUGDIR=($DIR/$BUILD_DIR/debug)
+ [ -d $DEBUGDIR ] || (cd ${BUILD_DIR} && mkdir debug && cd ..)
+ BUILD_DIR=$DEBUGDIR
+else
+ RELEASEDIR=($DIR/$BUILD_DIR/release)
+ [ -d $RELEASEDIR ] || (cd ${BUILD_DIR} && mkdir release && cd ..)
+ BUILD_DIR=$RELEASEDIR
+fi
+
+echo "Build Directory: ${BUILD_DIR}"
+
+CMAKE=cmake
+CMARGS="-DCMAKE_BUILD_TYPE=$TYPE \
+ -DBUILD_STATIC_PIPE_LIBS=$STATIC \
+ -DBUILD_PIPE_ONLY=1"
+if [ "$WINDOWS" -eq "1" ]; then
+ CMARGS="$CMARGS \
+ -DCMAKE_TOOLCHAIN_FILE=${DIR}/toolchain-x86-ubuntu-mingw64.cmake"
+fi
+MAKE=make
+
+cd ${BUILD_DIR}
+pwd
+( eval $CMAKE $CMARGS $DIR && eval ${MAKE} $MAKEFLAGS )
diff --git a/profiling/common/include/Assert.hpp b/profiling/common/include/Assert.hpp
new file mode 100644
index 0000000000..c6e8bc49d4
--- /dev/null
+++ b/profiling/common/include/Assert.hpp
@@ -0,0 +1,24 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <cassert>
+
+namespace arm
+{
+
+namespace pipe
+{
+
+#ifndef NDEBUG
+# define ARM_PIPE_ASSERT(COND) assert(COND)
+# define ARM_PIPE_ASSERT_MSG(COND, MSG) assert((COND) && MSG)
+#else
+# define ARM_PIPE_ASSERT(COND)
+# define ARM_PIPE_ASSERT_MSG(COND, MSG)
+#endif
+} // namespace pipe
+} //namespace arm \ No newline at end of file
diff --git a/src/profiling/CommandHandlerFunctor.hpp b/profiling/common/include/CommandHandlerFunctor.hpp
index 885a2f34b5..9827aa05ba 100644
--- a/src/profiling/CommandHandlerFunctor.hpp
+++ b/profiling/common/include/CommandHandlerFunctor.hpp
@@ -1,20 +1,17 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include <Packet.hpp>
-
-#include <armnn/utility/IgnoreUnused.hpp>
-
#include <cstdint>
-namespace armnn
+namespace arm
{
-namespace profiling
+namespace pipe
{
class CommandHandlerFunctor
@@ -40,6 +37,6 @@ private:
uint32_t m_Version;
};
-} // namespace profiling
+} // namespace pipe
-} // namespace armnn
+} // namespace arm
diff --git a/src/profiling/CommandHandlerKey.hpp b/profiling/common/include/CommandHandlerKey.hpp
index 247f67925b..f45b5bef14 100644
--- a/src/profiling/CommandHandlerKey.hpp
+++ b/profiling/common/include/CommandHandlerKey.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -7,10 +7,10 @@
#include <cstdint>
-namespace armnn
+namespace arm
{
-namespace profiling
+namespace pipe
{
class CommandHandlerKey
@@ -36,6 +36,6 @@ private:
uint32_t m_Version;
};
-} // namespace profiling
+} // namespace pipe
-} // namespace armnn
+} // namespace arm
diff --git a/src/profiling/CommandHandlerRegistry.hpp b/profiling/common/include/CommandHandlerRegistry.hpp
index 43419deea4..5a5d879996 100644
--- a/src/profiling/CommandHandlerRegistry.hpp
+++ b/profiling/common/include/CommandHandlerRegistry.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -8,14 +8,13 @@
#include "CommandHandlerFunctor.hpp"
#include "CommandHandlerKey.hpp"
-#include <boost/functional/hash.hpp>
-
+#include <functional>
#include <unordered_map>
-namespace armnn
+namespace arm
{
-namespace profiling
+namespace pipe
{
struct CommandHandlerHash
@@ -23,8 +22,9 @@ struct CommandHandlerHash
std::size_t operator() (const CommandHandlerKey& commandHandlerKey) const
{
std::size_t seed = 0;
- boost::hash_combine(seed, commandHandlerKey.GetPacketId());
- boost::hash_combine(seed, commandHandlerKey.GetVersion());
+ std::hash<uint32_t> hasher;
+ seed ^= hasher(commandHandlerKey.GetPacketId()) + 0x9e3779b9 + (seed<<6) + (seed>>2);
+ seed ^= hasher(commandHandlerKey.GetVersion()) + 0x9e3779b9 + (seed<<6) + (seed>>2);
return seed;
}
};
@@ -44,6 +44,6 @@ private:
std::unordered_map<CommandHandlerKey, CommandHandlerFunctor*, CommandHandlerHash> registry;
};
-} // namespace profiling
+} // namespace pipe
-} // namespace armnn
+} // namespace arm
diff --git a/profiling/common/include/CommonProfilingUtils.hpp b/profiling/common/include/CommonProfilingUtils.hpp
new file mode 100644
index 0000000000..68fe6bb8ca
--- /dev/null
+++ b/profiling/common/include/CommonProfilingUtils.hpp
@@ -0,0 +1,38 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#pragma once
+
+#include <cstdint>
+#include <string>
+
+namespace arm
+{
+
+namespace pipe
+{
+void ReadBytes(const unsigned char* buffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[]);
+
+uint64_t ReadUint64(unsigned const char* buffer, unsigned int offset);
+
+uint32_t ReadUint32(unsigned const char* buffer, unsigned int offset);
+
+uint16_t ReadUint16(unsigned const char* buffer, unsigned int offset);
+
+uint8_t ReadUint8(unsigned const char* buffer, unsigned int offset);
+
+void WriteBytes(unsigned char* buffer, unsigned int offset, const void* value, unsigned int valueSize);
+
+void WriteUint64(unsigned char* buffer, unsigned int offset, uint64_t value);
+
+void WriteUint32(unsigned char* buffer, unsigned int offset, uint32_t value);
+
+void WriteUint16(unsigned char* buffer, unsigned int offset, uint16_t value);
+
+void WriteUint8(unsigned char* buffer, unsigned int offset, uint8_t value);
+
+std::string CentreAlignFormatting(const std::string& stringToPass, const int spacingWidth);
+
+} // namespace pipe
+} // namespace arm \ No newline at end of file
diff --git a/profiling/common/include/Constants.hpp b/profiling/common/include/Constants.hpp
index 52e0e487a8..01bfe795c2 100644
--- a/profiling/common/include/Constants.hpp
+++ b/profiling/common/include/Constants.hpp
@@ -1,10 +1,14 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-namespace armnnProfiling
+namespace arm
+{
+
+namespace pipe
{
static const unsigned int PIPE_MAGIC = 0x45495434;
-} \ No newline at end of file
+} // namespace pipe
+} // namespace arm \ No newline at end of file
diff --git a/profiling/common/include/Conversion.hpp b/profiling/common/include/Conversion.hpp
new file mode 100644
index 0000000000..0a3eb0c0d6
--- /dev/null
+++ b/profiling/common/include/Conversion.hpp
@@ -0,0 +1,43 @@
+//
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#if __GNUC__
+# define ARM_PIPE_NO_CONVERSION_WARN_BEGIN \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wconversion\"") \
+ _Pragma("GCC diagnostic ignored \"-Wsign-conversion\"")
+
+# define ARM_PIPE_NO_CONVERSION_WARN_END \
+ _Pragma("GCC diagnostic pop")
+
+#elif __clang__
+# define ARM_PIPE_NO_CONVERSION_WARN_BEGIN \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Wconversion\"") \
+ _Pragma("clang diagnostic ignored \"-Wsign-conversion\"")
+
+# define ARM_PIPE_NO_CONVERSION_WARN_END \
+ _Pragma("clang diagnostic pop")
+
+#elif defined (_MSC_VER)
+# define ARM_PIPE_NO_CONVERSION_WARN_BEGIN \
+ __pragma(warning( push )) \
+ __pragma(warning(disable : 4101)) \
+ __pragma(warning(disable : 4267))
+
+# define ARM_PIPE_NO_CONVERSION_WARN_END \
+ __pragma(warning( pop ))
+
+#else
+# define ARM_PIPE_NO_CONVERSION_WARN_BEGIN
+# define ARM_PIPE_NO_CONVERSION_WARN_END
+#endif
+
+#define ARM_PIPE_SUPRESS_CONVERSION_WARNING(func) \
+ARM_PIPE_NO_CONVERSION_WARN_BEGIN \
+func; \
+ARM_PIPE_NO_CONVERSION_WARN_END
diff --git a/src/profiling/EncodeVersion.hpp b/profiling/common/include/EncodeVersion.hpp
index f66f7278a5..9257b22cfc 100644
--- a/src/profiling/EncodeVersion.hpp
+++ b/profiling/common/include/EncodeVersion.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
@@ -9,10 +9,10 @@
#include <ostream>
#include <sstream>
-namespace armnn
+namespace arm
{
-namespace profiling
+namespace pipe
{
constexpr inline uint32_t EncodeVersion(uint32_t major, uint32_t minor, uint32_t patch)
@@ -78,6 +78,6 @@ inline std::ostream& operator<<(std::ostream& os, const Version& version)
return os;
}
-} // namespace profiling
+} // namespace pipe
-} // namespace armnn
+} // namespace arm
diff --git a/profiling/common/include/IgnoreUnused.hpp b/profiling/common/include/IgnoreUnused.hpp
new file mode 100644
index 0000000000..fad40d33d4
--- /dev/null
+++ b/profiling/common/include/IgnoreUnused.hpp
@@ -0,0 +1,18 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+namespace arm
+{
+
+namespace pipe
+{
+// Utility function to selectively silence unused variable compiler warnings
+
+template<typename ... Ts>
+inline void IgnoreUnused(Ts&&...){}
+} //namespace pipe
+} //namespace arm \ No newline at end of file
diff --git a/profiling/common/include/Logging.hpp b/profiling/common/include/Logging.hpp
new file mode 100644
index 0000000000..a31c2aaa7b
--- /dev/null
+++ b/profiling/common/include/Logging.hpp
@@ -0,0 +1,182 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <iostream>
+#include <memory>
+#include <sstream>
+#include <vector>
+
+namespace arm
+{
+
+namespace pipe
+{
+
+enum class LogSeverity
+{
+ Trace,
+ Debug,
+ Info,
+ Warning,
+ Error,
+ Fatal
+};
+
+inline std::string LevelToString(LogSeverity level)
+{
+ switch(level)
+ {
+ case LogSeverity::Trace:
+ return "Trace";
+ case LogSeverity::Debug:
+ return "Debug";
+ case LogSeverity::Info:
+ return "Info";
+ case LogSeverity::Warning:
+ return "Warning";
+ case LogSeverity::Error:
+ return "Error";
+ case LogSeverity::Fatal:
+ return "Fatal";
+ default:
+ return "Log";
+ }
+}
+
+class LogSink
+{
+public:
+ virtual ~LogSink(){};
+
+ virtual void Consume(const std::string&) = 0;
+private:
+
+};
+
+class StandardOutputSink : public LogSink
+{
+public:
+ void Consume(const std::string& s) override
+ {
+ std::cout << s << std::endl;
+ }
+};
+
+struct ScopedRecord
+{
+ ScopedRecord(const std::vector<std::shared_ptr<LogSink>>& sinks, LogSeverity level, bool enabled)
+ : m_LogSinks(sinks)
+ , m_Enabled(enabled)
+ {
+ if (enabled)
+ {
+ m_Os << LevelToString(level) << ": ";
+ }
+ }
+
+ ~ScopedRecord()
+ {
+ if (m_Enabled)
+ {
+ for (auto sink : m_LogSinks)
+ {
+ if (sink)
+ {
+ sink->Consume(m_Os.str());
+ }
+ }
+ }
+ }
+
+ ScopedRecord(const ScopedRecord&) = delete;
+ ScopedRecord& operator=(const ScopedRecord&) = delete;
+ ScopedRecord& operator=(ScopedRecord&&) = delete;
+
+ ScopedRecord(ScopedRecord&& other) = default;
+
+ template<typename Streamable>
+ ScopedRecord& operator<<(const Streamable& s)
+ {
+ if (m_Enabled)
+ {
+ m_Os << s;
+ }
+ return (*this);
+ }
+
+private:
+ const std::vector<std::shared_ptr<LogSink>>& m_LogSinks;
+ std::ostringstream m_Os;
+ bool m_Enabled;
+};
+
+template<LogSeverity Level>
+class SimpleLogger
+{
+public:
+ SimpleLogger()
+ : m_Sinks{std::make_shared<StandardOutputSink>()}
+ , m_Enable(true)
+ {
+ }
+
+ static SimpleLogger& Get()
+ {
+ static SimpleLogger<Level> logger;
+ return logger;
+ }
+
+ void Enable(bool enable = true)
+ {
+ m_Enable = enable;
+ }
+
+ ScopedRecord StartNewRecord()
+ {
+ ScopedRecord record(m_Sinks, Level, m_Enable);
+ return record;
+ }
+
+ void RemoveAllSinks()
+ {
+ m_Sinks.clear();
+ }
+
+ void AddSink(std::shared_ptr<LogSink> sink)
+ {
+ m_Sinks.push_back(sink);
+ }
+private:
+ std::vector<std::shared_ptr<LogSink>> m_Sinks;
+ bool m_Enable;
+};
+
+void SetLogFilter(LogSeverity level);
+
+void SetAllLoggingSinks(bool standardOut, bool debugOut, bool coloured);
+
+enum class BoostLogSeverityMapping
+{
+ trace,
+ debug,
+ info,
+ warning,
+ error,
+ fatal
+};
+
+constexpr LogSeverity ConvertLogSeverity(BoostLogSeverityMapping severity)
+{
+ return static_cast<LogSeverity>(severity);
+}
+
+
+#define ARM_PIPE_LOG(severity) \
+ arm::pipe::SimpleLogger<ConvertLogSeverity(arm::pipe::BoostLogSeverityMapping::severity)>::Get().StartNewRecord()
+
+} // namespace pipe
+} // namespace arm
diff --git a/profiling/common/include/NetworkSockets.hpp b/profiling/common/include/NetworkSockets.hpp
index 05a45ae90b..29575cdcd6 100644
--- a/profiling/common/include/NetworkSockets.hpp
+++ b/profiling/common/include/NetworkSockets.hpp
@@ -19,11 +19,14 @@
#include <WindowsWrapper.hpp>
#include <winsock2.h>
#include <afunix.h>
+#elif defined(__MINGW32__)
+#include <WindowsWrapper.hpp>
+#include <winsock2.h>
#endif
-namespace armnnUtils
+namespace arm
{
-namespace Sockets
+namespace pipe
{
#if defined(__unix__)
@@ -45,6 +48,14 @@ using nfds_t = int;
using socklen_t = int;
#define SOCK_CLOEXEC 0
+#elif defined(__MINGW32__)
+
+using Socket = SOCKET;
+using PollFd = WSAPOLLFD;
+using nfds_t = int;
+using socklen_t = int;
+#define SOCK_CLOEXEC 0
+
#endif
/// Performs any required one-time setup.
@@ -64,5 +75,5 @@ int Poll(PollFd* fds, nfds_t numFds, int timeout);
Socket Accept(Socket s, sockaddr* addr, socklen_t* addrlen, int flags);
-}
-}
+} // namespace arm
+} // namespace pipe
diff --git a/profiling/common/include/NumericCast.hpp b/profiling/common/include/NumericCast.hpp
new file mode 100644
index 0000000000..069f9514fe
--- /dev/null
+++ b/profiling/common/include/NumericCast.hpp
@@ -0,0 +1,128 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "Assert.hpp"
+
+#include <type_traits>
+#include <limits>
+
+namespace arm
+{
+
+namespace pipe
+{
+
+#if !defined(NDEBUG) || defined(ARM_PIPE_NUMERIC_CAST_TESTABLE)
+#define ENABLE_NUMERIC_CAST_CHECKS 1
+#else
+#define ENABLE_NUMERIC_CAST_CHECKS 0
+#endif
+
+#if defined(ARM_PIPE_NUMERIC_CAST_TESTABLE)
+# define ARM_PIPE_NUMERIC_CAST_CHECK(cond, msg) ConditionalThrow<std::bad_cast>(cond)
+#else
+# define ARM_PIPE_NUMERIC_CAST_CHECK(cond, msg) ARM_PIPE_ASSERT_MSG(cond, msg)
+#endif
+
+template<typename Dest, typename Source>
+typename std::enable_if_t<
+ std::is_unsigned<Source>::value &&
+ std::is_unsigned<Dest>::value
+ , Dest>
+numeric_cast(Source source)
+{
+#if ENABLE_NUMERIC_CAST_CHECKS
+ if (source > std::numeric_limits<Dest>::max())
+ {
+ ARM_PIPE_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting unsigned type to "
+ "narrower unsigned type. Overflow detected.");
+ }
+#endif // ENABLE_NUMERIC_CAST_CHECKS
+
+ return static_cast<Dest>(source);
+}
+
+template<typename Dest, typename Source>
+typename std::enable_if_t<
+ std::is_signed<Source>::value &&
+ std::is_signed<Dest>::value
+ , Dest>
+numeric_cast(Source source)
+{
+ static_assert(!std::is_floating_point<Source>::value && !std::is_floating_point<Dest>::value,
+ "numeric_cast doesn't cast float.");
+
+#if ENABLE_NUMERIC_CAST_CHECKS
+ if (source > std::numeric_limits<Dest>::max())
+ {
+ ARM_PIPE_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting signed type to narrower signed type. "
+ "Overflow detected.");
+ }
+
+ if (source < std::numeric_limits<Dest>::lowest())
+ {
+ ARM_PIPE_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting signed type to narrower signed type. "
+ "Underflow detected.");
+ }
+#endif // ENABLE_NUMERIC_CAST_CHECKS
+
+ return static_cast<Dest>(source);
+}
+
+// numeric cast from unsigned to signed checked for narrowing overflows
+template<typename Dest, typename Source>
+typename std::enable_if_t<
+ std::is_signed<Dest>::value &&
+ std::is_unsigned<Source>::value
+ , Dest>
+numeric_cast(Source sValue)
+{
+ static_assert(!std::is_floating_point<Dest>::value, "numeric_cast doesn't cast to float.");
+
+#if ENABLE_NUMERIC_CAST_CHECKS
+ if (sValue > static_cast< typename std::make_unsigned<Dest>::type >(std::numeric_limits<Dest>::max()))
+ {
+ ARM_PIPE_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting unsigned type to signed type. "
+ "Overflow detected.");
+ }
+#endif // ENABLE_NUMERIC_CAST_CHECKS
+
+ return static_cast<Dest>(sValue);
+}
+
+// numeric cast from signed to unsigned checked for underflows and narrowing overflows
+template<typename Dest, typename Source>
+typename std::enable_if_t<
+ std::is_unsigned<Dest>::value &&
+ std::is_signed<Source>::value
+ , Dest>
+numeric_cast(Source sValue)
+{
+ static_assert(!std::is_floating_point<Source>::value && !std::is_floating_point<Dest>::value,
+ "numeric_cast doesn't cast floats.");
+
+#if ENABLE_NUMERIC_CAST_CHECKS
+ if (sValue < 0)
+ {
+ ARM_PIPE_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting negative value to unsigned type. "
+ "Underflow detected.");
+ }
+
+ if (static_cast< typename std::make_unsigned<Source>::type >(sValue) > std::numeric_limits<Dest>::max())
+ {
+ ARM_PIPE_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting signed type to unsigned type. "
+ "Overflow detected.");
+ }
+
+#endif // ENABLE_NUMERIC_CAST_CHECKS
+ return static_cast<Dest>(sValue);
+}
+
+#undef ENABLE_NUMERIC_CAST_CHECKS
+
+} // namespace pipe
+} // namespace arm
diff --git a/profiling/common/include/Packet.hpp b/profiling/common/include/Packet.hpp
index 23c3124bad..d8fa2709e2 100644
--- a/profiling/common/include/Packet.hpp
+++ b/profiling/common/include/Packet.hpp
@@ -1,18 +1,18 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include <armnn/Exceptions.hpp>
+#include "ProfilingException.hpp"
#include <memory>
-namespace armnn
+namespace arm
{
-namespace profiling
+namespace pipe
{
class Packet
@@ -45,7 +45,7 @@ public:
if (length == 0 && m_Data != nullptr)
{
- throw armnn::InvalidArgumentException("Data should be null when length is zero");
+ throw arm::pipe::InvalidArgumentException("Data should be null when length is zero");
}
}
@@ -86,6 +86,6 @@ private:
std::unique_ptr<unsigned char[]> m_Data;
};
-} // namespace profiling
+} // namespace pipe
-} // namespace armnn
+} // namespace arm
diff --git a/src/profiling/PacketVersionResolver.hpp b/profiling/common/include/PacketVersionResolver.hpp
index 3112f5eac0..0ec7d2aca4 100644
--- a/src/profiling/PacketVersionResolver.hpp
+++ b/profiling/common/include/PacketVersionResolver.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -7,10 +7,10 @@
#include "EncodeVersion.hpp"
-namespace armnn
+namespace arm
{
-namespace profiling
+namespace pipe
{
class PacketKey final
@@ -45,6 +45,6 @@ public:
Version ResolvePacketVersion(uint32_t familyId, uint32_t packetId) const;
};
-} // namespace profiling
+} // namespace pipe
-} // namespace armnn
+} // namespace arm
diff --git a/profiling/common/include/ProfilingException.hpp b/profiling/common/include/ProfilingException.hpp
index 532c2d49f7..abdc0dc025 100644
--- a/profiling/common/include/ProfilingException.hpp
+++ b/profiling/common/include/ProfilingException.hpp
@@ -1,29 +1,82 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include <stdexcept>
#include <string>
+#include <sstream>
-namespace armnnProfiling
+namespace arm
{
+namespace pipe
+{
+
+struct Location
+{
+ const char* m_Function;
+ const char* m_File;
+ unsigned int m_Line;
+
+ Location(const char* func,
+ const char* file,
+ unsigned int line)
+ : m_Function{func}
+ , m_File{file}
+ , m_Line{line}
+ {
+ }
+
+ std::string AsString() const
+ {
+ std::stringstream ss;
+ ss << " at function " << m_Function
+ << " [" << m_File << ':' << m_Line << "]";
+ return ss.str();
+ }
+
+ std::string FileLine() const
+ {
+ std::stringstream ss;
+ ss << " [" << m_File << ':' << m_Line << "]";
+ return ss.str();
+ }
+};
+
/// General Exception class for Profiling code
class ProfilingException : public std::exception
{
public:
explicit ProfilingException(const std::string& message) : m_Message(message) {};
+ explicit ProfilingException(const std::string& message,
+ const Location& location) : m_Message(message + location.AsString()) {};
+
/// @return - Error message of ProfilingException
- virtual const char* what() const noexcept override
+ virtual const char *what() const noexcept override
{
- return m_Message.c_str();
+ return m_Message.c_str();
}
private:
std::string m_Message;
};
-} // namespace armnnProfiling
+class TimeoutException : public ProfilingException
+{
+public:
+ using ProfilingException::ProfilingException;
+};
+
+class InvalidArgumentException : public ProfilingException
+{
+public:
+ using ProfilingException::ProfilingException;
+};
+
+} // namespace pipe
+} // namespace arm
+
+#define LOCATION() arm::pipe::Location(__func__, __FILE__, __LINE__)
diff --git a/profiling/common/include/SocketConnectionException.hpp b/profiling/common/include/SocketConnectionException.hpp
index d18dcc37e4..42b8d9d67e 100644
--- a/profiling/common/include/SocketConnectionException.hpp
+++ b/profiling/common/include/SocketConnectionException.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
@@ -10,30 +10,31 @@
#include "NetworkSockets.hpp"
-namespace armnnProfiling
+namespace arm
+{
+
+namespace pipe
{
/// Socket Connection Exception for profiling
class SocketConnectionException : public std::exception
{
public:
- explicit SocketConnectionException(const std::string& message, armnnUtils::Sockets::Socket socket)
- : m_Message(message), m_Socket(socket), m_ErrNo(-1)
- {};
+ explicit SocketConnectionException(const std::string &message, arm::pipe::Socket socket)
+ : m_Message(message), m_Socket(socket), m_ErrNo(-1) {};
- explicit SocketConnectionException(const std::string& message, armnnUtils::Sockets::Socket socket, int errNo)
- : m_Message(message), m_Socket(socket), m_ErrNo(errNo)
- {};
+ explicit SocketConnectionException(const std::string &message, arm::pipe::Socket socket, int errNo)
+ : m_Message(message), m_Socket(socket), m_ErrNo(errNo) {};
/// @return - Error message of SocketProfilingConnection
- virtual const char* what() const noexcept override
+ virtual const char *what() const noexcept override
{
return m_Message.c_str();
}
/// @return - Socket File Descriptor of SocketProfilingConnection
/// or '-1', an invalid file descriptor
- armnnUtils::Sockets::Socket GetSocketFd() const noexcept
+ arm::pipe::Socket GetSocketFd() const noexcept
{
return m_Socket;
}
@@ -46,8 +47,8 @@ public:
private:
std::string m_Message;
- armnnUtils::Sockets::Socket m_Socket;
+ arm::pipe::Socket m_Socket;
int m_ErrNo;
};
-
-} // namespace armnnProfiling
+} // namespace pipe
+} // namespace arm
diff --git a/profiling/common/include/SwTrace.hpp b/profiling/common/include/SwTrace.hpp
new file mode 100644
index 0000000000..5abc59b1a8
--- /dev/null
+++ b/profiling/common/include/SwTrace.hpp
@@ -0,0 +1,139 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "NumericCast.hpp"
+
+#include <algorithm>
+#include <cstring>
+#include <string>
+#include <vector>
+
+namespace arm
+{
+
+namespace pipe
+{
+
+struct SwTraceHeader
+{
+ uint8_t m_StreamVersion;
+ uint8_t m_PointerBytes;
+ uint8_t m_ThreadIdBytes;
+};
+
+struct SwTraceMessage
+{
+ uint32_t m_Id;
+ std::string m_Name;
+ std::string m_UiName;
+ std::vector<char> m_ArgTypes;
+ std::vector<std::string> m_ArgNames;
+};
+
+struct SwTraceCharPolicy
+{
+ static bool IsValidChar(unsigned char c)
+ {
+ // Check that the given character has ASCII 7-bit encoding
+ return c < 128;
+ }
+};
+
+struct SwTraceNameCharPolicy
+{
+ static bool IsValidChar(unsigned char c)
+ {
+ // Check that the given character has ASCII 7-bit encoding, alpha-numeric and underscore only
+ return c < 128 && (std::isalnum(c) || c == '_');
+ }
+};
+
+struct SwTraceTypeCharPolicy
+{
+ static bool IsValidChar(unsigned char c)
+ {
+ // Check that the given character is among the allowed ones
+ switch (c)
+ {
+ case '@':
+ case 't':
+ case 'i':
+ case 'I':
+ case 'l':
+ case 'L':
+ case 'F':
+ case 'p':
+ case 's':
+ return true; // Valid char
+ default:
+ return false; // Invalid char
+ }
+ }
+};
+
+template <typename SwTracePolicy>
+bool IsValidSwTraceString(const std::string& s)
+{
+ // Check that all the characters in the given string conform to the given policy
+ return std::all_of(s.begin(), s.end(), [](unsigned char c) { return SwTracePolicy::IsValidChar(c); });
+}
+
+template <typename SwTracePolicy>
+bool StringToSwTraceString(const std::string& s, std::vector<uint32_t>& outputBuffer)
+{
+ // Converts the given string to an SWTrace "string" (i.e. a string of "chars"), and writes it into
+ // the given buffer including the null-terminator. It also pads it to the next uint32_t if necessary
+
+ // Clear the output buffer
+ outputBuffer.clear();
+
+ // Check that the given string is a valid SWTrace "string" (i.e. a string of "chars")
+ if (!IsValidSwTraceString<SwTracePolicy>(s))
+ {
+ return false;
+ }
+
+ // Prepare the output buffer
+ size_t s_size = s.size() + 1; // The size of the string (in chars) plus the null-terminator
+ size_t uint32_t_size = sizeof(uint32_t);
+ // Output buffer size = StringLength (32 bit) + amount of complete 32bit words that fit into the string
+ // + an additional 32bit word if there are remaining chars to complete the string
+ // (The rest of the 32bit word is then filled with the NULL terminator)
+ size_t outBufferSize = 1 + (s_size / uint32_t_size) + (s_size % uint32_t_size != 0 ? 1 : 0);
+ outputBuffer.resize(outBufferSize, '\0');
+
+ // Write the SWTrace string to the output buffer
+ outputBuffer[0] = numeric_cast<uint32_t>(s_size);
+ std::memcpy(outputBuffer.data() + 1, s.data(), s_size);
+
+ return true;
+}
+
+template <typename SwTracePolicy,
+ typename SwTraceBuffer = std::vector<uint32_t>>
+bool ConvertDirectoryComponent(const std::string& directoryComponent, SwTraceBuffer& swTraceBuffer)
+{
+ // Convert the directory component using the given policy
+ SwTraceBuffer tempSwTraceBuffer;
+ bool result = StringToSwTraceString<SwTracePolicy>(directoryComponent, tempSwTraceBuffer);
+ if (!result)
+ {
+ return false;
+ }
+
+ swTraceBuffer.insert(swTraceBuffer.end(), tempSwTraceBuffer.begin(), tempSwTraceBuffer.end());
+
+ return true;
+}
+
+uint32_t CalculateSizeOfPaddedSwString(const std::string& str);
+
+SwTraceMessage ReadSwTraceMessage(const unsigned char*, unsigned int&, const unsigned int& packetLength);
+
+} // namespace pipe
+
+} // namespace arm
diff --git a/src/armnnUtils/WindowsWrapper.hpp b/profiling/common/include/WindowsWrapper.hpp
index 7f02cb1a16..d75fdc857a 100644
--- a/src/armnnUtils/WindowsWrapper.hpp
+++ b/profiling/common/include/WindowsWrapper.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -15,3 +15,16 @@
#undef CreateEvent // ITimelineDecoder.hpp
#endif
+
+#if defined(__MINGW32__)
+
+#define NOMINMAX // Prevent definition of min/max macros that interfere with std::min/max
+#define WIN32_LEAN_AND_MEAN
+#define WINVER 0x0A00
+#define _WIN32_WINNT 0x0A00
+#include <windows.h>
+// Windows.h defines some names that we don't need and interfere with some of our definition
+#undef TIME_MS // Instrument.hpp
+#undef CreateEvent // ITimelineDecoder.hpp
+
+#endif
diff --git a/profiling/common/src/CMakeLists.txt b/profiling/common/src/CMakeLists.txt
new file mode 100644
index 0000000000..9505fb8869
--- /dev/null
+++ b/profiling/common/src/CMakeLists.txt
@@ -0,0 +1,30 @@
+#
+# Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+# SPDX-License-Identifier: MIT
+#
+
+if(BUILD_TIMELINE_DECODER)
+ set(pipeCommon_sources)
+ list(APPEND pipeCommon_sources
+ CommandHandlerFunctor.cpp
+ CommandHandlerKey.cpp
+ CommandHandlerRegistry.cpp
+ CommonProfilingUtils.cpp
+ NetworkSockets.cpp
+ PacketVersionResolver.cpp
+ SwTrace.cpp)
+
+ include_directories(${PROJECT_SOURCE_DIR}/profiling/common/include)
+ include_directories(${PROJECT_SOURCE_DIR}/common/include)
+
+ if(BUILD_UNIT_TESTS)
+ include_directories(${PROJECT_SOURCE_DIR}/src/profiling
+ ${PROJECT_SOURCE_DIR}/src/armnnUtils)
+ target_include_directories(UnitTests PRIVATE ${PROJECT_SOURCE_DIR}/profiling/common/include)
+ endif()
+
+ # will only build a static version of this common code
+ # to simplify the build. No extra .so file to deploy to boards etc.
+ add_library_ex(pipeCommon STATIC ${pipeCommon_sources})
+
+endif()
diff --git a/src/profiling/CommandHandlerFunctor.cpp b/profiling/common/src/CommandHandlerFunctor.cpp
index 7f836cba2f..ea24cfb34e 100644
--- a/src/profiling/CommandHandlerFunctor.cpp
+++ b/profiling/common/src/CommandHandlerFunctor.cpp
@@ -1,14 +1,14 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "CommandHandlerFunctor.hpp"
-namespace armnn
+namespace arm
{
-namespace profiling
+namespace pipe
{
uint32_t CommandHandlerFunctor::GetFamilyId() const
@@ -26,6 +26,6 @@ uint32_t CommandHandlerFunctor::GetVersion() const
return m_Version;
}
-} // namespace profiling
+} // namespace pipe
-} // namespace armnn
+} // namespace arm
diff --git a/src/profiling/CommandHandlerKey.cpp b/profiling/common/src/CommandHandlerKey.cpp
index 4d7e11a7e0..98e4567348 100644
--- a/src/profiling/CommandHandlerKey.cpp
+++ b/profiling/common/src/CommandHandlerKey.cpp
@@ -1,14 +1,14 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "CommandHandlerKey.hpp"
-namespace armnn
+namespace arm
{
-namespace profiling
+namespace pipe
{
uint32_t CommandHandlerKey::GetFamilyId() const
@@ -72,6 +72,6 @@ bool CommandHandlerKey::operator!=(const CommandHandlerKey& rhs) const
return !(*this == rhs);
}
-} // namespace profiling
+} // namespace pipe
-} // namespace armnn
+} // namespace arm
diff --git a/src/profiling/CommandHandlerRegistry.cpp b/profiling/common/src/CommandHandlerRegistry.cpp
index c2fef7a597..324737eda5 100644
--- a/src/profiling/CommandHandlerRegistry.cpp
+++ b/profiling/common/src/CommandHandlerRegistry.cpp
@@ -1,18 +1,18 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
-#include "CommandHandlerRegistry.hpp"
-#include <armnn/utility/Assert.hpp>
+#include <common/include/Assert.hpp>
+#include <common/include/CommandHandlerRegistry.hpp>
-#include <boost/format.hpp>
+#include <sstream>
-namespace armnn
+namespace arm
{
-namespace profiling
+namespace pipe
{
void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor,
@@ -20,7 +20,7 @@ void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor,
uint32_t packetId,
uint32_t version)
{
- ARMNN_ASSERT_MSG(functor, "Provided functor should not be a nullptr");
+ ARM_PIPE_ASSERT_MSG(functor, "Provided functor should not be a nullptr");
CommandHandlerKey key(familyId, packetId, version);
registry[key] = functor;
@@ -28,7 +28,7 @@ void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor,
void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor)
{
- ARMNN_ASSERT_MSG(functor, "Provided functor should not be a nullptr");
+ ARM_PIPE_ASSERT_MSG(functor, "Provided functor should not be a nullptr");
RegisterFunctor(functor, functor->GetFamilyId(), functor->GetPacketId(), functor->GetVersion());
}
@@ -40,24 +40,22 @@ CommandHandlerFunctor* CommandHandlerRegistry::GetFunctor(uint32_t familyId,uint
// Check that the requested key exists
if (registry.find(key) == registry.end())
{
- throw armnn::InvalidArgumentException(
- boost::str(boost::format("Functor with requested PacketId=%1% and Version=%2% does not exist")
- % packetId
- % version));
+ std::stringstream ss;
+ ss << "Functor with requested PacketId=" << packetId << " and Version=" << version << " does not exist";
+ throw ProfilingException(ss.str());
}
CommandHandlerFunctor* commandHandlerFunctor = registry.at(key);
if (commandHandlerFunctor == nullptr)
{
- throw RuntimeException(
- boost::str(boost::format("Invalid functor registered for PacketId=%1% and Version=%2%")
- % packetId
- % version));
+ std::stringstream ss;
+ ss << "Invalid functor registered for PacketId=" << packetId << " and Version=" << version;
+ throw ProfilingException(ss.str());
}
return commandHandlerFunctor;
}
-} // namespace profiling
+} // namespace pipe
-} // namespace armnn
+} // namespace arm
diff --git a/profiling/common/src/CommonProfilingUtils.cpp b/profiling/common/src/CommonProfilingUtils.cpp
new file mode 100644
index 0000000000..fe98e0aaa9
--- /dev/null
+++ b/profiling/common/src/CommonProfilingUtils.cpp
@@ -0,0 +1,145 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include <common/include/Assert.hpp>
+#include <common/include/CommonProfilingUtils.hpp>
+
+#include <sstream>
+
+namespace arm
+{
+
+namespace pipe
+{
+void ReadBytes(const unsigned char* buffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
+{
+ ARM_PIPE_ASSERT(buffer);
+ ARM_PIPE_ASSERT(outValue);
+
+ for (unsigned int i = 0; i < valueSize; i++, offset++)
+ {
+ outValue[i] = static_cast<uint8_t>(buffer[offset]);
+ }
+}
+
+uint64_t ReadUint64(const unsigned char* buffer, unsigned int offset)
+{
+ ARM_PIPE_ASSERT(buffer);
+
+ uint64_t value = 0;
+ value = static_cast<uint64_t>(buffer[offset]);
+ value |= static_cast<uint64_t>(buffer[offset + 1]) << 8;
+ value |= static_cast<uint64_t>(buffer[offset + 2]) << 16;
+ value |= static_cast<uint64_t>(buffer[offset + 3]) << 24;
+ value |= static_cast<uint64_t>(buffer[offset + 4]) << 32;
+ value |= static_cast<uint64_t>(buffer[offset + 5]) << 40;
+ value |= static_cast<uint64_t>(buffer[offset + 6]) << 48;
+ value |= static_cast<uint64_t>(buffer[offset + 7]) << 56;
+
+ return value;
+}
+
+uint32_t ReadUint32(const unsigned char* buffer, unsigned int offset)
+{
+ ARM_PIPE_ASSERT(buffer);
+
+ uint32_t value = 0;
+ value = static_cast<uint32_t>(buffer[offset]);
+ value |= static_cast<uint32_t>(buffer[offset + 1]) << 8;
+ value |= static_cast<uint32_t>(buffer[offset + 2]) << 16;
+ value |= static_cast<uint32_t>(buffer[offset + 3]) << 24;
+ return value;
+}
+
+uint16_t ReadUint16(const unsigned char* buffer, unsigned int offset)
+{
+ ARM_PIPE_ASSERT(buffer);
+
+ uint32_t value = 0;
+ value = static_cast<uint32_t>(buffer[offset]);
+ value |= static_cast<uint32_t>(buffer[offset + 1]) << 8;
+ return static_cast<uint16_t>(value);
+}
+
+uint8_t ReadUint8(const unsigned char* buffer, unsigned int offset)
+{
+ ARM_PIPE_ASSERT(buffer);
+
+ return buffer[offset];
+}
+
+void WriteBytes(unsigned char* buffer, unsigned int offset, const void* value, unsigned int valueSize)
+{
+ ARM_PIPE_ASSERT(buffer);
+ ARM_PIPE_ASSERT(value);
+
+ for (unsigned int i = 0; i < valueSize; i++, offset++)
+ {
+ buffer[offset] = *(reinterpret_cast<const unsigned char*>(value) + i);
+ }
+}
+
+void WriteUint64(unsigned char* buffer, unsigned int offset, uint64_t value)
+{
+ ARM_PIPE_ASSERT(buffer);
+
+ buffer[offset] = static_cast<unsigned char>(value & 0xFF);
+ buffer[offset + 1] = static_cast<unsigned char>((value >> 8) & 0xFF);
+ buffer[offset + 2] = static_cast<unsigned char>((value >> 16) & 0xFF);
+ buffer[offset + 3] = static_cast<unsigned char>((value >> 24) & 0xFF);
+ buffer[offset + 4] = static_cast<unsigned char>((value >> 32) & 0xFF);
+ buffer[offset + 5] = static_cast<unsigned char>((value >> 40) & 0xFF);
+ buffer[offset + 6] = static_cast<unsigned char>((value >> 48) & 0xFF);
+ buffer[offset + 7] = static_cast<unsigned char>((value >> 56) & 0xFF);
+}
+
+void WriteUint32(unsigned char* buffer, unsigned int offset, uint32_t value)
+{
+ ARM_PIPE_ASSERT(buffer);
+
+ buffer[offset] = static_cast<unsigned char>(value & 0xFF);
+ buffer[offset + 1] = static_cast<unsigned char>((value >> 8) & 0xFF);
+ buffer[offset + 2] = static_cast<unsigned char>((value >> 16) & 0xFF);
+ buffer[offset + 3] = static_cast<unsigned char>((value >> 24) & 0xFF);
+}
+
+void WriteUint16(unsigned char* buffer, unsigned int offset, uint16_t value)
+{
+ ARM_PIPE_ASSERT(buffer);
+
+ buffer[offset] = static_cast<unsigned char>(value & 0xFF);
+ buffer[offset + 1] = static_cast<unsigned char>((value >> 8) & 0xFF);
+}
+
+void WriteUint8(unsigned char* buffer, unsigned int offset, uint8_t value)
+{
+ ARM_PIPE_ASSERT(buffer);
+
+ buffer[offset] = static_cast<unsigned char>(value);
+}
+
+std::string CentreAlignFormatting(const std::string& stringToPass, const int spacingWidth)
+{
+ std::stringstream outputStream, centrePadding;
+ int padding = spacingWidth - static_cast<int>(stringToPass.size());
+
+ for (int i = 0; i < padding / 2; ++i)
+ {
+ centrePadding << " ";
+ }
+
+ outputStream << centrePadding.str() << stringToPass << centrePadding.str();
+
+ if (padding > 0 && padding %2 != 0)
+ {
+ outputStream << " ";
+ }
+
+ return outputStream.str();
+}
+
+
+} // namespace pipe
+} // namespace arm \ No newline at end of file
diff --git a/profiling/common/src/NetworkSockets.cpp b/profiling/common/src/NetworkSockets.cpp
index 7f47c79b31..2a656552f1 100644
--- a/profiling/common/src/NetworkSockets.cpp
+++ b/profiling/common/src/NetworkSockets.cpp
@@ -1,27 +1,35 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
-#include "common/include/NetworkSockets.hpp"
+#include <common/include/NetworkSockets.hpp>
#if defined(__unix__) || defined(__APPLE__)
#include <unistd.h>
#include <fcntl.h>
-#include <armnn/Conversion.hpp>
+#include <common/include/Conversion.hpp>
+#endif
+
+#if defined(__APPLE__) || defined(_MSC_VER) || defined(__MINGW32__)
+#include <common/include/IgnoreUnused.hpp>
+#endif
+#if defined(__MINGW32__)
+#include <common/include/Conversion.hpp>
+#include <common/include/NumericCast.hpp>
#endif
-namespace armnnUtils
+namespace arm
{
-namespace Sockets
+namespace pipe
{
bool Initialize()
{
#if defined(__unix__) || defined(__APPLE__)
return true;
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) || defined(__MINGW32__)
WSADATA wsaData;
return WSAStartup(MAKEWORD(2, 2), &wsaData) == 0;
#endif
@@ -31,7 +39,7 @@ int Close(Socket s)
{
#if defined(__unix__) || defined(__APPLE__)
return close(s);
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) || defined(__MINGW32__)
return closesocket(s);
#endif
}
@@ -45,6 +53,9 @@ bool SetNonBlocking(Socket s)
#elif defined(_MSC_VER)
u_long mode = 1;
return ioctlsocket(s, FIONBIO, &mode) == 0;
+#elif defined(__MINGW32__)
+ u_long mode = 1;
+ return ioctlsocket(s, arm::pipe::numeric_cast<long>(FIONBIO), &mode) == 0;
#endif
}
@@ -53,7 +64,7 @@ long Write(Socket s, const void* buf, size_t len)
{
#if defined(__unix__) || defined(__APPLE__)
return write(s, buf, len);
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) || defined(__MINGW32__)
return send(s, static_cast<const char*>(buf), static_cast<int>(len), 0);
#endif
}
@@ -63,7 +74,7 @@ long Read(Socket s, void* buf, size_t len)
{
#if defined(__unix__) || defined(__APPLE__)
return read(s, buf, len);
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) || defined(__MINGW32__)
return recv(s, static_cast<char*>(buf), static_cast<int>(len), 0);
#endif
}
@@ -71,11 +82,13 @@ long Read(Socket s, void* buf, size_t len)
int Ioctl(Socket s, unsigned long int cmd, void* arg)
{
#if defined(__unix__) || defined(__APPLE__)
- ARMNN_NO_CONVERSION_WARN_BEGIN
+ ARM_PIPE_NO_CONVERSION_WARN_BEGIN
return ioctl(s, static_cast<int>(cmd), arg);
- ARMNN_NO_CONVERSION_WARN_END
-#elif defined(_MSC_VER)
+ ARM_PIPE_NO_CONVERSION_WARN_END
+#elif defined(_MSC_VER) || defined(__MINGW32__)
+ ARM_PIPE_NO_CONVERSION_WARN_BEGIN
return ioctlsocket(s, cmd, static_cast<u_long*>(arg));
+ ARM_PIPE_NO_CONVERSION_WARN_END
#endif
}
@@ -84,22 +97,24 @@ int Poll(PollFd* fds, nfds_t numFds, int timeout)
{
#if defined(__unix__) || defined(__APPLE__)
return poll(fds, numFds, timeout);
-#elif defined(_MSC_VER)
- return WSAPoll(fds, numFds, timeout);
+#elif defined(_MSC_VER) || defined(__MINGW32__)
+ return WSAPoll(fds, arm::pipe::numeric_cast<unsigned long>(numFds), timeout);
#endif
}
-armnnUtils::Sockets::Socket Accept(Socket s, sockaddr* addr, socklen_t* addrlen, int flags)
+arm::pipe::Socket Accept(Socket s, sockaddr* addr, socklen_t* addrlen, int flags)
{
#if defined(__unix__)
return accept4(s, addr, addrlen, flags);
#elif defined(__APPLE__)
+ IgnoreUnused(flags);
return accept(s, addr, addrlen);
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) || defined(__MINGW32__)
+ IgnoreUnused(flags);
return accept(s, addr, reinterpret_cast<int*>(addrlen));
#endif
}
-}
-}
+} // pipe
+} // arm
diff --git a/src/profiling/PacketVersionResolver.cpp b/profiling/common/src/PacketVersionResolver.cpp
index 689abbb082..25d92b0c5d 100644
--- a/src/profiling/PacketVersionResolver.cpp
+++ b/profiling/common/src/PacketVersionResolver.cpp
@@ -1,16 +1,14 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
-#include "PacketVersionResolver.hpp"
+#include <common/include/PacketVersionResolver.hpp>
-#include <armnn/utility/IgnoreUnused.hpp>
-
-namespace armnn
+namespace arm
{
-namespace profiling
+namespace pipe
{
bool PacketKey::operator<(const PacketKey& rhs) const
@@ -68,6 +66,6 @@ Version PacketVersionResolver::ResolvePacketVersion(uint32_t familyId, uint32_t
return Version(1, 0, 0);
}
-} // namespace profiling
+} // namespace pipe
-} // namespace armnn
+} // namespace arm
diff --git a/profiling/common/src/SwTrace.cpp b/profiling/common/src/SwTrace.cpp
new file mode 100644
index 0000000000..5860d8cf06
--- /dev/null
+++ b/profiling/common/src/SwTrace.cpp
@@ -0,0 +1,128 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include <common/include/CommonProfilingUtils.hpp>
+#include <common/include/NumericCast.hpp>
+#include <common/include/ProfilingException.hpp>
+#include <common/include/SwTrace.hpp>
+
+#include <sstream>
+
+namespace arm
+{
+
+namespace pipe
+{
+
+// Calculate the actual length an SwString will be including the terminating null character
+// padding to bring it to the next uint32_t boundary but minus the leading uint32_t encoding
+// the size to allow the offset to be correctly updated when decoding a binary packet.
+uint32_t CalculateSizeOfPaddedSwString(const std::string& str)
+{
+ std::vector<uint32_t> swTraceString;
+ StringToSwTraceString<SwTraceCharPolicy>(str, swTraceString);
+ unsigned int uint32_t_size = sizeof(uint32_t);
+ uint32_t size = (numeric_cast<uint32_t>(swTraceString.size()) - 1) * uint32_t_size;
+ return size;
+}
+
+// Read TimelineMessageDirectoryPacket from given IPacketBuffer and offset
+SwTraceMessage ReadSwTraceMessage(const unsigned char* packetBuffer,
+ unsigned int& offset,
+ const unsigned int& packetLength)
+{
+ ARM_PIPE_ASSERT(packetBuffer);
+
+ unsigned int uint32_t_size = sizeof(uint32_t);
+
+ SwTraceMessage swTraceMessage;
+
+ // Read the decl_id
+ uint32_t readDeclId = ReadUint32(packetBuffer, offset);
+ swTraceMessage.m_Id = readDeclId;
+
+ // SWTrace "namestring" format
+ // length of the string (first 4 bytes) + string + null terminator
+
+ // Check the decl_name
+ offset += uint32_t_size;
+ uint32_t swTraceDeclNameLength = ReadUint32(packetBuffer, offset);
+
+ if (swTraceDeclNameLength == 0 || swTraceDeclNameLength > packetLength)
+ {
+ throw arm::pipe::ProfilingException("Error swTraceDeclNameLength is an invalid size", LOCATION());
+ }
+
+ offset += uint32_t_size;
+ std::vector<unsigned char> swTraceStringBuffer(swTraceDeclNameLength - 1);
+ std::memcpy(swTraceStringBuffer.data(),
+ packetBuffer + offset, swTraceStringBuffer.size());
+
+ swTraceMessage.m_Name.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end()); // name
+
+ // Check the ui_name
+ offset += CalculateSizeOfPaddedSwString(swTraceMessage.m_Name);
+ uint32_t swTraceUINameLength = ReadUint32(packetBuffer, offset);
+
+ if (swTraceUINameLength == 0 || swTraceUINameLength > packetLength)
+ {
+ throw arm::pipe::ProfilingException("Error swTraceUINameLength is an invalid size", LOCATION());
+ }
+
+ offset += uint32_t_size;
+ swTraceStringBuffer.resize(swTraceUINameLength - 1);
+ std::memcpy(swTraceStringBuffer.data(),
+ packetBuffer + offset, swTraceStringBuffer.size());
+
+ swTraceMessage.m_UiName.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end()); // ui_name
+
+ // Check arg_types
+ offset += CalculateSizeOfPaddedSwString(swTraceMessage.m_UiName);
+ uint32_t swTraceArgTypesLength = ReadUint32(packetBuffer, offset);
+
+ if (swTraceArgTypesLength == 0 || swTraceArgTypesLength > packetLength)
+ {
+ throw arm::pipe::ProfilingException("Error swTraceArgTypesLength is an invalid size", LOCATION());
+ }
+
+ offset += uint32_t_size;
+ swTraceStringBuffer.resize(swTraceArgTypesLength - 1);
+ std::memcpy(swTraceStringBuffer.data(),
+ packetBuffer + offset, swTraceStringBuffer.size());
+
+ swTraceMessage.m_ArgTypes.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end()); // arg_types
+
+ std::string swTraceString(swTraceStringBuffer.begin(), swTraceStringBuffer.end());
+
+ // Check arg_names
+ offset += CalculateSizeOfPaddedSwString(swTraceString);
+ uint32_t swTraceArgNamesLength = ReadUint32(packetBuffer, offset);
+
+ if (swTraceArgNamesLength == 0 || swTraceArgNamesLength > packetLength)
+ {
+ throw arm::pipe::ProfilingException("Error swTraceArgNamesLength is an invalid size", LOCATION());
+ }
+
+ offset += uint32_t_size;
+ swTraceStringBuffer.resize(swTraceArgNamesLength - 1);
+ std::memcpy(swTraceStringBuffer.data(),
+ packetBuffer + offset, swTraceStringBuffer.size());
+
+ swTraceString.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end());
+ std::stringstream stringStream(swTraceString);
+ std::string argName;
+ while (std::getline(stringStream, argName, ','))
+ {
+ swTraceMessage.m_ArgNames.push_back(argName);
+ }
+
+ offset += CalculateSizeOfPaddedSwString(swTraceString);
+
+ return swTraceMessage;
+}
+
+} // namespace pipe
+
+} // namespace arm
diff --git a/profiling/server/src/basePipeServer/BasePipeServer.hpp b/profiling/server/include/basePipeServer/BasePipeServer.hpp
index bef9d29f44..1b6dec54ff 100644
--- a/profiling/server/src/basePipeServer/BasePipeServer.hpp
+++ b/profiling/server/include/basePipeServer/BasePipeServer.hpp
@@ -1,18 +1,21 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include <NetworkSockets.hpp>
-#include <Packet.hpp>
-#include <SocketConnectionException.hpp>
+#include <common/include/NetworkSockets.hpp>
+#include <common/include/Packet.hpp>
+#include <common/include/SocketConnectionException.hpp>
#include <string>
#include <atomic>
-namespace armnnProfiling
+namespace arm
+{
+
+namespace pipe
{
enum class TargetEndianness
@@ -34,7 +37,7 @@ class BasePipeServer
public:
- BasePipeServer(armnnUtils::Sockets::Socket clientConnection, bool echoPackets)
+ BasePipeServer(arm::pipe::Socket clientConnection, bool echoPackets)
: m_ClientConnection(clientConnection)
, m_EchoPackets(echoPackets)
{}
@@ -42,7 +45,7 @@ public:
~BasePipeServer()
{
// We have set SOCK_CLOEXEC on this socket but we'll close it to be good citizens.
- armnnUtils::Sockets::Close(m_ClientConnection);
+ arm::pipe::Close(m_ClientConnection);
}
BasePipeServer(const BasePipeServer&) = delete;
@@ -55,7 +58,7 @@ public:
/// @return 0 if successful
int Close()
{
- return armnnUtils::Sockets::Close(m_ClientConnection);
+ return arm::pipe::Close(m_ClientConnection);
}
/// Send a packet to the client
@@ -66,12 +69,12 @@ public:
/// @return true if successful.
bool SetNonBlocking()
{
- return armnnUtils::Sockets::SetNonBlocking(m_ClientConnection);
+ return arm::pipe::SetNonBlocking(m_ClientConnection);
}
/// Block on the client connection until a complete packet has been received.
/// @return true if a valid packet has been received.
- armnn::profiling::Packet WaitForPacket(uint32_t timeoutMs);
+ arm::pipe::Packet WaitForPacket(uint32_t timeoutMs);
/// Once the connection is open wait to receive the stream meta data packet from the client. Reading this
/// packet differs from others as we need to determine endianness.
@@ -99,12 +102,12 @@ private:
bool ReadFromSocket(uint8_t* packetData, uint32_t expectedLength);
bool ReadHeader(uint32_t headerAsWords[2]);
- armnn::profiling::Packet ReceivePacket();
+ arm::pipe::Packet ReceivePacket();
uint32_t ToUint32(uint8_t* data, TargetEndianness endianness);
void InsertU32(uint32_t value, uint8_t* data, TargetEndianness endianness);
- armnnUtils::Sockets::Socket m_ClientConnection;
+ arm::pipe::Socket m_ClientConnection;
bool m_EchoPackets;
TargetEndianness m_Endianness;
@@ -113,4 +116,5 @@ private:
uint32_t m_StreamMetaDataPid;
};
-} // namespace armnnProfiling \ No newline at end of file
+} // namespace pipe
+} // namespace arm
diff --git a/profiling/server/src/basePipeServer/ConnectionHandler.hpp b/profiling/server/include/basePipeServer/ConnectionHandler.hpp
index 661935b885..4859fced0d 100644
--- a/profiling/server/src/basePipeServer/ConnectionHandler.hpp
+++ b/profiling/server/include/basePipeServer/ConnectionHandler.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -8,7 +8,10 @@
#include "BasePipeServer.hpp"
#include <string>
-namespace armnnProfiling
+namespace arm
+{
+
+namespace pipe
{
class ConnectionHandler
@@ -22,7 +25,7 @@ public:
~ConnectionHandler()
{
// We have set SOCK_CLOEXEC on this socket but we'll close it to be good citizens.
- armnnUtils::Sockets::Close(m_ListeningSocket);
+ arm::pipe::Close(m_ListeningSocket);
}
ConnectionHandler(const ConnectionHandler&) = delete;
@@ -38,7 +41,8 @@ public:
private:
- armnnUtils::Sockets::Socket m_ListeningSocket;
+ arm::pipe::Socket m_ListeningSocket;
};
-} // namespace armnnProfiling \ No newline at end of file
+} // namespace pipe
+} // namespace arm
diff --git a/include/armnn/profiling/ITimelineDecoder.hpp b/profiling/server/include/timelineDecoder/ITimelineDecoder.hpp
index 0035a3b7d2..18b8cc7006 100644
--- a/include/armnn/profiling/ITimelineDecoder.hpp
+++ b/profiling/server/include/timelineDecoder/ITimelineDecoder.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -8,6 +8,12 @@
#include <cstdint>
#include <string>
+namespace arm
+{
+
+namespace pipe
+{
+
class ITimelineDecoder
{
@@ -79,4 +85,7 @@ public:
virtual TimelineStatus CreateEvent(const Event&) = 0;
virtual TimelineStatus CreateLabel(const Label&) = 0;
virtual TimelineStatus CreateRelationship(const Relationship&) = 0;
-}; \ No newline at end of file
+};
+
+} // namespace pipe
+} // namespace arm
diff --git a/src/timelineDecoder/TimelineCaptureCommandHandler.hpp b/profiling/server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp
index 0431e9ca49..c51cfd32cd 100644
--- a/src/timelineDecoder/TimelineCaptureCommandHandler.hpp
+++ b/profiling/server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp
@@ -5,20 +5,18 @@
#pragma once
-#include <armnn/profiling/ITimelineDecoder.hpp>
+#include "ITimelineDecoder.hpp"
-#include <CommandHandlerFunctor.hpp>
-#include <Packet.hpp>
-#include <ProfilingUtils.hpp>
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
-namespace armnn
+namespace arm
{
-namespace timelinedecoder
+namespace pipe
{
-class TimelineCaptureCommandHandler :
- public profiling::CommandHandlerFunctor
+class TimelineCaptureCommandHandler : public arm::pipe::CommandHandlerFunctor
{
// Utils
uint32_t uint32_t_size = sizeof(uint32_t);
@@ -39,13 +37,13 @@ public:
, m_PacketLength(0)
{}
- void operator()(const armnn::profiling::Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
void SetThreadIdSize(uint32_t size);
private:
- void ParseData(const armnn::profiling::Packet& packet);
+ void ParseData(const arm::pipe::Packet& packet);
ITimelineDecoder::TimelineStatus ReadLabel(const unsigned char* data, uint32_t& offset);
ITimelineDecoder::TimelineStatus ReadEntity(const unsigned char* data, uint32_t& offset);
@@ -60,6 +58,6 @@ private:
};
-} //namespace gatordmock
+} //namespace pipe
-} //namespace armnn
+} //namespace arm
diff --git a/src/timelineDecoder/TimelineDecoder.hpp b/profiling/server/include/timelineDecoder/TimelineDecoder.hpp
index 2efdc4483b..ea4b144860 100644
--- a/src/timelineDecoder/TimelineDecoder.hpp
+++ b/profiling/server/include/timelineDecoder/TimelineDecoder.hpp
@@ -1,17 +1,19 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include <armnn/profiling/ITimelineDecoder.hpp>
+#include "ITimelineDecoder.hpp"
#include <vector>
-namespace armnn
+namespace arm
{
-namespace timelinedecoder
+
+namespace pipe
{
+
class TimelineDecoder : public ITimelineDecoder
{
@@ -66,5 +68,5 @@ private:
void printEvents();
};
-}
-} \ No newline at end of file
+} // namespace pipe
+} // namespace arm \ No newline at end of file
diff --git a/src/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp b/profiling/server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp
index 2879052340..826ee1f10d 100644
--- a/src/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp
+++ b/profiling/server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -7,17 +7,15 @@
#include "TimelineCaptureCommandHandler.hpp"
-#include <Packet.hpp>
-#include <PacketBuffer.hpp>
-#include <ProfilingUtils.hpp>
+#include <common/include/SwTrace.hpp>
-namespace armnn
+namespace arm
{
-namespace timelinedecoder
+namespace pipe
{
-class TimelineDirectoryCaptureCommandHandler : public profiling::CommandHandlerFunctor
+class TimelineDirectoryCaptureCommandHandler : public arm::pipe::CommandHandlerFunctor
{
// Utils
uint32_t uint8_t_size = sizeof(uint8_t);
@@ -34,19 +32,19 @@ public:
, m_QuietOperation(quietOperation)
{}
- void operator()(const armnn::profiling::Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
- profiling::SwTraceHeader m_SwTraceHeader;
- std::vector<profiling::SwTraceMessage> m_SwTraceMessages;
+ arm::pipe::SwTraceHeader m_SwTraceHeader;
+ std::vector<arm::pipe::SwTraceMessage> m_SwTraceMessages;
private:
- void ParseData(const armnn::profiling::Packet& packet);
+ void ParseData(const arm::pipe::Packet& packet);
void Print();
TimelineCaptureCommandHandler& m_TimelineCaptureCommandHandler;
bool m_QuietOperation;
};
-} //namespace gatordmock
+} //namespace pipe
-} //namespace armnn
+} //namespace arm
diff --git a/profiling/server/src/basePipeServer/BasePipeServer.cpp b/profiling/server/src/basePipeServer/BasePipeServer.cpp
index ed5c442492..81f58a5ee9 100644
--- a/profiling/server/src/basePipeServer/BasePipeServer.cpp
+++ b/profiling/server/src/basePipeServer/BasePipeServer.cpp
@@ -1,30 +1,31 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
-#include "BasePipeServer.hpp"
+#include <server/include/basePipeServer/BasePipeServer.hpp>
-#include "common/include/Constants.hpp"
+#include <common/include/Constants.hpp>
+#include <common/include/NumericCast.hpp>
#include <iostream>
-#include <boost/cast.hpp>
#include <vector>
#include <iomanip>
#include <string.h>
-using namespace armnnUtils;
+namespace arm
+{
-namespace armnnProfiling
+namespace pipe
{
bool BasePipeServer::ReadFromSocket(uint8_t* packetData, uint32_t expectedLength)
{
// This is a blocking read until either expectedLength has been received or an error is detected.
long totalBytesRead = 0;
- while (boost::numeric_cast<uint32_t>(totalBytesRead) < expectedLength)
+ while (arm::pipe::numeric_cast<uint32_t>(totalBytesRead) < expectedLength)
{
- long bytesRead = Sockets::Read(m_ClientConnection, packetData, expectedLength);
+ long bytesRead = arm::pipe::Read(m_ClientConnection, packetData, expectedLength);
if (bytesRead < 0)
{
std::cerr << ": Failure when reading from client socket: " << strerror(errno) << std::endl;
@@ -68,17 +69,17 @@ 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) == armnnProfiling::PIPE_MAGIC)
+ if (ToUint32(&pipeMagic[0], TargetEndianness::BeWire) == PIPE_MAGIC)
{
m_Endianness = TargetEndianness::BeWire;
}
- else if (ToUint32(&pipeMagic[0], TargetEndianness::LeWire) == armnnProfiling::PIPE_MAGIC)
+ else if (ToUint32(&pipeMagic[0], TargetEndianness::LeWire) == PIPE_MAGIC)
{
m_Endianness = TargetEndianness::LeWire;
}
else
{
- std::cerr << ": Protocol read error. Unable to read PIPE_MAGIC value." << std::endl;
+ std::cerr << ": Protocol read error. Unable to read the PIPE_MAGIC value." << std::endl;
return false;
}
// Now we know the endianness we can get the length from the header.
@@ -87,7 +88,7 @@ bool BasePipeServer::WaitForStreamMetaData()
// Read the entire packet.
std::vector<uint8_t> packetData(metaDataLength);
if (metaDataLength !=
- boost::numeric_cast<uint32_t>(Sockets::Read(m_ClientConnection, packetData.data(), metaDataLength)))
+ arm::pipe::numeric_cast<uint32_t>(arm::pipe::Read(m_ClientConnection, packetData.data(), metaDataLength)))
{
std::cerr << ": Protocol read error. Data length mismatch." << std::endl;
return false;
@@ -100,11 +101,11 @@ bool BasePipeServer::WaitForStreamMetaData()
return true;
}
-armnn::profiling::Packet BasePipeServer::WaitForPacket(uint32_t timeoutMs)
+arm::pipe::Packet BasePipeServer::WaitForPacket(uint32_t timeoutMs)
{
// Is there currently more than a headers worth of data waiting to be read?
int bytes_available;
- Sockets::Ioctl(m_ClientConnection, FIONREAD, &bytes_available);
+ arm::pipe::Ioctl(m_ClientConnection, FIONREAD, &bytes_available);
if (bytes_available > 8)
{
// Yes there is. Read it:
@@ -115,18 +116,18 @@ armnn::profiling::Packet BasePipeServer::WaitForPacket(uint32_t timeoutMs)
// No there's not. Poll for more data.
struct pollfd pollingFd[1]{};
pollingFd[0].fd = m_ClientConnection;
- int pollResult = Sockets::Poll(pollingFd, 1, static_cast<int>(timeoutMs));
+ int pollResult = arm::pipe::Poll(pollingFd, 1, static_cast<int>(timeoutMs));
switch (pollResult)
{
// Error
case -1:
- throw armnn::RuntimeException(std::string("File descriptor reported an error during polling: ") +
- strerror(errno));
+ throw ProfilingException(std::string("File descriptor reported an error during polling: ") +
+ strerror(errno));
// Timeout
case 0:
- throw armnn::TimeoutException("Timeout while waiting to receive packet.");
+ throw arm::pipe::TimeoutException("Timeout while waiting to receive packet.");
// Normal poll return. It could still contain an error signal
default:
@@ -135,16 +136,18 @@ armnn::profiling::Packet BasePipeServer::WaitForPacket(uint32_t timeoutMs)
{
if (pollingFd[0].revents == POLLNVAL)
{
- throw armnn::RuntimeException(std::string("Error while polling receiving socket: POLLNVAL"));
+ throw arm::pipe::ProfilingException(
+ std::string("Error while polling receiving socket: POLLNVAL"));
}
if (pollingFd[0].revents == POLLERR)
{
- throw armnn::RuntimeException(std::string("Error while polling receiving socket: POLLERR: ") +
- strerror(errno));
+ throw arm::pipe::ProfilingException(
+ std::string("Error while polling receiving socket: POLLERR: ") + strerror(errno));
}
if (pollingFd[0].revents == POLLHUP)
{
- throw armnn::RuntimeException(std::string("Connection closed by remote client: POLLHUP"));
+ throw arm::pipe::ProfilingException(
+ std::string("Connection closed by remote client: POLLHUP"));
}
}
@@ -153,19 +156,20 @@ armnn::profiling::Packet BasePipeServer::WaitForPacket(uint32_t timeoutMs)
{
// This is a corner case. The socket as been woken up but not with any data.
// We'll throw a timeout exception to loop around again.
- throw armnn::TimeoutException("File descriptor was polled but no data was available to receive.");
+ throw arm::pipe::TimeoutException(
+ "File descriptor was polled but no data was available to receive.");
}
return ReceivePacket();
}
}
}
-armnn::profiling::Packet BasePipeServer::ReceivePacket()
+arm::pipe::Packet BasePipeServer::ReceivePacket()
{
uint32_t header[2];
if (!ReadHeader(header))
{
- return armnn::profiling::Packet();
+ return arm::pipe::Packet();
}
// Read data_length bytes from the socket.
std::unique_ptr<unsigned char[]> uniquePacketData = std::make_unique<unsigned char[]>(header[1]);
@@ -173,13 +177,13 @@ armnn::profiling::Packet BasePipeServer::ReceivePacket()
if (!ReadFromSocket(packetData, header[1]))
{
- return armnn::profiling::Packet();
+ return arm::pipe::Packet();
}
EchoPacket(PacketDirection::ReceivedData, packetData, header[1]);
// Construct received packet
- armnn::profiling::Packet packetRx = armnn::profiling::Packet(header[0], header[1], uniquePacketData);
+ arm::pipe::Packet packetRx = arm::pipe::Packet(header[0], header[1], uniquePacketData);
if (m_EchoPackets)
{
std::cout << "Processing packet ID= " << packetRx.GetPacketId() << " Length=" << packetRx.GetLength()
@@ -206,7 +210,7 @@ bool BasePipeServer::SendPacket(uint32_t packetFamily, uint32_t packetId, const
memcpy((packet.data() + 8), data, dataLength);
}
EchoPacket(PacketDirection::Sending, packet.data(), packet.size());
- if (-1 == armnnUtils::Sockets::Write(m_ClientConnection, packet.data(), packet.size()))
+ if (-1 == arm::pipe::Write(m_ClientConnection, packet.data(), packet.size()))
{
std::cerr << ": Failure when writing to client socket: " << strerror(errno) << std::endl;
return false;
@@ -294,4 +298,5 @@ void BasePipeServer::InsertU32(uint32_t value, uint8_t* data, TargetEndianness e
}
}
-} // namespace armnnProfiling \ No newline at end of file
+} // namespace pipe
+} // namespace arm
diff --git a/profiling/server/src/basePipeServer/CMakeLists.txt b/profiling/server/src/basePipeServer/CMakeLists.txt
index 56ef4548ec..b5dc68c2c4 100644
--- a/profiling/server/src/basePipeServer/CMakeLists.txt
+++ b/profiling/server/src/basePipeServer/CMakeLists.txt
@@ -1,37 +1,49 @@
#
-# Copyright © 2020 Arm Ltd. All rights reserved.
+# Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
# SPDX-License-Identifier: MIT
#
if(BUILD_BASE_PIPE_SERVER)
set(BasePipeServer_sources)
list(APPEND BasePipeServer_sources
- BasePipeServer.cpp
- BasePipeServer.hpp
- ConnectionHandler.cpp
- ConnectionHandler.hpp)
+ BasePipeServer.cpp)
+
+ if(NOT "${TOOLCHAIN_PREFIX}" STREQUAL x86_64-w64-mingw32)
+ list(APPEND BasePipeServer_sources
+ ConnectionHandler.cpp)
+ endif()
include_directories(${PROJECT_SOURCE_DIR}/profiling/common/include)
+ include_directories(${PROJECT_SOURCE_DIR}/profiling/server/include/basePipeServer)
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})
+ if (BUILD_STATIC_PIPE_LIBS)
+ add_library_ex(armnnBasePipeServer STATIC ${BasePipeServer_sources})
+ target_link_libraries(armnnBasePipeServer pipeCommon)
- set_target_properties(armnnBasePipeServer PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
- set_target_properties(armnnBasePipeServer PROPERTIES VERSION ${GENERIC_LIB_VERSION}
- SOVERSION ${GENERIC_LIB_SOVERSION})
+ if ("${CMAKE_SYSTEM_NAME}" STREQUAL Windows)
+ target_link_libraries(armnnBasePipeServer ws2_32.lib)
+ endif()
+ else()
+ add_library_ex(armnnBasePipeServer SHARED ${BasePipeServer_sources})
+ target_link_libraries(armnnBasePipeServer pipeCommon)
- target_include_directories(armnnBasePipeServer PRIVATE ${PROJECT_SOURCE_DIR}/src/armnnUtils)
+ if ("${CMAKE_SYSTEM_NAME}" STREQUAL Windows)
+ target_link_libraries(armnnBasePipeServer ws2_32.lib)
+ endif()
- target_link_libraries(armnnBasePipeServer armnn)
- if ("${CMAKE_SYSTEM_NAME}" STREQUAL Windows)
- target_link_libraries(armnnBasePipeServer Ws2_32.lib)
- endif()
+ set_target_properties(armnnBasePipeServer PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
+ set_target_properties(armnnBasePipeServer PROPERTIES VERSION ${GENERIC_LIB_VERSION}
+ SOVERSION ${GENERIC_LIB_SOVERSION})
+
+ target_include_directories(armnnBasePipeServer PRIVATE ${PROJECT_SOURCE_DIR}/src/armnnUtils)
- install(TARGETS armnnBasePipeServer
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
-endif() \ No newline at end of file
+ install(TARGETS armnnBasePipeServer
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+ endif()
+endif()
diff --git a/profiling/server/src/basePipeServer/ConnectionHandler.cpp b/profiling/server/src/basePipeServer/ConnectionHandler.cpp
index 1485ab8620..1c9ffa95c2 100644
--- a/profiling/server/src/basePipeServer/ConnectionHandler.cpp
+++ b/profiling/server/src/basePipeServer/ConnectionHandler.cpp
@@ -1,18 +1,21 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
-#include "ConnectionHandler.hpp"
-#include <string.h>
+#include <server/include/basePipeServer/ConnectionHandler.hpp>
-using namespace armnnUtils;
+#include <string>
-namespace armnnProfiling
+namespace arm
{
+
+namespace pipe
+{
+
ConnectionHandler::ConnectionHandler(const std::string& udsNamespace, const bool setNonBlocking)
{
- Sockets::Initialize();
+ arm::pipe::Initialize();
m_ListeningSocket = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (-1 == m_ListeningSocket)
@@ -39,14 +42,13 @@ ConnectionHandler::ConnectionHandler(const std::string& udsNamespace, const bool
if (setNonBlocking)
{
- Sockets::SetNonBlocking(m_ListeningSocket);
+ arm::pipe::SetNonBlocking(m_ListeningSocket);
}
}
std::unique_ptr<BasePipeServer> ConnectionHandler::GetNewBasePipeServer(const bool echoPackets)
{
- armnnUtils::Sockets::Socket clientConnection = armnnUtils::Sockets::Accept(m_ListeningSocket, nullptr, nullptr,
- SOCK_CLOEXEC);
+ arm::pipe::Socket clientConnection = arm::pipe::Accept(m_ListeningSocket, nullptr, nullptr, SOCK_CLOEXEC);
if (clientConnection < 1)
{
return nullptr;
@@ -54,4 +56,5 @@ std::unique_ptr<BasePipeServer> ConnectionHandler::GetNewBasePipeServer(const bo
return std::make_unique<BasePipeServer>(clientConnection, echoPackets);
}
-} // namespace armnnProfiling \ No newline at end of file
+} // namespace pipe
+} // namespace arm
diff --git a/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp b/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp
index 57fc9e9da6..091792782f 100644
--- a/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp
+++ b/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp
@@ -1,9 +1,9 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
-#include <ConnectionHandler.hpp>
+#include <server/include/basePipeServer/ConnectionHandler.hpp>
#include <SocketProfilingConnection.hpp>
#include <Processes.hpp>
@@ -15,7 +15,7 @@
BOOST_AUTO_TEST_SUITE(BasePipeServerTests)
using namespace armnn;
-using namespace armnnProfiling;
+using namespace arm::pipe;
BOOST_AUTO_TEST_CASE(BasePipeServerTest)
{
@@ -28,7 +28,7 @@ BOOST_AUTO_TEST_CASE(BasePipeServerTest)
// The socket should close once we leave the scope of BOOST_CHECK_NO_THROW
// and socketProfilingConnection should fail to connect
BOOST_CHECK_THROW(profiling::SocketProfilingConnection socketProfilingConnection,
- armnnProfiling::SocketConnectionException);
+ arm::pipe::SocketConnectionException);
// Try to initialize a listening socket through the ConnectionHandler again
ConnectionHandler connectionHandler(udsNamespace, true);
diff --git a/profiling/server/src/timelineDecoder/CMakeLists.txt b/profiling/server/src/timelineDecoder/CMakeLists.txt
new file mode 100644
index 0000000000..7154722fa6
--- /dev/null
+++ b/profiling/server/src/timelineDecoder/CMakeLists.txt
@@ -0,0 +1,44 @@
+#
+# Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+# SPDX-License-Identifier: MIT
+#
+
+if(BUILD_TIMELINE_DECODER)
+ set(timelineDecoder_sources)
+ list(APPEND timelineDecoder_sources
+ TimelineCaptureCommandHandler.cpp
+ TimelineDecoder.cpp
+ TimelineDirectoryCaptureCommandHandler.cpp)
+
+ include_directories(${PROJECT_SOURCE_DIR}/profiling/common/include)
+
+ if(BUILD_UNIT_TESTS)
+ include_directories(${PROJECT_SOURCE_DIR}/src/profiling
+ ${PROJECT_SOURCE_DIR}/src/armnnUtils)
+ target_include_directories(UnitTests PRIVATE ${PROJECT_SOURCE_DIR}/profiling/server/include/timelineDecoder)
+ endif()
+
+
+ if (BUILD_STATIC_PIPE_LIBS)
+ add_library_ex(timelineDecoder STATIC ${timelineDecoder_sources})
+ target_link_libraries(timelineDecoder pipeCommon)
+
+ if ("${CMAKE_SYSTEM_NAME}" STREQUAL Windows)
+ target_link_libraries(timelineDecoder ws2_32.lib)
+ endif()
+ else()
+ add_library_ex(timelineDecoder SHARED ${timelineDecoder_sources})
+ target_link_libraries(timelineDecoder pipeCommon)
+
+ if ("${CMAKE_SYSTEM_NAME}" STREQUAL Windows)
+ target_link_libraries(timelineDecoder ws2_32.lib)
+ endif()
+
+ set_target_properties(timelineDecoder PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
+ set_target_properties(timelineDecoder PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
+
+ install(TARGETS timelineDecoder
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+ endif()
+endif()
diff --git a/src/timelineDecoder/TimelineCaptureCommandHandler.cpp b/profiling/server/src/timelineDecoder/TimelineCaptureCommandHandler.cpp
index 39a806ce87..247c9519e0 100644
--- a/src/timelineDecoder/TimelineCaptureCommandHandler.cpp
+++ b/profiling/server/src/timelineDecoder/TimelineCaptureCommandHandler.cpp
@@ -3,14 +3,16 @@
// SPDX-License-Identifier: MIT
//
-#include "TimelineCaptureCommandHandler.hpp"
+#include <common/include/CommonProfilingUtils.hpp>
+#include <common/include/Logging.hpp>
+#include <server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp>
#include <string>
-#include <armnn/Logging.hpp>
-namespace armnn
+
+namespace arm
{
-namespace timelinedecoder
+namespace pipe
{
//Array of member functions, the array index matches the decl_id
@@ -28,12 +30,12 @@ void TimelineCaptureCommandHandler::SetThreadIdSize(uint32_t size)
m_ThreadIdSize = size;
}
-void TimelineCaptureCommandHandler::operator()(const profiling::Packet& packet)
+void TimelineCaptureCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ParseData(packet);
}
-void TimelineCaptureCommandHandler::ParseData(const armnn::profiling::Packet& packet)
+void TimelineCaptureCommandHandler::ParseData(const arm::pipe::Packet& packet)
{
uint32_t offset = 0;
m_PacketLength = packet.GetLength();
@@ -42,7 +44,7 @@ void TimelineCaptureCommandHandler::ParseData(const armnn::profiling::Packet& pa
// if it not set in the constructor
if (m_ThreadIdSize == 0)
{
- ARMNN_LOG(error) << "TimelineCaptureCommandHandler: m_ThreadIdSize has not been set";
+ ARM_PIPE_LOG(error) << "TimelineCaptureCommandHandler: m_ThreadIdSize has not been set";
return;
}
@@ -57,13 +59,13 @@ void TimelineCaptureCommandHandler::ParseData(const armnn::profiling::Packet& pa
while ( offset < m_PacketLength )
{
- declId = profiling::ReadUint32(data, offset);
+ declId = arm::pipe::ReadUint32(data, offset);
offset += uint32_t_size;
ITimelineDecoder::TimelineStatus status = (this->*m_ReadFunctions[declId])(data, offset);
if (status == ITimelineDecoder::TimelineStatus::TimelineStatus_Fail)
{
- ARMNN_LOG(error) << "Decode of timeline message type [" << declId <<
+ ARM_PIPE_LOG(error) << "Decode of timeline message type [" << declId <<
"] at offset [" << offset << "] failed";
break;
}
@@ -73,17 +75,17 @@ void TimelineCaptureCommandHandler::ParseData(const armnn::profiling::Packet& pa
ITimelineDecoder::TimelineStatus TimelineCaptureCommandHandler::ReadLabel(const unsigned char* data, uint32_t& offset)
{
ITimelineDecoder::Label label;
- label.m_Guid = profiling::ReadUint64(data, offset);
+ label.m_Guid = arm::pipe::ReadUint64(data, offset);
offset += uint64_t_size;
- uint32_t nameLength = profiling::ReadUint32(data, offset);
+ uint32_t nameLength = arm::pipe::ReadUint32(data, offset);
offset += uint32_t_size;
uint32_t i = 0;
// nameLength - 1 to account for null operator \0
for ( i = 0; i < nameLength - 1; ++i )
{
- label.m_Name += static_cast<char>(profiling::ReadUint8(data, offset + i));
+ label.m_Name += static_cast<char>(arm::pipe::ReadUint8(data, offset + i));
}
// Shift offset past nameLength
uint32_t uint32WordAmount = (nameLength / uint32_t_size) + (nameLength % uint32_t_size != 0 ? 1 : 0);
@@ -96,7 +98,7 @@ ITimelineDecoder::TimelineStatus TimelineCaptureCommandHandler::ReadEntity(
const unsigned char* data, uint32_t& offset)
{
ITimelineDecoder::Entity entity;
- entity.m_Guid = profiling::ReadUint64(data, offset);
+ entity.m_Guid = arm::pipe::ReadUint64(data, offset);
offset += uint64_t_size;
return m_TimelineDecoder.CreateEntity(entity);
}
@@ -105,9 +107,9 @@ ITimelineDecoder::TimelineStatus TimelineCaptureCommandHandler::ReadEventClass(
const unsigned char* data, uint32_t& offset)
{
ITimelineDecoder::EventClass eventClass;
- eventClass.m_Guid = profiling::ReadUint64(data, offset);
+ eventClass.m_Guid = arm::pipe::ReadUint64(data, offset);
offset += uint64_t_size;
- eventClass.m_NameGuid = profiling::ReadUint64(data, offset);
+ eventClass.m_NameGuid = arm::pipe::ReadUint64(data, offset);
offset += uint64_t_size;
return m_TimelineDecoder.CreateEventClass(eventClass);
}
@@ -117,19 +119,19 @@ ITimelineDecoder::TimelineStatus TimelineCaptureCommandHandler::ReadRelationship
{
ITimelineDecoder::Relationship relationship;
relationship.m_RelationshipType =
- static_cast<ITimelineDecoder::RelationshipType>(profiling::ReadUint32(data, offset));
+ static_cast<ITimelineDecoder::RelationshipType>(arm::pipe::ReadUint32(data, offset));
offset += uint32_t_size;
- relationship.m_Guid = profiling::ReadUint64(data, offset);
+ relationship.m_Guid = arm::pipe::ReadUint64(data, offset);
offset += uint64_t_size;
- relationship.m_HeadGuid = profiling::ReadUint64(data, offset);
+ relationship.m_HeadGuid = arm::pipe::ReadUint64(data, offset);
offset += uint64_t_size;
- relationship.m_TailGuid = profiling::ReadUint64(data, offset);
+ relationship.m_TailGuid = arm::pipe::ReadUint64(data, offset);
offset += uint64_t_size;
- relationship.m_AttributeGuid = profiling::ReadUint64(data, offset);
+ relationship.m_AttributeGuid = arm::pipe::ReadUint64(data, offset);
offset += uint64_t_size;
return m_TimelineDecoder.CreateRelationship(relationship);
@@ -139,26 +141,26 @@ ITimelineDecoder::TimelineStatus TimelineCaptureCommandHandler::ReadEvent(
const unsigned char* data, uint32_t& offset)
{
ITimelineDecoder::Event event;
- event.m_TimeStamp = profiling::ReadUint64(data, offset);
+ event.m_TimeStamp = arm::pipe::ReadUint64(data, offset);
offset += uint64_t_size;
if ( m_ThreadIdSize == 4 )
{
- event.m_ThreadId = profiling::ReadUint32(data, offset);
+ event.m_ThreadId = arm::pipe::ReadUint32(data, offset);
}
else if ( m_ThreadIdSize == 8 )
{
- event.m_ThreadId = profiling::ReadUint64(data, offset);
+ event.m_ThreadId = arm::pipe::ReadUint64(data, offset);
}
offset += m_ThreadIdSize;
- event.m_Guid = profiling::ReadUint64(data, offset);
+ event.m_Guid = arm::pipe::ReadUint64(data, offset);
offset += uint64_t_size;
return m_TimelineDecoder.CreateEvent(event);
}
-} //namespace gatordmock
+} //namespace pipe
-} //namespace armnn
+} //namespace arm
diff --git a/src/timelineDecoder/TimelineDecoder.cpp b/profiling/server/src/timelineDecoder/TimelineDecoder.cpp
index 9aa84d2084..df967de1f5 100644
--- a/src/timelineDecoder/TimelineDecoder.cpp
+++ b/profiling/server/src/timelineDecoder/TimelineDecoder.cpp
@@ -1,15 +1,17 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
-#include "TimelineDecoder.hpp"
-#include <ProfilingUtils.hpp>
+#include <common/include/CommonProfilingUtils.hpp>
+#include <server/include/timelineDecoder/TimelineDecoder.hpp>
+
#include <iostream>
+#include <sstream>
-namespace armnn
+namespace arm
{
-namespace timelinedecoder
+namespace pipe
{
TimelineDecoder::TimelineStatus TimelineDecoder::CreateEntity(const Entity &entity)
@@ -169,13 +171,13 @@ void TimelineDecoder::printLabels()
{
std::string header;
- header.append(profiling::CentreAlignFormatting("guid", 12));
+ header.append(arm::pipe::CentreAlignFormatting("guid", 12));
header.append(" | ");
- header.append(profiling::CentreAlignFormatting("value", 30));
+ header.append(arm::pipe::CentreAlignFormatting("value", 30));
header.append("\n");
std::cout << "\n" << "\n";
- std::cout << profiling::CentreAlignFormatting("LABELS", static_cast<int>(header.size()));
+ std::cout << arm::pipe::CentreAlignFormatting("LABELS", static_cast<int>(header.size()));
std::cout << "\n";
std::cout << std::string(header.size(), '=') << "\n";
std::cout << header;
@@ -184,9 +186,9 @@ void TimelineDecoder::printLabels()
{
std::string body;
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_Labels[i].m_Guid), 12));
+ body.append(arm::pipe::CentreAlignFormatting(std::to_string(m_Model.m_Labels[i].m_Guid), 12));
body.append(" | ");
- body.append(profiling::CentreAlignFormatting(m_Model.m_Labels[i].m_Name, 30));
+ body.append(arm::pipe::CentreAlignFormatting(m_Model.m_Labels[i].m_Name, 30));
body.append("\n");
std::cout << std::string(body.size(), '-') << "\n";
@@ -197,11 +199,11 @@ void TimelineDecoder::printLabels()
void TimelineDecoder::printEntities()
{
std::string header;
- header.append(profiling::CentreAlignFormatting("guid", 12));
+ header.append(arm::pipe::CentreAlignFormatting("guid", 12));
header.append("\n");
std::cout << "\n" << "\n";
- std::cout << profiling::CentreAlignFormatting("ENTITIES", static_cast<int>(header.size()));
+ std::cout << arm::pipe::CentreAlignFormatting("ENTITIES", static_cast<int>(header.size()));
std::cout << "\n";
std::cout << std::string(header.size(), '=') << "\n";
std::cout << header;
@@ -210,7 +212,7 @@ void TimelineDecoder::printEntities()
{
std::string body;
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_Entities[i].m_Guid), 12));
+ body.append(arm::pipe::CentreAlignFormatting(std::to_string(m_Model.m_Entities[i].m_Guid), 12));
body.append("\n");
std::cout << std::string(body.size(), '-') << "\n";
@@ -221,11 +223,11 @@ void TimelineDecoder::printEntities()
void TimelineDecoder::printEventClasses()
{
std::string header;
- header.append(profiling::CentreAlignFormatting("guid", 12));
+ header.append(arm::pipe::CentreAlignFormatting("guid", 12));
header.append("\n");
std::cout << "\n" << "\n";
- std::cout << profiling::CentreAlignFormatting("EVENT CLASSES", static_cast<int>(header.size()));
+ std::cout << arm::pipe::CentreAlignFormatting("EVENT CLASSES", static_cast<int>(header.size()));
std::cout << "\n";
std::cout << std::string(header.size(), '=') << "\n";
std::cout << header;
@@ -234,7 +236,7 @@ void TimelineDecoder::printEventClasses()
{
std::string body;
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_EventClasses[i].m_Guid), 12));
+ body.append(arm::pipe::CentreAlignFormatting(std::to_string(m_Model.m_EventClasses[i].m_Guid), 12));
body.append("\n");
std::cout << std::string(body.size(), '-') << "\n";
@@ -246,15 +248,15 @@ void TimelineDecoder::printEvents()
{
std::string header;
- header.append(profiling::CentreAlignFormatting("timestamp", 12));
+ header.append(arm::pipe::CentreAlignFormatting("timestamp", 12));
header.append(" | ");
- header.append(profiling::CentreAlignFormatting("threadId", 12));
+ header.append(arm::pipe::CentreAlignFormatting("threadId", 12));
header.append(" | ");
- header.append(profiling::CentreAlignFormatting("eventGuid", 12));
+ header.append(arm::pipe::CentreAlignFormatting("eventGuid", 12));
header.append("\n");
std::cout << "\n" << "\n";
- std::cout << profiling::CentreAlignFormatting("EVENTS", static_cast<int>(header.size()));
+ std::cout << arm::pipe::CentreAlignFormatting("EVENTS", static_cast<int>(header.size()));
std::cout << "\n";
std::cout << std::string(header.size(), '=') << "\n";
std::cout << header;
@@ -263,16 +265,16 @@ void TimelineDecoder::printEvents()
{
std::string body;
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_Events[i].m_TimeStamp), 12));
+ body.append(arm::pipe::CentreAlignFormatting(std::to_string(m_Model.m_Events[i].m_TimeStamp), 12));
body.append(" | ");
std::stringstream ss;
ss << m_Model.m_Events[i].m_ThreadId;
std::string threadId = ss.str();;
- body.append(profiling::CentreAlignFormatting(threadId, 12));
+ body.append(arm::pipe::CentreAlignFormatting(threadId, 12));
body.append(" | ");
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_Events[i].m_Guid), 12));
+ body.append(arm::pipe::CentreAlignFormatting(std::to_string(m_Model.m_Events[i].m_Guid), 12));
body.append("\n");
std::cout << std::string(body.size(), '-') << "\n";
@@ -283,17 +285,17 @@ void TimelineDecoder::printEvents()
void TimelineDecoder::printRelationships()
{
std::string header;
- header.append(profiling::CentreAlignFormatting("relationshipType", 20));
+ header.append(arm::pipe::CentreAlignFormatting("relationshipType", 20));
header.append(" | ");
- header.append(profiling::CentreAlignFormatting("relationshipGuid", 20));
+ header.append(arm::pipe::CentreAlignFormatting("relationshipGuid", 20));
header.append(" | ");
- header.append(profiling::CentreAlignFormatting("headGuid", 12));
+ header.append(arm::pipe::CentreAlignFormatting("headGuid", 12));
header.append(" | ");
- header.append(profiling::CentreAlignFormatting("tailGuid", 12));
+ header.append(arm::pipe::CentreAlignFormatting("tailGuid", 12));
header.append("\n");
std::cout << "\n" << "\n";
- std::cout << profiling::CentreAlignFormatting("RELATIONSHIPS", static_cast<int>(header.size()));
+ std::cout << arm::pipe::CentreAlignFormatting("RELATIONSHIPS", static_cast<int>(header.size()));
std::cout << "\n";
std::cout << std::string(header.size(), '=') << "\n";
std::cout << header;
@@ -303,15 +305,15 @@ void TimelineDecoder::printRelationships()
std::string body;
body.append(
- profiling::CentreAlignFormatting(std::to_string(static_cast<unsigned int>
+ arm::pipe::CentreAlignFormatting(std::to_string(static_cast<unsigned int>
(m_Model.m_Relationships[i].m_RelationshipType)),
20));
body.append(" | ");
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_Relationships[i].m_Guid), 20));
+ body.append(arm::pipe::CentreAlignFormatting(std::to_string(m_Model.m_Relationships[i].m_Guid), 20));
body.append(" | ");
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_Relationships[i].m_HeadGuid), 12));
+ body.append(arm::pipe::CentreAlignFormatting(std::to_string(m_Model.m_Relationships[i].m_HeadGuid), 12));
body.append(" | ");
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_Relationships[i].m_TailGuid), 12));
+ body.append(arm::pipe::CentreAlignFormatting(std::to_string(m_Model.m_Relationships[i].m_TailGuid), 12));
body.append(" | ");
body.append("\n");
@@ -319,5 +321,6 @@ void TimelineDecoder::printRelationships()
std::cout << body;
}
}
-}
-} \ No newline at end of file
+
+} // namespace pipe
+} // namespace arm \ No newline at end of file
diff --git a/src/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp b/profiling/server/src/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp
index 5aac77c86a..6963dd00c7 100644
--- a/src/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp
+++ b/profiling/server/src/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp
@@ -3,21 +3,21 @@
// SPDX-License-Identifier: MIT
//
-#include "TimelineDirectoryCaptureCommandHandler.hpp"
-#include "TimelineCaptureCommandHandler.hpp"
+#include <common/include/CommonProfilingUtils.hpp>
+#include <common/include/SwTrace.hpp>
+#include <server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp>
+#include <server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp>
#include <iostream>
#include <string>
-using namespace armnn::profiling;
-
-namespace armnn
+namespace arm
{
-namespace timelinedecoder
+namespace pipe
{
-void TimelineDirectoryCaptureCommandHandler::ParseData(const armnn::profiling::Packet& packet)
+void TimelineDirectoryCaptureCommandHandler::ParseData(const arm::pipe::Packet& packet)
{
uint32_t offset = 0;
@@ -35,12 +35,12 @@ void TimelineDirectoryCaptureCommandHandler::ParseData(const armnn::profiling::P
m_SwTraceHeader.m_ThreadIdBytes = ReadUint8(data, offset);
offset += uint8_t_size;
- uint32_t numberOfDeclarations = profiling::ReadUint32(data, offset);
+ uint32_t numberOfDeclarations = arm::pipe::ReadUint32(data, offset);
offset += uint32_t_size;
for (uint32_t declaration = 0; declaration < numberOfDeclarations; ++declaration)
{
- m_SwTraceMessages.push_back(profiling::ReadSwTraceMessage(data, offset, packet.GetLength()));
+ m_SwTraceMessages.push_back(arm::pipe::ReadSwTraceMessage(data, offset, packet.GetLength()));
}
m_TimelineCaptureCommandHandler.SetThreadIdSize(m_SwTraceHeader.m_ThreadIdBytes);
@@ -50,19 +50,19 @@ void TimelineDirectoryCaptureCommandHandler::Print()
{
std::string header;
- header.append(profiling::CentreAlignFormatting("decl_id", 12));
+ header.append(arm::pipe::CentreAlignFormatting("decl_id", 12));
header.append(" | ");
- header.append(profiling::CentreAlignFormatting("decl_name", 20));
+ header.append(arm::pipe::CentreAlignFormatting("decl_name", 20));
header.append(" | ");
- header.append(profiling::CentreAlignFormatting("ui_name", 20));
+ header.append(arm::pipe::CentreAlignFormatting("ui_name", 20));
header.append(" | ");
- header.append(profiling::CentreAlignFormatting("arg_types", 16));
+ header.append(arm::pipe::CentreAlignFormatting("arg_types", 16));
header.append(" | ");
- header.append(profiling::CentreAlignFormatting("arg_names", 80));
+ header.append(arm::pipe::CentreAlignFormatting("arg_names", 80));
header.append("\n");
std::cout << "\n" << "\n";
- std::cout << profiling::CentreAlignFormatting("SW DIRECTORY", static_cast<int>(header.size()));
+ std::cout << arm::pipe::CentreAlignFormatting("SW DIRECTORY", static_cast<int>(header.size()));
std::cout << "\n";
std::cout << std::string(header.size(), '=') << "\n";
@@ -72,11 +72,11 @@ void TimelineDirectoryCaptureCommandHandler::Print()
{
std::string body;
- body.append(profiling::CentreAlignFormatting(std::to_string(swTraceMessage.m_Id), 12));
+ body.append(arm::pipe::CentreAlignFormatting(std::to_string(swTraceMessage.m_Id), 12));
body.append(" | ");
- body.append(profiling::CentreAlignFormatting(swTraceMessage.m_Name, 20));
+ body.append(arm::pipe::CentreAlignFormatting(swTraceMessage.m_Name, 20));
body.append(" | ");
- body.append(profiling::CentreAlignFormatting(swTraceMessage.m_UiName, 20));
+ body.append(arm::pipe::CentreAlignFormatting(swTraceMessage.m_UiName, 20));
body.append(" | ");
std::string argTypes;
@@ -85,7 +85,7 @@ void TimelineDirectoryCaptureCommandHandler::Print()
argTypes += argType;
argTypes += " ";
}
- body.append(profiling::CentreAlignFormatting(argTypes, 16));
+ body.append(arm::pipe::CentreAlignFormatting(argTypes, 16));
body.append(" | ");
std::string argNames;
@@ -93,7 +93,7 @@ void TimelineDirectoryCaptureCommandHandler::Print()
{
argNames += argName + " ";
}
- body.append(profiling::CentreAlignFormatting(argNames, 80));
+ body.append(arm::pipe::CentreAlignFormatting(argNames, 80));
body.append("\n");
@@ -103,7 +103,7 @@ void TimelineDirectoryCaptureCommandHandler::Print()
}
}
-void TimelineDirectoryCaptureCommandHandler::operator()(const profiling::Packet& packet)
+void TimelineDirectoryCaptureCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ParseData(packet);
@@ -113,6 +113,5 @@ void TimelineDirectoryCaptureCommandHandler::operator()(const profiling::Packet&
}
}
-} //namespace gatordmock
-
-} //namespace armnn
+} //namespace pipe
+} //namespace arm
diff --git a/src/timelineDecoder/tests/TimelineTests.cpp b/profiling/server/src/timelineDecoder/tests/TimelineTests.cpp
index ceb955d131..e7797061c9 100644
--- a/src/timelineDecoder/tests/TimelineTests.cpp
+++ b/profiling/server/src/timelineDecoder/tests/TimelineTests.cpp
@@ -3,11 +3,13 @@
// SPDX-License-Identifier: MIT
//
-#include <TimelineCaptureCommandHandler.hpp>
-#include <TimelineDirectoryCaptureCommandHandler.hpp>
-#include <TimelineDecoder.hpp>
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/CommonProfilingUtils.hpp>
+#include <server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp>
+#include <server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp>
+#include <server/include/timelineDecoder/TimelineDecoder.hpp>
-#include <CommandHandlerFunctor.hpp>
+#include <BufferManager.hpp>
#include <Threads.hpp>
#include <ProfilingService.hpp>
#include <PacketBuffer.hpp>
@@ -18,53 +20,51 @@
BOOST_AUTO_TEST_SUITE(TimelineDecoderTests)
-using namespace armnn;
-using namespace timelinedecoder;
-
void SendTimelinePacketToCommandHandler(const unsigned char* packetBuffer,
- profiling::CommandHandlerFunctor &CommandHandler)
+ arm::pipe::CommandHandlerFunctor& CommandHandler)
{
uint32_t uint32_t_size = sizeof(uint32_t);
unsigned int offset = 0;
uint32_t header[2];
- header[0] = profiling::ReadUint32(packetBuffer, offset);
+ header[0] = arm::pipe::ReadUint32(packetBuffer, offset);
offset += uint32_t_size;
- header[1] = profiling::ReadUint32(packetBuffer, offset);
+ header[1] = arm::pipe::ReadUint32(packetBuffer, offset);
offset += uint32_t_size;
uint32_t PacketDataLength = header[1] & 0x00FFFFFF;
auto uniquePacketData = std::make_unique<unsigned char[]>(PacketDataLength);
std::memcpy(uniquePacketData.get(), packetBuffer + offset, PacketDataLength);
- armnn::profiling::Packet packet(header[0], PacketDataLength, uniquePacketData);
+ arm::pipe::Packet packet(header[0], PacketDataLength, uniquePacketData);
BOOST_CHECK(std::memcmp(packetBuffer + offset, packet.GetData(), packet.GetLength()) == 0);
CommandHandler(packet);
}
-void PushEntity(TimelineDecoder::Model& model, const ITimelineDecoder::Entity entity)
+void PushEntity(arm::pipe::TimelineDecoder::Model& model, const arm::pipe::ITimelineDecoder::Entity entity)
{
model.m_Entities.emplace_back(entity);
}
-void PushEventClass(TimelineDecoder::Model& model, const ITimelineDecoder::EventClass eventClass)
+void PushEventClass(arm::pipe::TimelineDecoder::Model& model, const arm::pipe::ITimelineDecoder::EventClass eventClass)
{
model.m_EventClasses.emplace_back(eventClass);
}
-void PushEvent(TimelineDecoder::Model& model, const ITimelineDecoder::Event event)
+void PushEvent(arm::pipe::TimelineDecoder::Model& model, const arm::pipe::ITimelineDecoder::Event event)
{
model.m_Events.emplace_back(event);
}
-void PushLabel(TimelineDecoder::Model& model, const ITimelineDecoder::Label label)
+void PushLabel(arm::pipe::TimelineDecoder::Model& model, const arm::pipe::ITimelineDecoder::Label label)
{
model.m_Labels.emplace_back(label);
}
-void PushRelationship(TimelineDecoder::Model& model, const ITimelineDecoder::Relationship relationship)
+void PushRelationship(arm::pipe::TimelineDecoder::Model& model,
+ const arm::pipe::ITimelineDecoder::Relationship relationship)
{
model.m_Relationships.emplace_back(relationship);
}
@@ -75,30 +75,30 @@ BOOST_AUTO_TEST_CASE(TimelineDirectoryTest)
uint32_t uint32_t_size = sizeof(uint32_t);
uint32_t uint64_t_size = sizeof(uint64_t);
- profiling::BufferManager bufferManager(5);
- profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
+ armnn::profiling::BufferManager bufferManager(5);
+ armnn::profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
- std::unique_ptr<profiling::ISendTimelinePacket> sendTimelinePacket =
+ std::unique_ptr<armnn::profiling::ISendTimelinePacket> sendTimelinePacket =
timelinePacketWriterFactory.GetSendTimelinePacket();
- profiling::PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
- TimelineDecoder timelineDecoder;
- TimelineCaptureCommandHandler timelineCaptureCommandHandler(
+ arm::pipe::TimelineDecoder timelineDecoder;
+ arm::pipe::TimelineCaptureCommandHandler timelineCaptureCommandHandler(
1, 1, packetVersionResolver.ResolvePacketVersion(1, 1).GetEncodedValue(), timelineDecoder);
- TimelineDirectoryCaptureCommandHandler timelineDirectoryCaptureCommandHandler(
+ arm::pipe::TimelineDirectoryCaptureCommandHandler timelineDirectoryCaptureCommandHandler(
1, 0, packetVersionResolver.ResolvePacketVersion(1, 0).GetEncodedValue(),
timelineCaptureCommandHandler, true);
sendTimelinePacket->SendTimelineMessageDirectoryPackage();
sendTimelinePacket->Commit();
- std::vector<profiling::SwTraceMessage> swTraceBufferMessages;
+ std::vector<arm::pipe::SwTraceMessage> swTraceBufferMessages;
unsigned int offset = uint32_t_size * 2;
- std::unique_ptr<profiling::IPacketBuffer> packetBuffer = bufferManager.GetReadableBuffer();
+ std::unique_ptr<armnn::profiling::IPacketBuffer> packetBuffer = bufferManager.GetReadableBuffer();
uint8_t readStreamVersion = ReadUint8(packetBuffer, offset);
BOOST_CHECK(readStreamVersion == 4);
@@ -110,11 +110,11 @@ BOOST_AUTO_TEST_CASE(TimelineDirectoryTest)
BOOST_CHECK(readThreadIdBytes == armnn::profiling::ThreadIdSize);
offset += uint8_t_size;
- uint32_t declarationSize = profiling::ReadUint32(packetBuffer, offset);
+ uint32_t declarationSize = arm::pipe::ReadUint32(packetBuffer->GetReadableData(), offset);
offset += uint32_t_size;
for(uint32_t i = 0; i < declarationSize; ++i)
{
- swTraceBufferMessages.push_back(profiling::ReadSwTraceMessage(packetBuffer->GetReadableData(),
+ swTraceBufferMessages.push_back(arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(),
offset,
packetBuffer->GetSize()));
}
@@ -123,8 +123,8 @@ BOOST_AUTO_TEST_CASE(TimelineDirectoryTest)
for(uint32_t index = 0; index < declarationSize; ++index)
{
- profiling::SwTraceMessage& bufferMessage = swTraceBufferMessages[index];
- profiling::SwTraceMessage& handlerMessage = timelineDirectoryCaptureCommandHandler.m_SwTraceMessages[index];
+ arm::pipe::SwTraceMessage& bufferMessage = swTraceBufferMessages[index];
+ arm::pipe::SwTraceMessage& handlerMessage = timelineDirectoryCaptureCommandHandler.m_SwTraceMessages[index];
BOOST_CHECK(bufferMessage.m_Name == handlerMessage.m_Name);
BOOST_CHECK(bufferMessage.m_UiName == handlerMessage.m_UiName);
@@ -146,23 +146,23 @@ BOOST_AUTO_TEST_CASE(TimelineDirectoryTest)
BOOST_AUTO_TEST_CASE(TimelineCaptureTest)
{
- profiling::BufferManager bufferManager(50);
- profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
+ armnn::profiling::BufferManager bufferManager(50);
+ armnn::profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
- std::unique_ptr<profiling::ISendTimelinePacket> sendTimelinePacket =
+ std::unique_ptr<armnn::profiling::ISendTimelinePacket> sendTimelinePacket =
timelinePacketWriterFactory.GetSendTimelinePacket();
- profiling::PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
- TimelineDecoder timelineDecoder;
- const TimelineDecoder::Model& model = timelineDecoder.GetModel();
+ arm::pipe::TimelineDecoder timelineDecoder;
+ const arm::pipe::TimelineDecoder::Model& model = timelineDecoder.GetModel();
- TimelineCaptureCommandHandler timelineCaptureCommandHandler(
+ arm::pipe::TimelineCaptureCommandHandler timelineCaptureCommandHandler(
1, 1, packetVersionResolver.ResolvePacketVersion(1, 1).GetEncodedValue(), timelineDecoder,
armnn::profiling::ThreadIdSize);
- using Status = ITimelineDecoder::TimelineStatus;
+ using Status = arm::pipe::ITimelineDecoder::TimelineStatus;
BOOST_CHECK(timelineDecoder.SetEntityCallback(PushEntity) == Status::TimelineStatus_Success);
BOOST_CHECK(timelineDecoder.SetEventClassCallback(PushEventClass) == Status::TimelineStatus_Success);
BOOST_CHECK(timelineDecoder.SetEventCallback(PushEvent) == Status::TimelineStatus_Success);
@@ -181,15 +181,15 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTest)
unsigned char* uCharThreadId = new unsigned char[armnn::profiling::ThreadIdSize]();;
uint64_t uint64ThreadId;
- profiling::WriteBytes(uCharThreadId, 0, &threadId, armnn::profiling::ThreadIdSize);
+ arm::pipe::WriteBytes(uCharThreadId, 0, &threadId, armnn::profiling::ThreadIdSize);
if (armnn::profiling::ThreadIdSize == 4)
{
- uint64ThreadId = profiling::ReadUint32(uCharThreadId, 0);
+ uint64ThreadId = arm::pipe::ReadUint32(uCharThreadId, 0);
}
else if (armnn::profiling::ThreadIdSize == 8)
{
- uint64ThreadId = profiling::ReadUint64(uCharThreadId, 0);
+ uint64ThreadId = arm::pipe::ReadUint64(uCharThreadId, 0);
}
delete[] uCharThreadId;
@@ -227,7 +227,8 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTest)
timelineCaptureCommandHandler);
// Send relationship
- profiling::ProfilingRelationshipType relationshipType = profiling::ProfilingRelationshipType::DataLink;
+ armnn::profiling::ProfilingRelationshipType relationshipType =
+ armnn::profiling::ProfilingRelationshipType::DataLink;
sendTimelinePacket->SendTimelineRelationshipBinaryPacket(relationshipType,
relationshipGuid,
headGuid,
@@ -251,7 +252,8 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTest)
BOOST_CHECK(model.m_Labels[i].m_Guid == labelGuid);
BOOST_CHECK(model.m_Labels[i].m_Name == labelName);
- BOOST_CHECK(model.m_Relationships[i].m_RelationshipType == ITimelineDecoder::RelationshipType::DataLink);
+ BOOST_CHECK(model.m_Relationships[i].m_RelationshipType ==
+ arm::pipe::ITimelineDecoder::RelationshipType::DataLink);
BOOST_CHECK(model.m_Relationships[i].m_Guid == relationshipGuid);
BOOST_CHECK(model.m_Relationships[i].m_HeadGuid == headGuid);
BOOST_CHECK(model.m_Relationships[i].m_TailGuid == tailGuid);
@@ -260,22 +262,22 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTest)
BOOST_AUTO_TEST_CASE(TimelineCaptureTestMultipleStringsInBuffer)
{
- profiling::BufferManager bufferManager(50);
- profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
+ armnn::profiling::BufferManager bufferManager(50);
+ armnn::profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
- std::unique_ptr<profiling::ISendTimelinePacket> sendTimelinePacket =
+ std::unique_ptr<armnn::profiling::ISendTimelinePacket> sendTimelinePacket =
timelinePacketWriterFactory.GetSendTimelinePacket();
- profiling::PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
- TimelineDecoder timelineDecoder;
- const TimelineDecoder::Model& model = timelineDecoder.GetModel();
+ arm::pipe::TimelineDecoder timelineDecoder;
+ const arm::pipe::TimelineDecoder::Model& model = timelineDecoder.GetModel();
- TimelineCaptureCommandHandler timelineCaptureCommandHandler(
+ arm::pipe::TimelineCaptureCommandHandler timelineCaptureCommandHandler(
1, 1, packetVersionResolver.ResolvePacketVersion(1, 1).GetEncodedValue(), timelineDecoder,
armnn::profiling::ThreadIdSize);
- using Status = ITimelineDecoder::TimelineStatus;
+ using Status = arm::pipe::TimelineDecoder::TimelineStatus;
BOOST_CHECK(timelineDecoder.SetEntityCallback(PushEntity) == Status::TimelineStatus_Success);
BOOST_CHECK(timelineDecoder.SetEventClassCallback(PushEventClass) == Status::TimelineStatus_Success);
BOOST_CHECK(timelineDecoder.SetEventCallback(PushEvent) == Status::TimelineStatus_Success);
@@ -294,15 +296,15 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTestMultipleStringsInBuffer)
unsigned char* uCharThreadId = new unsigned char[armnn::profiling::ThreadIdSize]();
uint64_t uint64ThreadId;
- profiling::WriteBytes(uCharThreadId, 0, &threadId, armnn::profiling::ThreadIdSize);
+ arm::pipe::WriteBytes(uCharThreadId, 0, &threadId, armnn::profiling::ThreadIdSize);
if ( armnn::profiling::ThreadIdSize == 4 )
{
- uint64ThreadId = profiling::ReadUint32(uCharThreadId, 0);
+ uint64ThreadId = arm::pipe::ReadUint32(uCharThreadId, 0);
}
else if ( armnn::profiling::ThreadIdSize == 8 )
{
- uint64ThreadId = profiling::ReadUint64(uCharThreadId, 0);
+ uint64ThreadId = arm::pipe::ReadUint64(uCharThreadId, 0);
}
delete[] uCharThreadId;
@@ -329,7 +331,8 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTestMultipleStringsInBuffer)
sendTimelinePacket->SendTimelineLabelBinaryPacket(labelGuid, labelName2);
sendTimelinePacket->SendTimelineLabelBinaryPacket(labelGuid, labelName3);
// Send relationship
- profiling::ProfilingRelationshipType relationshipType = profiling::ProfilingRelationshipType::DataLink;
+ armnn::profiling::ProfilingRelationshipType relationshipType =
+ armnn::profiling::ProfilingRelationshipType::DataLink;
sendTimelinePacket->SendTimelineRelationshipBinaryPacket(relationshipType,
relationshipGuid,
headGuid,
@@ -353,7 +356,8 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTestMultipleStringsInBuffer)
BOOST_CHECK(model.m_Events[i].m_ThreadId == uint64ThreadId);
BOOST_CHECK(model.m_Events[i].m_Guid == eventGuid);
- BOOST_CHECK(model.m_Relationships[i].m_RelationshipType == ITimelineDecoder::RelationshipType::DataLink);
+ BOOST_CHECK(model.m_Relationships[i].m_RelationshipType ==
+ arm::pipe::ITimelineDecoder::RelationshipType::DataLink);
BOOST_CHECK(model.m_Relationships[i].m_Guid == relationshipGuid);
BOOST_CHECK(model.m_Relationships[i].m_HeadGuid == headGuid);
BOOST_CHECK(model.m_Relationships[i].m_TailGuid == tailGuid);
diff --git a/profiling/toolchain-x86-ubuntu-mingw64.cmake b/profiling/toolchain-x86-ubuntu-mingw64.cmake
new file mode 100644
index 0000000000..2d9e49f0c3
--- /dev/null
+++ b/profiling/toolchain-x86-ubuntu-mingw64.cmake
@@ -0,0 +1,28 @@
+#
+# Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+# SPDX-License-Identifier: MIT
+#
+
+# toolchain file for building for Windows on an Ubuntu Linux system.
+#
+# Typical usage:
+# *) install cross compiler: `sudo apt-get install mingw-w64`
+# *) cmake -DCMAKE_TOOLCHAIN_FILE=~/toolchain-x86-ubuntu-mingw64.cmake
+
+set(CMAKE_SYSTEM_NAME Windows)
+set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
+
+# cross compilers to use for C and C++
+set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
+set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
+
+# target environment on the build host system
+# set 1st to dir with the cross compiler's C/C++ headers/libs
+set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
+
+# modify default behavior of FIND_XXX() commands to
+# search for headers/libs in the target environment and
+# search for programs in the build host environment
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/src/armnn/Logging.cpp b/src/armnn/Logging.cpp
index 6db4afaf49..8b46a77b79 100644
--- a/src/armnn/Logging.cpp
+++ b/src/armnn/Logging.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -9,7 +9,7 @@
#include <armnn/utility/Assert.hpp>
#if defined(_MSC_VER)
-#include <WindowsWrapper.hpp>
+#include <commons/include/WindowsWrapper.hpp>
#endif
#if defined(__ANDROID__)
diff --git a/src/armnn/test/UnitTests.cpp b/src/armnn/test/UnitTests.cpp
index 300eddf6e3..5d9211e44f 100644
--- a/src/armnn/test/UnitTests.cpp
+++ b/src/armnn/test/UnitTests.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#define BOOST_TEST_MODULE UnitTests
@@ -24,7 +24,7 @@ BOOST_GLOBAL_FIXTURE(ConfigureLoggingFixture);
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/tee.hpp>
#include <iostream>
-#include <WindowsWrapper.hpp>
+#include <commons/include/WindowsWrapper.hpp>
using namespace boost::iostreams;
using namespace std;
diff --git a/src/armnn/test/UnitTests.hpp b/src/armnn/test/UnitTests.hpp
index f7c49a5c2a..2d9c1583d2 100644
--- a/src/armnn/test/UnitTests.hpp
+++ b/src/armnn/test/UnitTests.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
diff --git a/src/armnnUtils/Processes.cpp b/src/armnnUtils/Processes.cpp
index 41b035b887..eb68dd9dff 100644
--- a/src/armnnUtils/Processes.cpp
+++ b/src/armnnUtils/Processes.cpp
@@ -8,7 +8,7 @@
#if defined(__unix__) || defined(__APPLE__)
#include <unistd.h>
#elif defined(_MSC_VER)
-#include "WindowsWrapper.hpp"
+#include <commons/include/WindowsWrapper.hpp>
#endif
namespace armnnUtils
diff --git a/src/armnnUtils/Threads.cpp b/src/armnnUtils/Threads.cpp
index 0ca1adf0c3..3ee8174d01 100644
--- a/src/armnnUtils/Threads.cpp
+++ b/src/armnnUtils/Threads.cpp
@@ -10,7 +10,7 @@
#include <sys/syscall.h>
#define gettid() syscall(SYS_gettid)
#elif defined(_MSC_VER)
-#include "WindowsWrapper.hpp"
+#include <commons/include/WindowsWrapper.hpp>
#elif defined(__APPLE__)
#include "AvailabilityMacros.h"
#include <sys/syscall.h>
diff --git a/src/backends/backendsCommon/test/BackendProfilingTests.cpp b/src/backends/backendsCommon/test/BackendProfilingTests.cpp
index 306c0240df..8434536ca0 100644
--- a/src/backends/backendsCommon/test/BackendProfilingTests.cpp
+++ b/src/backends/backendsCommon/test/BackendProfilingTests.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -93,7 +93,7 @@ private:
std::vector<Timestamp> m_timestamps;
};
-Packet PacketWriter(uint32_t period, std::vector<uint16_t> countervalues)
+arm::pipe::Packet PacketWriter(uint32_t period, std::vector<uint16_t> countervalues)
{
const uint32_t packetId = 0x40000;
uint32_t offset = 0;
@@ -140,7 +140,7 @@ BOOST_AUTO_TEST_CASE(BackendProfilingCounterRegisterMockBackendTest)
BOOST_AUTO_TEST_CASE(TestBackendCounters)
{
Holder holder;
- PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
ProfilingStateMachine stateMachine;
ReadCounterVals readCounterVals;
CounterIdMap counterIdMap;
@@ -387,7 +387,7 @@ BOOST_AUTO_TEST_CASE(TestBackendCounterLogging)
};
Holder holder;
- PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
ProfilingStateMachine stateMachine;
ReadCounterVals readCounterVals;
StreamRedirector redirect(std::cout, ss.rdbuf());
diff --git a/src/profiling/ActivateTimelineReportingCommandHandler.cpp b/src/profiling/ActivateTimelineReportingCommandHandler.cpp
index d762efc277..614417c6de 100644
--- a/src/profiling/ActivateTimelineReportingCommandHandler.cpp
+++ b/src/profiling/ActivateTimelineReportingCommandHandler.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -15,7 +15,7 @@ namespace armnn
namespace profiling
{
-void ActivateTimelineReportingCommandHandler::operator()(const Packet& packet)
+void ActivateTimelineReportingCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ProfilingState currentState = m_StateMachine.GetCurrentState();
diff --git a/src/profiling/ActivateTimelineReportingCommandHandler.hpp b/src/profiling/ActivateTimelineReportingCommandHandler.hpp
index ff0e840170..a40115084b 100644
--- a/src/profiling/ActivateTimelineReportingCommandHandler.hpp
+++ b/src/profiling/ActivateTimelineReportingCommandHandler.hpp
@@ -1,11 +1,10 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include "CommandHandlerFunctor.hpp"
#include "ProfilingStateMachine.hpp"
#include "SendTimelinePacket.hpp"
#include "IReportStructure.hpp"
@@ -13,7 +12,8 @@
#include "armnn/Optional.hpp"
-#include <Packet.hpp>
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
namespace armnn
@@ -22,7 +22,7 @@ namespace armnn
namespace profiling
{
-class ActivateTimelineReportingCommandHandler : public CommandHandlerFunctor
+class ActivateTimelineReportingCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
ActivateTimelineReportingCommandHandler(uint32_t familyId,
@@ -41,7 +41,7 @@ public:
m_ReportStructure(reportStructure)
{}
- void operator()(const Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
private:
SendTimelinePacket& m_SendTimelinePacket;
diff --git a/src/profiling/CommandHandler.cpp b/src/profiling/CommandHandler.cpp
index cae7037327..9f536445e9 100644
--- a/src/profiling/CommandHandler.cpp
+++ b/src/profiling/CommandHandler.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -47,7 +47,7 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection)
{
try
{
- Packet packet = profilingConnection.ReadPacket(m_Timeout.load());
+ arm::pipe::Packet packet = profilingConnection.ReadPacket(m_Timeout.load());
if (packet.IsEmpty())
{
@@ -55,12 +55,12 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection)
continue;
}
- Version version = m_PacketVersionResolver.ResolvePacketVersion(packet.GetPacketFamily(),
- packet.GetPacketId());
+ arm::pipe::Version version = m_PacketVersionResolver.ResolvePacketVersion(packet.GetPacketFamily(),
+ packet.GetPacketId());
- CommandHandlerFunctor* commandHandlerFunctor =
- m_CommandHandlerRegistry.GetFunctor(packet.GetPacketFamily(),
- packet.GetPacketId(),
+ arm::pipe::CommandHandlerFunctor* commandHandlerFunctor =
+ m_CommandHandlerRegistry.GetFunctor(packet.GetPacketFamily(),
+ packet.GetPacketId(),
version.GetEncodedValue());
ARMNN_ASSERT(commandHandlerFunctor);
commandHandlerFunctor->operator()(packet);
@@ -72,6 +72,19 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection)
m_KeepRunning.store(false);
}
}
+ catch (const arm::pipe::ProfilingException& e)
+ {
+ // Log the error and continue
+ ARMNN_LOG(warning) << "An error has occurred when handling a command: " << e.what();
+ // Did we get here because the socket failed?
+ if ( !profilingConnection.IsOpen() )
+ {
+ // We're going to stop processing commands.
+ // This will leave the thread idle. There is no mechanism to restart the profiling service when the
+ // connection is lost.
+ m_KeepRunning.store(false);
+ }
+ }
catch (const Exception& e)
{
// Log the error and continue
diff --git a/src/profiling/CommandHandler.hpp b/src/profiling/CommandHandler.hpp
index 4bf820c5db..b2c9725a34 100644
--- a/src/profiling/CommandHandler.hpp
+++ b/src/profiling/CommandHandler.hpp
@@ -1,13 +1,14 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include "CommandHandlerRegistry.hpp"
#include "IProfilingConnection.hpp"
-#include "PacketVersionResolver.hpp"
+#include <common/include/PacketVersionResolver.hpp>
+
+#include <common/include/CommandHandlerRegistry.hpp>
#include <atomic>
#include <thread>
@@ -23,8 +24,8 @@ class CommandHandler
public:
CommandHandler(uint32_t timeout,
bool stopAfterTimeout,
- CommandHandlerRegistry& commandHandlerRegistry,
- PacketVersionResolver& packetVersionResolver)
+ arm::pipe::CommandHandlerRegistry& commandHandlerRegistry,
+ arm::pipe::PacketVersionResolver& packetVersionResolver)
: m_Timeout(timeout),
m_StopAfterTimeout(stopAfterTimeout),
m_IsRunning(false),
@@ -51,8 +52,8 @@ private:
std::atomic<bool> m_KeepRunning;
std::thread m_CommandThread;
- CommandHandlerRegistry& m_CommandHandlerRegistry;
- PacketVersionResolver& m_PacketVersionResolver;
+ arm::pipe::CommandHandlerRegistry& m_CommandHandlerRegistry;
+ arm::pipe::PacketVersionResolver& m_PacketVersionResolver;
};
} // namespace profiling
diff --git a/src/profiling/ConnectionAcknowledgedCommandHandler.cpp b/src/profiling/ConnectionAcknowledgedCommandHandler.cpp
index ce2a36f9fb..7fa3785a43 100644
--- a/src/profiling/ConnectionAcknowledgedCommandHandler.cpp
+++ b/src/profiling/ConnectionAcknowledgedCommandHandler.cpp
@@ -16,7 +16,7 @@ namespace armnn
namespace profiling
{
-void ConnectionAcknowledgedCommandHandler::operator()(const Packet& packet)
+void ConnectionAcknowledgedCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ProfilingState currentState = m_StateMachine.GetCurrentState();
switch (currentState)
diff --git a/src/profiling/ConnectionAcknowledgedCommandHandler.hpp b/src/profiling/ConnectionAcknowledgedCommandHandler.hpp
index f65b23f457..0906f7f9f3 100644
--- a/src/profiling/ConnectionAcknowledgedCommandHandler.hpp
+++ b/src/profiling/ConnectionAcknowledgedCommandHandler.hpp
@@ -6,20 +6,21 @@
#pragma once
#include <armnn/backends/profiling/IBackendProfilingContext.hpp>
-#include "CommandHandlerFunctor.hpp"
#include "IProfilingServiceStatus.hpp"
#include "ISendCounterPacket.hpp"
#include "armnn/profiling/ISendTimelinePacket.hpp"
-#include <Packet.hpp>
#include "ProfilingStateMachine.hpp"
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
+
namespace armnn
{
namespace profiling
{
-class ConnectionAcknowledgedCommandHandler final : public CommandHandlerFunctor
+class ConnectionAcknowledgedCommandHandler final : public arm::pipe::CommandHandlerFunctor
{
typedef const std::unordered_map<BackendId, std::shared_ptr<armnn::profiling::IBackendProfilingContext>>&
@@ -44,7 +45,7 @@ public:
, m_BackendProfilingContext(backendProfilingContexts)
{}
- void operator()(const Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
void setTimelineEnabled(bool timelineEnabled)
{
diff --git a/src/profiling/CounterDirectory.cpp b/src/profiling/CounterDirectory.cpp
index ae1c49796c..e6356b82bd 100644
--- a/src/profiling/CounterDirectory.cpp
+++ b/src/profiling/CounterDirectory.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -7,10 +7,11 @@
#include "ProfilingUtils.hpp"
#include <armnn/Exceptions.hpp>
-#include <armnn/Conversion.hpp>
#include <armnn/utility/Assert.hpp>
#include <armnn/utility/IgnoreUnused.hpp>
+#include <common/include/SwTrace.hpp>
+
#include <boost/format.hpp>
namespace armnn
@@ -23,7 +24,7 @@ const Category* CounterDirectory::RegisterCategory(const std::string& categoryNa
{
// Check that the given category name is valid
if (categoryName.empty() ||
- !IsValidSwTraceString<SwTraceNameCharPolicy>(categoryName))
+ !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(categoryName))
{
throw InvalidArgumentException("Trying to register a category with an invalid name");
}
@@ -56,7 +57,7 @@ const Device* CounterDirectory::RegisterDevice(const std::string& deviceName,
{
// Check that the given device name is valid
if (deviceName.empty() ||
- !IsValidSwTraceString<SwTraceCharPolicy>(deviceName))
+ !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(deviceName))
{
throw InvalidArgumentException("Trying to register a device with an invalid name");
}
@@ -118,7 +119,7 @@ const CounterSet* CounterDirectory::RegisterCounterSet(const std::string& counte
{
// Check that the given counter set name is valid
if (counterSetName.empty() ||
- !IsValidSwTraceString<SwTraceNameCharPolicy>(counterSetName))
+ !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(counterSetName))
{
throw InvalidArgumentException("Trying to register a counter set with an invalid name");
}
@@ -196,7 +197,7 @@ const Counter* CounterDirectory::RegisterCounter(const BackendId& backendId,
// Check that the given parent category name is valid
if (parentCategoryName.empty() ||
- !IsValidSwTraceString<SwTraceNameCharPolicy>(parentCategoryName))
+ !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(parentCategoryName))
{
throw InvalidArgumentException("Trying to register a counter with an invalid parent category name");
}
@@ -221,21 +222,21 @@ const Counter* CounterDirectory::RegisterCounter(const BackendId& backendId,
// Check that the given name is valid
if (name.empty() ||
- !IsValidSwTraceString<SwTraceCharPolicy>(name))
+ !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(name))
{
throw InvalidArgumentException("Trying to register a counter with an invalid name");
}
// Check that the given description is valid
if (description.empty() ||
- !IsValidSwTraceString<SwTraceCharPolicy>(description))
+ !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(description))
{
throw InvalidArgumentException("Trying to register a counter with an invalid description");
}
// Check that the given units are valid
if (units.has_value()
- && !IsValidSwTraceString<SwTraceNameCharPolicy>(units.value()))
+ && !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(units.value()))
{
throw InvalidArgumentException("Trying to register a counter with a invalid units");
}
diff --git a/src/profiling/CounterDirectory.hpp b/src/profiling/CounterDirectory.hpp
index 6a73a76a0d..a6e788ee1f 100644
--- a/src/profiling/CounterDirectory.hpp
+++ b/src/profiling/CounterDirectory.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -12,7 +12,7 @@
#include <unordered_set>
#include <unordered_map>
-#include <boost/numeric/conversion/cast.hpp>
+#include <armnn/utility/NumericCast.hpp>
namespace armnn
{
@@ -48,10 +48,10 @@ public:
const Optional<uint16_t>& counterSetUid = EmptyOptional()) override;
// Getters for counts
- uint16_t GetCategoryCount() const override { return boost::numeric_cast<uint16_t>(m_Categories.size()); }
- uint16_t GetDeviceCount() const override { return boost::numeric_cast<uint16_t>(m_Devices.size()); }
- uint16_t GetCounterSetCount() const override { return boost::numeric_cast<uint16_t>(m_CounterSets.size()); }
- uint16_t GetCounterCount() const override { return boost::numeric_cast<uint16_t>(m_Counters.size()); }
+ uint16_t GetCategoryCount() const override { return armnn::numeric_cast<uint16_t>(m_Categories.size()); }
+ uint16_t GetDeviceCount() const override { return armnn::numeric_cast<uint16_t>(m_Devices.size()); }
+ uint16_t GetCounterSetCount() const override { return armnn::numeric_cast<uint16_t>(m_CounterSets.size()); }
+ uint16_t GetCounterCount() const override { return armnn::numeric_cast<uint16_t>(m_Counters.size()); }
// Getters for collections
const Categories& GetCategories() const override { return m_Categories; }
diff --git a/src/profiling/DeactivateTimelineReportingCommandHandler.cpp b/src/profiling/DeactivateTimelineReportingCommandHandler.cpp
index dbfb053b3d..bdee83b1c0 100644
--- a/src/profiling/DeactivateTimelineReportingCommandHandler.cpp
+++ b/src/profiling/DeactivateTimelineReportingCommandHandler.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -15,7 +15,7 @@ namespace armnn
namespace profiling
{
-void DeactivateTimelineReportingCommandHandler::operator()(const Packet& packet)
+void DeactivateTimelineReportingCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ProfilingState currentState = m_StateMachine.GetCurrentState();
diff --git a/src/profiling/DeactivateTimelineReportingCommandHandler.hpp b/src/profiling/DeactivateTimelineReportingCommandHandler.hpp
index e9d2180699..822e92c425 100644
--- a/src/profiling/DeactivateTimelineReportingCommandHandler.hpp
+++ b/src/profiling/DeactivateTimelineReportingCommandHandler.hpp
@@ -1,22 +1,23 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include "CommandHandlerFunctor.hpp"
-#include <Packet.hpp>
#include "ProfilingStateMachine.hpp"
#include "INotifyBackends.hpp"
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
+
namespace armnn
{
namespace profiling
{
-class DeactivateTimelineReportingCommandHandler : public CommandHandlerFunctor
+class DeactivateTimelineReportingCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
@@ -32,7 +33,7 @@ public:
, m_BackendNotifier(notifyBackends)
{}
- void operator()(const Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
private:
std::atomic<bool>& m_TimelineReporting;
diff --git a/src/profiling/DirectoryCaptureCommandHandler.cpp b/src/profiling/DirectoryCaptureCommandHandler.cpp
index e20f5402c6..60463a10c3 100644
--- a/src/profiling/DirectoryCaptureCommandHandler.cpp
+++ b/src/profiling/DirectoryCaptureCommandHandler.cpp
@@ -1,7 +1,8 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
+
#include "DirectoryCaptureCommandHandler.hpp"
#include <armnn/BackendId.hpp>
@@ -20,7 +21,7 @@ namespace profiling
uint32_t uint16_t_size = sizeof(uint16_t);
uint32_t uint32_t_size = sizeof(uint32_t);
-void DirectoryCaptureCommandHandler::ParseData(const armnn::profiling::Packet& packet)
+void DirectoryCaptureCommandHandler::ParseData(const arm::pipe::Packet& packet)
{
uint16_t categoryRecordCount;
uint16_t counterSetRecordCount;
@@ -296,7 +297,7 @@ std::vector<CounterDirectoryEventRecord> DirectoryCaptureCommandHandler::ReadEve
return eventRecords;
}
-void DirectoryCaptureCommandHandler::operator()(const profiling::Packet& packet)
+void DirectoryCaptureCommandHandler::operator()(const arm::pipe::Packet& packet)
{
if (!m_QuietOperation) // Are we supposed to print to stdout?
{
diff --git a/src/profiling/DirectoryCaptureCommandHandler.hpp b/src/profiling/DirectoryCaptureCommandHandler.hpp
index 6b25714168..90ae1d400d 100644
--- a/src/profiling/DirectoryCaptureCommandHandler.hpp
+++ b/src/profiling/DirectoryCaptureCommandHandler.hpp
@@ -1,13 +1,14 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include "CommandHandlerFunctor.hpp"
#include "CounterDirectory.hpp"
+#include <common/include/CommandHandlerFunctor.hpp>
+
#include <atomic>
namespace armnn
@@ -30,7 +31,7 @@ struct CounterDirectoryEventRecord
uint16_t m_MaxCounterUid;
};
-class DirectoryCaptureCommandHandler : public profiling::CommandHandlerFunctor
+class DirectoryCaptureCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
@@ -40,7 +41,7 @@ public:
, m_AlreadyParsed(false)
{}
- void operator()(const armnn::profiling::Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
const ICounterDirectory& GetCounterDirectory() const;
@@ -61,7 +62,7 @@ public:
}
private:
- void ParseData(const armnn::profiling::Packet& packet);
+ void ParseData(const arm::pipe::Packet& packet);
void ReadCategoryRecords(const unsigned char* data, uint32_t offset, std::vector<uint32_t> categoryOffsets);
diff --git a/src/profiling/FileOnlyProfilingConnection.cpp b/src/profiling/FileOnlyProfilingConnection.cpp
index 1e26aaa472..24f2cc7ede 100644
--- a/src/profiling/FileOnlyProfilingConnection.cpp
+++ b/src/profiling/FileOnlyProfilingConnection.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -28,30 +28,30 @@ std::vector<uint32_t> StreamMetaDataProcessor::GetHeadersAccepted()
return headers;
}
-void StreamMetaDataProcessor::HandlePacket(const Packet& packet)
+void StreamMetaDataProcessor::HandlePacket(const arm::pipe::Packet& packet)
{
if (packet.GetHeader() != m_MetaDataPacketHeader)
{
- throw armnnProfiling::ProfilingException("StreamMetaDataProcessor can only handle Stream Meta Data Packets");
+ throw arm::pipe::ProfilingException("StreamMetaDataProcessor can only handle Stream Meta Data Packets");
}
// determine the endianness of the protocol
TargetEndianness endianness;
- if (ToUint32(packet.GetData(),TargetEndianness::BeWire) == armnnProfiling::PIPE_MAGIC)
+ if (ToUint32(packet.GetData(),TargetEndianness::BeWire) == arm::pipe::PIPE_MAGIC)
{
endianness = TargetEndianness::BeWire;
}
- else if (ToUint32(packet.GetData(), TargetEndianness::LeWire) == armnnProfiling::PIPE_MAGIC)
+ else if (ToUint32(packet.GetData(), TargetEndianness::LeWire) == arm::pipe::PIPE_MAGIC)
{
endianness = TargetEndianness::LeWire;
}
else
{
- throw armnnProfiling::ProfilingException("Protocol read error. Unable to read PIPE_MAGIC value.");
+ throw arm::pipe::ProfilingException("Protocol read error. Unable to read the PIPE_MAGIC value.");
}
m_FileOnlyProfilingConnection->SetEndianess(endianness);
// send back the acknowledgement
std::unique_ptr<unsigned char[]> uniqueNullPtr = nullptr;
- Packet returnPacket(0x10000, 0, uniqueNullPtr);
+ arm::pipe::Packet returnPacket(0x10000, 0, uniqueNullPtr);
m_FileOnlyProfilingConnection->ReturnPacket(returnPacket);
}
@@ -110,12 +110,12 @@ void FileOnlyProfilingConnection::Close()
bool FileOnlyProfilingConnection::WritePacket(const unsigned char* buffer, uint32_t length)
{
ARMNN_ASSERT(buffer);
- Packet packet = ReceivePacket(buffer, length);
+ arm::pipe::Packet packet = ReceivePacket(buffer, length);
ForwardPacketToHandlers(packet);
return true;
}
-void FileOnlyProfilingConnection::ReturnPacket(Packet& packet)
+void FileOnlyProfilingConnection::ReturnPacket(arm::pipe::Packet& packet)
{
{
std::lock_guard<std::mutex> lck(m_PacketAvailableMutex);
@@ -124,7 +124,7 @@ void FileOnlyProfilingConnection::ReturnPacket(Packet& packet)
m_ConditionPacketAvailable.notify_one();
}
-Packet FileOnlyProfilingConnection::ReadPacket(uint32_t timeout)
+arm::pipe::Packet FileOnlyProfilingConnection::ReadPacket(uint32_t timeout)
{
std::unique_lock<std::mutex> lck(m_PacketAvailableMutex);
@@ -134,11 +134,11 @@ Packet FileOnlyProfilingConnection::ReadPacket(uint32_t timeout)
std::chrono::milliseconds(timeout),
[&]{return !m_PacketQueue.empty();}))
{
- Packet empty;
+ arm::pipe::Packet empty;
return empty;
}
- Packet returnedPacket = std::move(m_PacketQueue.front());
+ arm::pipe::Packet returnedPacket = std::move(m_PacketQueue.front());
m_PacketQueue.pop();
return returnedPacket;
}
@@ -199,7 +199,7 @@ void FileOnlyProfilingConnection::StartProcessingThread()
m_LocalHandlersThread = std::thread(&FileOnlyProfilingConnection::ServiceLocalHandlers, this);
}
-void FileOnlyProfilingConnection::ForwardPacketToHandlers(Packet& packet)
+void FileOnlyProfilingConnection::ForwardPacketToHandlers(arm::pipe::Packet& packet)
{
if (m_PacketHandlers.empty())
{
@@ -224,7 +224,7 @@ void FileOnlyProfilingConnection::ServiceLocalHandlers()
{
do
{
- Packet returnedPacket;
+ arm::pipe::Packet returnedPacket;
bool readPacket = false;
{ // only lock while we are taking the packet off the incoming list
std::unique_lock<std::mutex> lck(m_ReadableMutex);
@@ -273,7 +273,7 @@ void FileOnlyProfilingConnection::ClearReadableList()
}
}
-void FileOnlyProfilingConnection::DispatchPacketToHandlers(const Packet& packet)
+void FileOnlyProfilingConnection::DispatchPacketToHandlers(const arm::pipe::Packet& packet)
{
for (auto& delegate : m_UniversalHandlers)
{
@@ -288,7 +288,7 @@ void FileOnlyProfilingConnection::DispatchPacketToHandlers(const Packet& packet)
{
delegate->HandlePacket(packet);
}
- catch (const armnnProfiling::ProfilingException& ex)
+ catch (const arm::pipe::ProfilingException& ex)
{
Fail(ex.what());
}
diff --git a/src/profiling/FileOnlyProfilingConnection.hpp b/src/profiling/FileOnlyProfilingConnection.hpp
index b19b983ebc..8bde0abdea 100644
--- a/src/profiling/FileOnlyProfilingConnection.hpp
+++ b/src/profiling/FileOnlyProfilingConnection.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -8,10 +8,11 @@
#include <armnn/profiling/ILocalPacketHandler.hpp>
#include "DirectoryCaptureCommandHandler.hpp"
#include "IProfilingConnection.hpp"
-#include <Packet.hpp>
#include "ProfilingUtils.hpp"
#include "Runtime.hpp"
+#include <common/include/Packet.hpp>
+
#include <atomic>
#include <condition_variable>
#include <fstream>
@@ -37,7 +38,7 @@ public:
std::vector<uint32_t> GetHeadersAccepted() override;
- void HandlePacket(const Packet& packet) override;
+ void HandlePacket(const arm::pipe::Packet& packet) override;
private:
FileOnlyProfilingConnection* m_FileOnlyProfilingConnection;
@@ -82,28 +83,28 @@ public:
bool WritePacket(const unsigned char* buffer, uint32_t length) override;
// Sending a packet back to ArmNN.
- Packet ReadPacket(uint32_t timeout) override;
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override;
void SetEndianess(const TargetEndianness& endianness) override //IInternalProfilingConnection
{
m_Endianness = endianness;
}
- void ReturnPacket(Packet& packet) override; //IInternalProfilingConnection
+ void ReturnPacket(arm::pipe::Packet& packet) override; //IInternalProfilingConnection
private:
void AddLocalPacketHandler(ILocalPacketHandlerSharedPtr localPacketHandler);
void StartProcessingThread();
void ClearReadableList();
- void DispatchPacketToHandlers(const Packet& packet);
+ void DispatchPacketToHandlers(const arm::pipe::Packet& packet);
void Fail(const std::string& errorMessage);
- void ForwardPacketToHandlers(Packet& packet);
+ void ForwardPacketToHandlers(arm::pipe::Packet& packet);
void ServiceLocalHandlers();
Runtime::CreationOptions::ExternalProfilingOptions m_Options;
- std::queue<Packet> m_PacketQueue;
+ std::queue<arm::pipe::Packet> m_PacketQueue;
TargetEndianness m_Endianness;
std::mutex m_PacketAvailableMutex;
@@ -114,7 +115,7 @@ private:
std::vector<ILocalPacketHandlerSharedPtr> m_UniversalHandlers;
// List of readable packets for the local packet handlers
- std::queue<Packet> m_ReadableList;
+ std::queue<arm::pipe::Packet> m_ReadableList;
// Mutex and condition variable for the readable packet list
std::mutex m_ReadableMutex;
std::condition_variable m_ConditionPacketReadable;
diff --git a/src/profiling/IProfilingConnection.hpp b/src/profiling/IProfilingConnection.hpp
index cf45a43ef3..7ed714c1a3 100644
--- a/src/profiling/IProfilingConnection.hpp
+++ b/src/profiling/IProfilingConnection.hpp
@@ -5,9 +5,10 @@
#pragma once
-#include <Packet.hpp>
#include <armnn/profiling/ILocalPacketHandler.hpp>
+#include <common/include/Packet.hpp>
+
#include <cstdint>
namespace armnn
@@ -27,7 +28,7 @@ public:
virtual bool WritePacket(const unsigned char* buffer, uint32_t length) = 0;
- virtual Packet ReadPacket(uint32_t timeout) = 0;
+ virtual arm::pipe::Packet ReadPacket(uint32_t timeout) = 0;
};
} // namespace profiling
diff --git a/src/profiling/PerJobCounterSelectionCommandHandler.cpp b/src/profiling/PerJobCounterSelectionCommandHandler.cpp
index 8892e1457d..fea8ee3e5b 100644
--- a/src/profiling/PerJobCounterSelectionCommandHandler.cpp
+++ b/src/profiling/PerJobCounterSelectionCommandHandler.cpp
@@ -1,9 +1,10 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "PerJobCounterSelectionCommandHandler.hpp"
+#include <armnn/Exceptions.hpp>
#include <boost/format.hpp>
@@ -13,7 +14,7 @@ namespace armnn
namespace profiling
{
-void PerJobCounterSelectionCommandHandler::operator()(const Packet& packet)
+void PerJobCounterSelectionCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ProfilingState currentState = m_StateMachine.GetCurrentState();
switch (currentState)
@@ -21,9 +22,9 @@ void PerJobCounterSelectionCommandHandler::operator()(const Packet& packet)
case ProfilingState::Uninitialised:
case ProfilingState::NotConnected:
case ProfilingState::WaitingForAck:
- throw RuntimeException(boost::str(boost::format("Per-Job Counter Selection Command Handler invoked while in "
- "an wrong state: %1%")
- % GetProfilingStateName(currentState)));
+ throw armnn::RuntimeException(boost::str(boost::format(
+ "Per-Job Counter Selection Command Handler invoked while in an incorrect state: %1%")
+ % GetProfilingStateName(currentState)));
case ProfilingState::Active:
// Process the packet
if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 5u))
@@ -38,8 +39,8 @@ void PerJobCounterSelectionCommandHandler::operator()(const Packet& packet)
break;
default:
- throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1%")
- % static_cast<int>(currentState)));
+ throw armnn::RuntimeException(boost::str(boost::format("Unknown profiling service state: %1%")
+ % static_cast<int>(currentState)));
}
}
diff --git a/src/profiling/PerJobCounterSelectionCommandHandler.hpp b/src/profiling/PerJobCounterSelectionCommandHandler.hpp
index daf10c6d95..eef8421900 100644
--- a/src/profiling/PerJobCounterSelectionCommandHandler.hpp
+++ b/src/profiling/PerJobCounterSelectionCommandHandler.hpp
@@ -1,21 +1,22 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include <Packet.hpp>
-#include "CommandHandlerFunctor.hpp"
#include "ProfilingStateMachine.hpp"
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
+
namespace armnn
{
namespace profiling
{
-class PerJobCounterSelectionCommandHandler : public CommandHandlerFunctor
+class PerJobCounterSelectionCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
@@ -27,7 +28,7 @@ public:
, m_StateMachine(profilingStateMachine)
{}
- void operator()(const Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
private:
const ProfilingStateMachine& m_StateMachine;
diff --git a/src/profiling/PeriodicCounterSelectionCommandHandler.cpp b/src/profiling/PeriodicCounterSelectionCommandHandler.cpp
index bd4fa0691c..1b10643fca 100644
--- a/src/profiling/PeriodicCounterSelectionCommandHandler.cpp
+++ b/src/profiling/PeriodicCounterSelectionCommandHandler.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -18,7 +18,7 @@ namespace armnn
namespace profiling
{
-void PeriodicCounterSelectionCommandHandler::ParseData(const Packet& packet, CaptureData& captureData)
+void PeriodicCounterSelectionCommandHandler::ParseData(const arm::pipe::Packet& packet, CaptureData& captureData)
{
std::vector<uint16_t> counterIds;
uint32_t sizeOfUint32 = boost::numeric_cast<uint32_t>(sizeof(uint32_t));
@@ -56,7 +56,7 @@ void PeriodicCounterSelectionCommandHandler::ParseData(const Packet& packet, Cap
captureData.SetCounterIds(counterIds);
}
-void PeriodicCounterSelectionCommandHandler::operator()(const Packet& packet)
+void PeriodicCounterSelectionCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ProfilingState currentState = m_StateMachine.GetCurrentState();
switch (currentState)
diff --git a/src/profiling/PeriodicCounterSelectionCommandHandler.hpp b/src/profiling/PeriodicCounterSelectionCommandHandler.hpp
index ac08cc58ec..ec67391b9c 100644
--- a/src/profiling/PeriodicCounterSelectionCommandHandler.hpp
+++ b/src/profiling/PeriodicCounterSelectionCommandHandler.hpp
@@ -1,13 +1,11 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include "CounterIdMap.hpp"
-#include <Packet.hpp>
-#include "CommandHandlerFunctor.hpp"
#include "Holder.hpp"
#include "ProfilingStateMachine.hpp"
#include "SendCounterPacket.hpp"
@@ -18,8 +16,10 @@
#include "armnn/Logging.hpp"
#include "armnn/BackendRegistry.hpp"
-#include <set>
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
+#include <set>
namespace armnn
{
@@ -28,7 +28,7 @@ namespace profiling
{
-class PeriodicCounterSelectionCommandHandler : public CommandHandlerFunctor
+class PeriodicCounterSelectionCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
@@ -60,7 +60,7 @@ public:
}
- void operator()(const Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
private:
@@ -90,7 +90,7 @@ private:
<< errorMsg.value();
}
}
- void ParseData(const Packet& packet, CaptureData& captureData);
+ void ParseData(const arm::pipe::Packet& packet, CaptureData& captureData);
std::set<armnn::BackendId> ProcessBackendCounterIds(const uint32_t capturePeriod,
const std::set<uint16_t> newCounterIds,
const std::set<uint16_t> unusedCounterIds);
diff --git a/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp b/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp
index d61911b54e..5768566178 100644
--- a/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp
+++ b/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -61,9 +61,9 @@ bool ProfilingConnectionDumpToFileDecorator::WritePacket(const unsigned char* bu
return success;
}
-Packet ProfilingConnectionDumpToFileDecorator::ReadPacket(uint32_t timeout)
+arm::pipe::Packet ProfilingConnectionDumpToFileDecorator::ReadPacket(uint32_t timeout)
{
- Packet packet = m_Connection->ReadPacket(timeout);
+ arm::pipe::Packet packet = m_Connection->ReadPacket(timeout);
if (!m_Options.m_IncomingCaptureFile.empty())
{
DumpIncomingToFile(packet);
@@ -90,7 +90,7 @@ bool ProfilingConnectionDumpToFileDecorator::OpenOutgoingDumpFile()
/// to write the data into the specified file.
/// @param packet data packet to write
/// @return nothing
-void ProfilingConnectionDumpToFileDecorator::DumpIncomingToFile(const Packet& packet)
+void ProfilingConnectionDumpToFileDecorator::DumpIncomingToFile(const arm::pipe::Packet& packet)
{
bool success = true;
if (!m_IncomingDumpFileStream.is_open())
diff --git a/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp b/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp
index 545c57f728..aedb28571e 100644
--- a/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp
+++ b/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -38,14 +38,14 @@ public:
bool WritePacket(const unsigned char* buffer, uint32_t length) override;
- Packet ReadPacket(uint32_t timeout) override;
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override;
private:
bool OpenIncomingDumpFile();
bool OpenOutgoingDumpFile();
- void DumpIncomingToFile(const Packet& packet);
+ void DumpIncomingToFile(const arm::pipe::Packet& packet);
bool DumpOutgoingToFile(const unsigned char* buffer, uint32_t length);
diff --git a/src/profiling/ProfilingConnectionFactory.cpp b/src/profiling/ProfilingConnectionFactory.cpp
index 7849b7e21e..96f7ed4b06 100644
--- a/src/profiling/ProfilingConnectionFactory.cpp
+++ b/src/profiling/ProfilingConnectionFactory.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/src/profiling/ProfilingConnectionFactory.hpp b/src/profiling/ProfilingConnectionFactory.hpp
index c6d4c6faf0..fa8b32f703 100644
--- a/src/profiling/ProfilingConnectionFactory.hpp
+++ b/src/profiling/ProfilingConnectionFactory.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp
index 8532c3efad..b673993846 100644
--- a/src/profiling/ProfilingService.cpp
+++ b/src/profiling/ProfilingService.cpp
@@ -148,7 +148,7 @@ void ProfilingService::Update()
ARMNN_LOG(warning) << "An error has occurred when creating the profiling connection: "
<< e.what();
}
- catch (const armnnProfiling::SocketConnectionException& e)
+ catch (const arm::pipe::SocketConnectionException& e)
{
ARMNN_LOG(warning) << "An error has occurred when creating the profiling connection ["
<< e.what() << "] on socket [" << e.GetSocketFd() << "].";
diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp
index 247b945813..1bc7c59808 100644
--- a/src/profiling/ProfilingService.hpp
+++ b/src/profiling/ProfilingService.hpp
@@ -31,6 +31,8 @@
#include "INotifyBackends.hpp"
#include <armnn/backends/profiling/IBackendProfilingContext.hpp>
+#include <list>
+
namespace armnn
{
@@ -236,22 +238,22 @@ private:
void CheckCounterUid(uint16_t counterUid) const;
// Profiling service components
- ExternalProfilingOptions m_Options;
- std::atomic<bool> m_TimelineReporting;
- CounterDirectory m_CounterDirectory;
- CounterIdMap m_CounterIdMap;
- IProfilingConnectionFactoryPtr m_ProfilingConnectionFactory;
- IProfilingConnectionPtr m_ProfilingConnection;
- ProfilingStateMachine m_StateMachine;
- CounterIndices m_CounterIndex;
- CounterValues m_CounterValues;
- CommandHandlerRegistry m_CommandHandlerRegistry;
- PacketVersionResolver m_PacketVersionResolver;
- CommandHandler m_CommandHandler;
- BufferManager m_BufferManager;
- SendCounterPacket m_SendCounterPacket;
- SendThread m_SendThread;
- SendTimelinePacket m_SendTimelinePacket;
+ ExternalProfilingOptions m_Options;
+ std::atomic<bool> m_TimelineReporting;
+ CounterDirectory m_CounterDirectory;
+ CounterIdMap m_CounterIdMap;
+ IProfilingConnectionFactoryPtr m_ProfilingConnectionFactory;
+ IProfilingConnectionPtr m_ProfilingConnection;
+ ProfilingStateMachine m_StateMachine;
+ CounterIndices m_CounterIndex;
+ CounterValues m_CounterValues;
+ arm::pipe::CommandHandlerRegistry m_CommandHandlerRegistry;
+ arm::pipe::PacketVersionResolver m_PacketVersionResolver;
+ CommandHandler m_CommandHandler;
+ BufferManager m_BufferManager;
+ SendCounterPacket m_SendCounterPacket;
+ SendThread m_SendThread;
+ SendTimelinePacket m_SendTimelinePacket;
Holder m_Holder;
diff --git a/src/profiling/ProfilingUtils.cpp b/src/profiling/ProfilingUtils.cpp
index 8c43a8cd3a..4767f3e746 100644
--- a/src/profiling/ProfilingUtils.cpp
+++ b/src/profiling/ProfilingUtils.cpp
@@ -5,7 +5,9 @@
#include "ProfilingUtils.hpp"
-#include "common/include/ProfilingException.hpp"
+#include <common/include/CommonProfilingUtils.hpp>
+#include <common/include/ProfilingException.hpp>
+#include <common/include/SwTrace.hpp>
#include <armnn/Version.hpp>
@@ -139,52 +141,27 @@ void WriteUint8(const IPacketBufferPtr& packetBuffer, unsigned int offset, uint8
void WriteBytes(unsigned char* buffer, unsigned int offset, const void* value, unsigned int valueSize)
{
- ARMNN_ASSERT(buffer);
- ARMNN_ASSERT(value);
-
- for (unsigned int i = 0; i < valueSize; i++, offset++)
- {
- buffer[offset] = *(reinterpret_cast<const unsigned char*>(value) + i);
- }
+ arm::pipe::WriteBytes(buffer, offset, value, valueSize);
}
void WriteUint64(unsigned char* buffer, unsigned int offset, uint64_t value)
{
- ARMNN_ASSERT(buffer);
-
- buffer[offset] = static_cast<unsigned char>(value & 0xFF);
- buffer[offset + 1] = static_cast<unsigned char>((value >> 8) & 0xFF);
- buffer[offset + 2] = static_cast<unsigned char>((value >> 16) & 0xFF);
- buffer[offset + 3] = static_cast<unsigned char>((value >> 24) & 0xFF);
- buffer[offset + 4] = static_cast<unsigned char>((value >> 32) & 0xFF);
- buffer[offset + 5] = static_cast<unsigned char>((value >> 40) & 0xFF);
- buffer[offset + 6] = static_cast<unsigned char>((value >> 48) & 0xFF);
- buffer[offset + 7] = static_cast<unsigned char>((value >> 56) & 0xFF);
+ arm::pipe::WriteUint64(buffer, offset, value);
}
void WriteUint32(unsigned char* buffer, unsigned int offset, uint32_t value)
{
- ARMNN_ASSERT(buffer);
-
- buffer[offset] = static_cast<unsigned char>(value & 0xFF);
- buffer[offset + 1] = static_cast<unsigned char>((value >> 8) & 0xFF);
- buffer[offset + 2] = static_cast<unsigned char>((value >> 16) & 0xFF);
- buffer[offset + 3] = static_cast<unsigned char>((value >> 24) & 0xFF);
+ arm::pipe::WriteUint32(buffer, offset, value);
}
void WriteUint16(unsigned char* buffer, unsigned int offset, uint16_t value)
{
- ARMNN_ASSERT(buffer);
-
- buffer[offset] = static_cast<unsigned char>(value & 0xFF);
- buffer[offset + 1] = static_cast<unsigned char>((value >> 8) & 0xFF);
+ arm::pipe::WriteUint16(buffer, offset, value);
}
void WriteUint8(unsigned char* buffer, unsigned int offset, uint8_t value)
{
- ARMNN_ASSERT(buffer);
-
- buffer[offset] = static_cast<unsigned char>(value);
+ arm::pipe::WriteUint8(buffer, offset, value);
}
void ReadBytes(const IPacketBufferPtr& packetBuffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
@@ -224,59 +201,27 @@ uint8_t ReadUint8(const IPacketBufferPtr& packetBuffer, unsigned int offset)
void ReadBytes(const unsigned char* buffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
{
- ARMNN_ASSERT(buffer);
- ARMNN_ASSERT(outValue);
-
- for (unsigned int i = 0; i < valueSize; i++, offset++)
- {
- outValue[i] = static_cast<uint8_t>(buffer[offset]);
- }
+ arm::pipe::ReadBytes(buffer, offset, valueSize, outValue);
}
uint64_t ReadUint64(const unsigned char* buffer, unsigned int offset)
{
- ARMNN_ASSERT(buffer);
-
- uint64_t value = 0;
- value = static_cast<uint64_t>(buffer[offset]);
- value |= static_cast<uint64_t>(buffer[offset + 1]) << 8;
- value |= static_cast<uint64_t>(buffer[offset + 2]) << 16;
- value |= static_cast<uint64_t>(buffer[offset + 3]) << 24;
- value |= static_cast<uint64_t>(buffer[offset + 4]) << 32;
- value |= static_cast<uint64_t>(buffer[offset + 5]) << 40;
- value |= static_cast<uint64_t>(buffer[offset + 6]) << 48;
- value |= static_cast<uint64_t>(buffer[offset + 7]) << 56;
-
- return value;
+ return arm::pipe::ReadUint64(buffer, offset);
}
uint32_t ReadUint32(const unsigned char* buffer, unsigned int offset)
{
- ARMNN_ASSERT(buffer);
-
- uint32_t value = 0;
- value = static_cast<uint32_t>(buffer[offset]);
- value |= static_cast<uint32_t>(buffer[offset + 1]) << 8;
- value |= static_cast<uint32_t>(buffer[offset + 2]) << 16;
- value |= static_cast<uint32_t>(buffer[offset + 3]) << 24;
- return value;
+ return arm::pipe::ReadUint32(buffer, offset);
}
uint16_t ReadUint16(const unsigned char* buffer, unsigned int offset)
{
- ARMNN_ASSERT(buffer);
-
- uint32_t value = 0;
- value = static_cast<uint32_t>(buffer[offset]);
- value |= static_cast<uint32_t>(buffer[offset + 1]) << 8;
- return static_cast<uint16_t>(value);
+ return arm::pipe::ReadUint16(buffer, offset);
}
uint8_t ReadUint8(const unsigned char* buffer, unsigned int offset)
{
- ARMNN_ASSERT(buffer);
-
- return buffer[offset];
+ return arm::pipe::ReadUint8(buffer, offset);
}
std::string GetSoftwareInfo()
@@ -303,113 +248,6 @@ std::string GetProcessName()
return name;
}
-// Calculate the actual length an SwString will be including the terminating null character
-// padding to bring it to the next uint32_t boundary but minus the leading uint32_t encoding
-// the size to allow the offset to be correctly updated when decoding a binary packet.
-uint32_t CalculateSizeOfPaddedSwString(const std::string& str)
-{
- std::vector<uint32_t> swTraceString;
- StringToSwTraceString<SwTraceCharPolicy>(str, swTraceString);
- unsigned int uint32_t_size = sizeof(uint32_t);
- uint32_t size = (boost::numeric_cast<uint32_t>(swTraceString.size()) - 1) * uint32_t_size;
- return size;
-}
-
-// Read TimelineMessageDirectoryPacket from given IPacketBuffer and offset
-SwTraceMessage ReadSwTraceMessage(const unsigned char* packetBuffer,
- unsigned int& offset,
- const unsigned int& packetLength)
-{
- ARMNN_ASSERT(packetBuffer);
-
- unsigned int uint32_t_size = sizeof(uint32_t);
-
- SwTraceMessage swTraceMessage;
-
- // Read the decl_id
- uint32_t readDeclId = ReadUint32(packetBuffer, offset);
- swTraceMessage.m_Id = readDeclId;
-
- // SWTrace "namestring" format
- // length of the string (first 4 bytes) + string + null terminator
-
- // Check the decl_name
- offset += uint32_t_size;
- uint32_t swTraceDeclNameLength = ReadUint32(packetBuffer, offset);
-
- if (swTraceDeclNameLength == 0 || swTraceDeclNameLength > packetLength)
- {
- throw RuntimeException("Error swTraceDeclNameLength is an invalid size", CHECK_LOCATION());
- }
-
- offset += uint32_t_size;
- std::vector<unsigned char> swTraceStringBuffer(swTraceDeclNameLength - 1);
- std::memcpy(swTraceStringBuffer.data(),
- packetBuffer + offset, swTraceStringBuffer.size());
-
- swTraceMessage.m_Name.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end()); // name
-
- // Check the ui_name
- offset += CalculateSizeOfPaddedSwString(swTraceMessage.m_Name);
- uint32_t swTraceUINameLength = ReadUint32(packetBuffer, offset);
-
- if (swTraceUINameLength == 0 || swTraceUINameLength > packetLength)
- {
- throw RuntimeException("Error swTraceUINameLength is an invalid size", CHECK_LOCATION());
- }
-
- offset += uint32_t_size;
- swTraceStringBuffer.resize(swTraceUINameLength - 1);
- std::memcpy(swTraceStringBuffer.data(),
- packetBuffer + offset, swTraceStringBuffer.size());
-
- swTraceMessage.m_UiName.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end()); // ui_name
-
- // Check arg_types
- offset += CalculateSizeOfPaddedSwString(swTraceMessage.m_UiName);
- uint32_t swTraceArgTypesLength = ReadUint32(packetBuffer, offset);
-
- if (swTraceArgTypesLength == 0 || swTraceArgTypesLength > packetLength)
- {
- throw RuntimeException("Error swTraceArgTypesLength is an invalid size", CHECK_LOCATION());
- }
-
- offset += uint32_t_size;
- swTraceStringBuffer.resize(swTraceArgTypesLength - 1);
- std::memcpy(swTraceStringBuffer.data(),
- packetBuffer + offset, swTraceStringBuffer.size());
-
- swTraceMessage.m_ArgTypes.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end()); // arg_types
-
- std::string swTraceString(swTraceStringBuffer.begin(), swTraceStringBuffer.end());
-
- // Check arg_names
- offset += CalculateSizeOfPaddedSwString(swTraceString);
- uint32_t swTraceArgNamesLength = ReadUint32(packetBuffer, offset);
-
- if (swTraceArgNamesLength == 0 || swTraceArgNamesLength > packetLength)
- {
- throw RuntimeException("Error swTraceArgNamesLength is an invalid size", CHECK_LOCATION());
- }
-
- offset += uint32_t_size;
- swTraceStringBuffer.resize(swTraceArgNamesLength - 1);
- std::memcpy(swTraceStringBuffer.data(),
- packetBuffer + offset, swTraceStringBuffer.size());
-
- swTraceString.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end());
- std::stringstream stringStream(swTraceString);
- std::string argName;
- while (std::getline(stringStream, argName, ','))
- {
- swTraceMessage.m_ArgNames.push_back(argName);
- }
-
- offset += CalculateSizeOfPaddedSwString(swTraceString);
-
- return swTraceMessage;
-}
-
/// Creates a timeline packet header
///
/// \params
@@ -493,7 +331,7 @@ TimelinePacketStatus WriteTimelineLabelBinaryPacket(uint64_t profilingGuid,
// Convert the label into a SWTrace string
std::vector<uint32_t> swTraceLabel;
- bool result = StringToSwTraceString<SwTraceCharPolicy>(label, swTraceLabel);
+ bool result = arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(label, swTraceLabel);
if (!result)
{
return TimelinePacketStatus::Error;
@@ -712,10 +550,14 @@ TimelinePacketStatus WriteTimelineMessageDirectoryPackage(unsigned char* buffer,
swTraceBuffer.push_back(declId);
bool result = true;
- result &= ConvertDirectoryComponent<SwTraceNameCharPolicy>(directoryComponent[1], swTraceBuffer); // decl_name
- result &= ConvertDirectoryComponent<SwTraceCharPolicy> (directoryComponent[2], swTraceBuffer); // ui_name
- result &= ConvertDirectoryComponent<SwTraceTypeCharPolicy>(directoryComponent[3], swTraceBuffer); // arg_types
- result &= ConvertDirectoryComponent<SwTraceCharPolicy> (directoryComponent[4], swTraceBuffer); // arg_names
+ result &= arm::pipe::ConvertDirectoryComponent<arm::pipe::SwTraceNameCharPolicy>(
+ directoryComponent[1], swTraceBuffer); // decl_name
+ result &= arm::pipe::ConvertDirectoryComponent<arm::pipe::SwTraceCharPolicy> (
+ directoryComponent[2], swTraceBuffer); // ui_name
+ result &= arm::pipe::ConvertDirectoryComponent<arm::pipe::SwTraceTypeCharPolicy>(
+ directoryComponent[3], swTraceBuffer); // arg_types
+ result &= arm::pipe::ConvertDirectoryComponent<arm::pipe::SwTraceCharPolicy> (
+ directoryComponent[4], swTraceBuffer); // arg_names
if (!result)
{
return TimelinePacketStatus::Error;
@@ -884,22 +726,7 @@ TimelinePacketStatus WriteTimelineEventBinary(uint64_t timestamp,
std::string CentreAlignFormatting(const std::string& stringToPass, const int spacingWidth)
{
- std::stringstream outputStream, centrePadding;
- int padding = spacingWidth - static_cast<int>(stringToPass.size());
-
- for (int i = 0; i < padding / 2; ++i)
- {
- centrePadding << " ";
- }
-
- outputStream << centrePadding.str() << stringToPass << centrePadding.str();
-
- if (padding > 0 && padding %2 != 0)
- {
- outputStream << " ";
- }
-
- return outputStream.str();
+ return arm::pipe::CentreAlignFormatting(stringToPass, spacingWidth);
}
void PrintDeviceDetails(const std::pair<const unsigned short, std::unique_ptr<Device>>& devicePair)
@@ -1088,15 +915,15 @@ uint64_t GetTimestamp()
return static_cast<uint64_t>(timestamp.count());
}
-Packet ReceivePacket(const unsigned char* buffer, uint32_t length)
+arm::pipe::Packet ReceivePacket(const unsigned char* buffer, uint32_t length)
{
if (buffer == nullptr)
{
- throw armnnProfiling::ProfilingException("data buffer is nullptr");
+ throw arm::pipe::ProfilingException("data buffer is nullptr");
}
if (length < 8)
{
- throw armnnProfiling::ProfilingException("length of data buffer is less than 8");
+ throw arm::pipe::ProfilingException("length of data buffer is less than 8");
}
uint32_t metadataIdentifier = 0;
@@ -1112,7 +939,7 @@ Packet ReceivePacket(const unsigned char* buffer, uint32_t length)
std::memcpy(packetData.get(), buffer + 8u, dataLength);
}
- return Packet(metadataIdentifier, dataLength, packetData);
+ return arm::pipe::Packet(metadataIdentifier, dataLength, packetData);
}
} // namespace profiling
diff --git a/src/profiling/ProfilingUtils.hpp b/src/profiling/ProfilingUtils.hpp
index 833b73d963..79fa6c7bb0 100644
--- a/src/profiling/ProfilingUtils.hpp
+++ b/src/profiling/ProfilingUtils.hpp
@@ -11,7 +11,7 @@
#include "ICounterDirectory.hpp"
#include "IPacketBuffer.hpp"
-#include <Packet.hpp>
+#include <common/include/Packet.hpp>
#include <boost/numeric/conversion/cast.hpp>
@@ -30,118 +30,6 @@ namespace profiling
constexpr unsigned int ThreadIdSize = sizeof(int); // Is platform dependent
-struct SwTraceHeader
-{
- uint8_t m_StreamVersion;
- uint8_t m_PointerBytes;
- uint8_t m_ThreadIdBytes;
-};
-
-struct SwTraceMessage
-{
- uint32_t m_Id;
- std::string m_Name;
- std::string m_UiName;
- std::vector<char> m_ArgTypes;
- std::vector<std::string> m_ArgNames;
-};
-
-struct SwTraceCharPolicy
-{
- static bool IsValidChar(unsigned char c)
- {
- // Check that the given character has ASCII 7-bit encoding
- return c < 128;
- }
-};
-
-struct SwTraceNameCharPolicy
-{
- static bool IsValidChar(unsigned char c)
- {
- // Check that the given character has ASCII 7-bit encoding, alpha-numeric and underscore only
- return c < 128 && (std::isalnum(c) || c == '_');
- }
-};
-
-struct SwTraceTypeCharPolicy
-{
- static bool IsValidChar(unsigned char c)
- {
- // Check that the given character is among the allowed ones
- switch (c)
- {
- case '@':
- case 't':
- case 'i':
- case 'I':
- case 'l':
- case 'L':
- case 'F':
- case 'p':
- case 's':
- return true; // Valid char
- default:
- return false; // Invalid char
- }
- }
-};
-
-template <typename SwTracePolicy>
-bool IsValidSwTraceString(const std::string& s)
-{
- // Check that all the characters in the given string conform to the given policy
- return std::all_of(s.begin(), s.end(), [](unsigned char c) { return SwTracePolicy::IsValidChar(c); });
-}
-
-template <typename SwTracePolicy>
-bool StringToSwTraceString(const std::string& s, std::vector<uint32_t>& outputBuffer)
-{
- // Converts the given string to an SWTrace "string" (i.e. a string of "chars"), and writes it into
- // the given buffer including the null-terminator. It also pads it to the next uint32_t if necessary
-
- // Clear the output buffer
- outputBuffer.clear();
-
- // Check that the given string is a valid SWTrace "string" (i.e. a string of "chars")
- if (!IsValidSwTraceString<SwTracePolicy>(s))
- {
- return false;
- }
-
- // Prepare the output buffer
- size_t s_size = s.size() + 1; // The size of the string (in chars) plus the null-terminator
- size_t uint32_t_size = sizeof(uint32_t);
- // Output buffer size = StringLength (32 bit) + amount of complete 32bit words that fit into the string
- // + an additional 32bit word if there are remaining chars to complete the string
- // (The rest of the 32bit word is then filled with the NULL terminator)
- size_t outBufferSize = 1 + (s_size / uint32_t_size) + (s_size % uint32_t_size != 0 ? 1 : 0);
- outputBuffer.resize(outBufferSize, '\0');
-
- // Write the SWTrace string to the output buffer
- outputBuffer[0] = boost::numeric_cast<uint32_t>(s_size);
- std::memcpy(outputBuffer.data() + 1, s.data(), s_size);
-
- return true;
-}
-
-template <typename SwTracePolicy,
- typename SwTraceBuffer = std::vector<uint32_t>>
-bool ConvertDirectoryComponent(const std::string& directoryComponent, SwTraceBuffer& swTraceBuffer)
-{
- // Convert the directory component using the given policy
- SwTraceBuffer tempSwTraceBuffer;
- bool result = StringToSwTraceString<SwTracePolicy>(directoryComponent, tempSwTraceBuffer);
- if (!result)
- {
- return false;
- }
-
- swTraceBuffer.insert(swTraceBuffer.end(), tempSwTraceBuffer.begin(), tempSwTraceBuffer.end());
-
- return true;
-}
-
uint16_t GetNextUid(bool peekOnly = false);
std::vector<uint16_t> GetNextCounterUids(uint16_t firstUid, uint16_t cores);
@@ -212,10 +100,6 @@ enum class TimelinePacketStatus
BufferExhaustion
};
-uint32_t CalculateSizeOfPaddedSwString(const std::string& str);
-
-SwTraceMessage ReadSwTraceMessage(const unsigned char*, unsigned int&, const unsigned int& packetLength);
-
TimelinePacketStatus WriteTimelineLabelBinaryPacket(uint64_t profilingGuid,
const std::string& label,
unsigned char* buffer,
@@ -264,7 +148,7 @@ class BufferExhaustion : public armnn::Exception
uint64_t GetTimestamp();
-Packet ReceivePacket(const unsigned char* buffer, uint32_t length);
+arm::pipe::Packet ReceivePacket(const unsigned char* buffer, uint32_t length);
} // namespace profiling
diff --git a/src/profiling/RequestCounterDirectoryCommandHandler.cpp b/src/profiling/RequestCounterDirectoryCommandHandler.cpp
index 5521a25f20..8f78ae63f0 100644
--- a/src/profiling/RequestCounterDirectoryCommandHandler.cpp
+++ b/src/profiling/RequestCounterDirectoryCommandHandler.cpp
@@ -13,7 +13,7 @@ namespace armnn
namespace profiling
{
-void RequestCounterDirectoryCommandHandler::operator()(const Packet& packet)
+void RequestCounterDirectoryCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ProfilingState currentState = m_StateMachine.GetCurrentState();
switch (currentState)
diff --git a/src/profiling/RequestCounterDirectoryCommandHandler.hpp b/src/profiling/RequestCounterDirectoryCommandHandler.hpp
index d8ce881ffb..18577b2851 100644
--- a/src/profiling/RequestCounterDirectoryCommandHandler.hpp
+++ b/src/profiling/RequestCounterDirectoryCommandHandler.hpp
@@ -5,19 +5,20 @@
#pragma once
-#include "CommandHandlerFunctor.hpp"
#include "ISendCounterPacket.hpp"
#include "armnn/profiling/ISendTimelinePacket.hpp"
-#include <Packet.hpp>
#include "ProfilingStateMachine.hpp"
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
+
namespace armnn
{
namespace profiling
{
-class RequestCounterDirectoryCommandHandler : public CommandHandlerFunctor
+class RequestCounterDirectoryCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
@@ -35,7 +36,7 @@ public:
, m_StateMachine(profilingStateMachine)
{}
- void operator()(const Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
private:
const ICounterDirectory& m_CounterDirectory;
diff --git a/src/profiling/SendCounterPacket.cpp b/src/profiling/SendCounterPacket.cpp
index 2182ce6d39..79123f0c5e 100644
--- a/src/profiling/SendCounterPacket.cpp
+++ b/src/profiling/SendCounterPacket.cpp
@@ -4,13 +4,14 @@
//
#include "SendCounterPacket.hpp"
-#include "EncodeVersion.hpp"
+#include <common/include/EncodeVersion.hpp>
#include <armnn/Exceptions.hpp>
#include <armnn/Conversion.hpp>
#include <Processes.hpp>
#include <armnn/utility/Assert.hpp>
#include <common/include/Constants.hpp>
+#include <common/include/SwTrace.hpp>
#include <boost/format.hpp>
#include <boost/numeric/conversion/cast.hpp>
@@ -61,19 +62,19 @@ void SendCounterPacket::SendStreamMetaDataPacket()
// Timeline Message Directory (packet_family = 1, packet_class = 0, packet_type = 0) Version 1.0.0
// Timeline Message (packet_family = 1, packet_class = 0, packet_type = 1) Version 1.0.0
std::vector<std::pair<uint32_t, uint32_t>> packetVersions;
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 1), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 2), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 3), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 4), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 5), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 6), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 7), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(3, 0, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 1), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 1), EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 0), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 1), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 2), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 3), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 4), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 5), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 6), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 7), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(3, 0, 0), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 0), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 1), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 0), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 1), arm::pipe::EncodeVersion(1, 0, 0)));
uint32_t numberOfVersions = numeric_cast<uint32_t>(packetVersions.size());
uint32_t packetVersionSize = numeric_cast<uint32_t>(numberOfVersions * 2 * sizeUint32);
@@ -104,9 +105,9 @@ void SendCounterPacket::SendStreamMetaDataPacket()
// Packet body
offset += sizeUint32;
- WriteUint32(writeBuffer, offset, armnnProfiling::PIPE_MAGIC); // pipe_magic
+ WriteUint32(writeBuffer, offset, arm::pipe::PIPE_MAGIC); // pipe_magic
offset += sizeUint32;
- WriteUint32(writeBuffer, offset, EncodeVersion(1, 0, 0)); // stream_metadata_version
+ WriteUint32(writeBuffer, offset, arm::pipe::EncodeVersion(1, 0, 0)); // stream_metadata_version
offset += sizeUint32;
WriteUint32(writeBuffer, offset, MAX_METADATA_PACKET_LENGTH); // max_data_length
offset += sizeUint32;
@@ -213,7 +214,7 @@ bool SendCounterPacket::CreateCategoryRecord(const CategoryPtr& category,
// Convert the device name into a SWTrace namestring
std::vector<uint32_t> categoryNameBuffer;
- if (!StringToSwTraceString<SwTraceNameCharPolicy>(categoryName, categoryNameBuffer))
+ if (!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>(categoryName, categoryNameBuffer))
{
errorMessage = boost::str(boost::format("Cannot convert the name of category (%1%) to an SWTrace namestring")
% categoryName);
@@ -318,7 +319,7 @@ bool SendCounterPacket::CreateDeviceRecord(const DevicePtr& device,
// Convert the device name into a SWTrace string
std::vector<uint32_t> deviceNameBuffer;
- if (!StringToSwTraceString<SwTraceCharPolicy>(deviceName, deviceNameBuffer))
+ if (!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(deviceName, deviceNameBuffer))
{
errorMessage = boost::str(boost::format("Cannot convert the name of device %1% (%2%) to an SWTrace string")
% deviceUid
@@ -368,7 +369,7 @@ bool SendCounterPacket::CreateCounterSetRecord(const CounterSetPtr& counterSet,
// Convert the device name into a SWTrace namestring
std::vector<uint32_t> counterSetNameBuffer;
- if (!StringToSwTraceString<SwTraceNameCharPolicy>(counterSet->m_Name, counterSetNameBuffer))
+ if (!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>(counterSet->m_Name, counterSetNameBuffer))
{
errorMessage = boost::str(boost::format("Cannot convert the name of counter set %1% (%2%) to "
"an SWTrace namestring")
@@ -465,7 +466,7 @@ bool SendCounterPacket::CreateEventRecord(const CounterPtr& counter,
// Convert the counter name into a SWTrace string
std::vector<uint32_t> counterNameBuffer;
- if (!StringToSwTraceString<SwTraceCharPolicy>(counterName, counterNameBuffer))
+ if (!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(counterName, counterNameBuffer))
{
errorMessage = boost::str(boost::format("Cannot convert the name of counter %1% (name: %2%) "
"to an SWTrace string")
@@ -482,7 +483,7 @@ bool SendCounterPacket::CreateEventRecord(const CounterPtr& counter,
// Convert the counter description into a SWTrace string
std::vector<uint32_t> counterDescriptionBuffer;
- if (!StringToSwTraceString<SwTraceCharPolicy>(counterDescription, counterDescriptionBuffer))
+ if (!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(counterDescription, counterDescriptionBuffer))
{
errorMessage = boost::str(boost::format("Cannot convert the description of counter %1% (description: %2%) "
"to an SWTrace string")
@@ -507,7 +508,7 @@ bool SendCounterPacket::CreateEventRecord(const CounterPtr& counter,
if (includeUnits)
{
// Convert the counter units into a SWTrace namestring
- if (!StringToSwTraceString<SwTraceNameCharPolicy>(counterUnits, counterUnitsBuffer))
+ if (!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>(counterUnits, counterUnitsBuffer))
{
errorMessage = boost::str(boost::format("Cannot convert the units of counter %1% (units: %2%) "
"to an SWTrace string")
diff --git a/src/profiling/SendThread.cpp b/src/profiling/SendThread.cpp
index 5962f2fc5d..86e6c05a02 100644
--- a/src/profiling/SendThread.cpp
+++ b/src/profiling/SendThread.cpp
@@ -1,10 +1,9 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "SendThread.hpp"
-#include "EncodeVersion.hpp"
#include "ProfilingUtils.hpp"
#include <armnn/Exceptions.hpp>
@@ -25,7 +24,9 @@ namespace profiling
using boost::numeric_cast;
SendThread::SendThread(armnn::profiling::ProfilingStateMachine& profilingStateMachine,
- armnn::profiling::IBufferManager& buffer, armnn::profiling::ISendCounterPacket& sendCounterPacket, int timeout)
+ armnn::profiling::IBufferManager& buffer,
+ armnn::profiling::ISendCounterPacket& sendCounterPacket,
+ int timeout)
: m_StateMachine(profilingStateMachine)
, m_BufferManager(buffer)
, m_SendCounterPacket(sendCounterPacket)
diff --git a/src/profiling/SocketProfilingConnection.cpp b/src/profiling/SocketProfilingConnection.cpp
index c231045b10..9de425b62c 100644
--- a/src/profiling/SocketProfilingConnection.cpp
+++ b/src/profiling/SocketProfilingConnection.cpp
@@ -11,7 +11,6 @@
#include <fcntl.h>
#include <string>
-using namespace armnnUtils;
namespace armnn
{
@@ -20,13 +19,13 @@ namespace profiling
SocketProfilingConnection::SocketProfilingConnection()
{
- Sockets::Initialize();
+ arm::pipe::Initialize();
memset(m_Socket, 0, sizeof(m_Socket));
// Note: we're using Linux specific SOCK_CLOEXEC flag.
m_Socket[0].fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (m_Socket[0].fd == -1)
{
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Socket construction failed: ") + strerror(errno),
m_Socket[0].fd,
errno);
@@ -41,7 +40,7 @@ SocketProfilingConnection::SocketProfilingConnection()
if (0 != connect(m_Socket[0].fd, reinterpret_cast<const sockaddr*>(&server), sizeof(sockaddr_un)))
{
Close();
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Cannot connect to stream socket: ") + strerror(errno),
m_Socket[0].fd,
errno);
@@ -51,10 +50,10 @@ SocketProfilingConnection::SocketProfilingConnection()
m_Socket[0].events = POLLIN;
// Make the socket non blocking.
- if (!Sockets::SetNonBlocking(m_Socket[0].fd))
+ if (!arm::pipe::SetNonBlocking(m_Socket[0].fd))
{
Close();
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Failed to set socket as non blocking: ") + strerror(errno),
m_Socket[0].fd,
errno);
@@ -68,9 +67,9 @@ bool SocketProfilingConnection::IsOpen() const
void SocketProfilingConnection::Close()
{
- if (Sockets::Close(m_Socket[0].fd) != 0)
+ if (arm::pipe::Close(m_Socket[0].fd) != 0)
{
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Cannot close stream socket: ") + strerror(errno),
m_Socket[0].fd,
errno);
@@ -86,14 +85,14 @@ bool SocketProfilingConnection::WritePacket(const unsigned char* buffer, uint32_
return false;
}
- return Sockets::Write(m_Socket[0].fd, buffer, length) != -1;
+ return arm::pipe::Write(m_Socket[0].fd, buffer, length) != -1;
}
-Packet SocketProfilingConnection::ReadPacket(uint32_t timeout)
+arm::pipe::Packet SocketProfilingConnection::ReadPacket(uint32_t timeout)
{
// Is there currently at least a header worth of data waiting to be read?
int bytes_available = 0;
- Sockets::Ioctl(m_Socket[0].fd, FIONREAD, &bytes_available);
+ arm::pipe::Ioctl(m_Socket[0].fd, FIONREAD, &bytes_available);
if (bytes_available >= 8)
{
// Yes there is. Read it:
@@ -101,18 +100,18 @@ Packet SocketProfilingConnection::ReadPacket(uint32_t timeout)
}
// Poll for data on the socket or until timeout occurs
- int pollResult = Sockets::Poll(&m_Socket[0], 1, static_cast<int>(timeout));
+ int pollResult = arm::pipe::Poll(&m_Socket[0], 1, static_cast<int>(timeout));
switch (pollResult)
{
case -1: // Error
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Error occured while reading from socket: ") + strerror(errno),
m_Socket[0].fd,
errno);
case 0: // Timeout
- throw TimeoutException("SocketProfilingConnection: Timeout while reading from socket");
+ throw arm::pipe::TimeoutException("SocketProfilingConnection: Timeout while reading from socket");
default: // Normal poll return but it could still contain an error signal
// Check if the socket reported an error
@@ -122,13 +121,13 @@ Packet SocketProfilingConnection::ReadPacket(uint32_t timeout)
{
// This is an unrecoverable error.
Close();
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Error occured while polling receiving socket: POLLNVAL."),
m_Socket[0].fd);
}
if (m_Socket[0].revents == POLLERR)
{
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string(
"SocketProfilingConnection: Error occured while polling receiving socket: POLLERR: ")
+ strerror(errno),
@@ -139,7 +138,7 @@ Packet SocketProfilingConnection::ReadPacket(uint32_t timeout)
{
// This is an unrecoverable error.
Close();
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Connection closed by remote client: POLLHUP."),
m_Socket[0].fd);
}
@@ -158,30 +157,30 @@ Packet SocketProfilingConnection::ReadPacket(uint32_t timeout)
}
}
-Packet SocketProfilingConnection::ReceivePacket()
+arm::pipe::Packet SocketProfilingConnection::ReceivePacket()
{
char header[8] = {};
- long receiveResult = Sockets::Read(m_Socket[0].fd, &header, sizeof(header));
+ long receiveResult = arm::pipe::Read(m_Socket[0].fd, &header, sizeof(header));
// We expect 8 as the result here. 0 means EOF, socket is closed. -1 means there been some other kind of error.
switch( receiveResult )
{
case 0:
// Socket has closed.
Close();
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Remote socket has closed the connection."),
m_Socket[0].fd);
case -1:
// There's been a socket error. We will presume it's unrecoverable.
Close();
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Error occured while reading the packet: ") + strerror(errno),
m_Socket[0].fd,
errno);
default:
if (receiveResult < 8)
{
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string(
"SocketProfilingConnection: The received packet did not contains a valid PIPE header."),
m_Socket[0].fd);
@@ -201,10 +200,10 @@ Packet SocketProfilingConnection::ReceivePacket()
if (dataLength > 0)
{
packetData = std::make_unique<unsigned char[]>(dataLength);
- long receivedLength = Sockets::Read(m_Socket[0].fd, packetData.get(), dataLength);
+ long receivedLength = arm::pipe::Read(m_Socket[0].fd, packetData.get(), dataLength);
if (receivedLength < 0)
{
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Error occured while reading the packet: ") + strerror(errno),
m_Socket[0].fd,
errno);
@@ -212,13 +211,13 @@ Packet SocketProfilingConnection::ReceivePacket()
if (dataLength != static_cast<uint32_t>(receivedLength))
{
// What do we do here if we can't read in a full packet?
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Invalid PIPE packet."),
m_Socket[0].fd);
}
}
- return Packet(metadataIdentifier, dataLength, packetData);
+ return arm::pipe::Packet(metadataIdentifier, dataLength, packetData);
}
} // namespace profiling
diff --git a/src/profiling/SocketProfilingConnection.hpp b/src/profiling/SocketProfilingConnection.hpp
index a646c03d9c..8d9cb20935 100644
--- a/src/profiling/SocketProfilingConnection.hpp
+++ b/src/profiling/SocketProfilingConnection.hpp
@@ -22,12 +22,12 @@ public:
bool IsOpen() const final;
void Close() final;
bool WritePacket(const unsigned char* buffer, uint32_t length) final;
- Packet ReadPacket(uint32_t timeout) final;
+ arm::pipe::Packet ReadPacket(uint32_t timeout) final;
private:
// Read a full packet from the socket.
- Packet ReceivePacket();
+ arm::pipe::Packet ReceivePacket();
#ifndef __APPLE__
// To indicate we want to use an abstract UDS ensure the first character of the address is 0.
@@ -36,7 +36,7 @@ private:
// MACOSX does not support abstract UDS
const char* m_GatorNamespace = "/tmp/gatord_namespace";
#endif
- armnnUtils::Sockets::PollFd m_Socket[1]{};
+ arm::pipe::PollFd m_Socket[1]{};
};
} // namespace profiling
diff --git a/src/profiling/test/BufferTests.cpp b/src/profiling/test/BufferTests.cpp
index 804335138d..7a92ee19e5 100644
--- a/src/profiling/test/BufferTests.cpp
+++ b/src/profiling/test/BufferTests.cpp
@@ -7,6 +7,8 @@
#include "PacketBuffer.hpp"
#include "ProfilingUtils.hpp"
+#include <common/include/SwTrace.hpp>
+
#include <armnn/Exceptions.hpp>
#include <boost/test/unit_test.hpp>
@@ -380,8 +382,8 @@ BOOST_AUTO_TEST_CASE(ReadSwTraceMessageExceptionTest0)
unsigned int uint32_t_size = sizeof(uint32_t);
unsigned int offset = uint32_t_size;
- BOOST_CHECK_THROW(ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()),
- armnn::RuntimeException);
+ BOOST_CHECK_THROW(arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()),
+ arm::pipe::ProfilingException);
}
@@ -402,8 +404,8 @@ BOOST_AUTO_TEST_CASE(ReadSwTraceMessageExceptionTest1)
unsigned int uint32_t_size = sizeof(uint32_t);
unsigned int offset = uint32_t_size;
- BOOST_CHECK_THROW(ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()),
- armnn::RuntimeException);
+ BOOST_CHECK_THROW(arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()),
+ arm::pipe::ProfilingException);
}
diff --git a/src/profiling/test/PrintPacketHeaderHandler.cpp b/src/profiling/test/PrintPacketHeaderHandler.cpp
index 24095d8250..f85a7b1fcb 100644
--- a/src/profiling/test/PrintPacketHeaderHandler.cpp
+++ b/src/profiling/test/PrintPacketHeaderHandler.cpp
@@ -1,11 +1,12 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "PrintPacketHeaderHandler.hpp"
#include <iostream>
+#include <sstream>
namespace armnn
{
@@ -18,7 +19,7 @@ std::vector<uint32_t> PrintPacketHeaderHandler::GetHeadersAccepted()
return std::vector<uint32_t>();
}
-void PrintPacketHeaderHandler::HandlePacket(const Packet& packet)
+void PrintPacketHeaderHandler::HandlePacket(const arm::pipe::Packet& packet)
{
std::stringstream ss;
ss << "Handler Received Outgoing Packet [" << packet.GetPacketFamily() << ":" << packet.GetPacketId() << "]";
diff --git a/src/profiling/test/PrintPacketHeaderHandler.hpp b/src/profiling/test/PrintPacketHeaderHandler.hpp
index 6564f3cea5..397da0b8ea 100644
--- a/src/profiling/test/PrintPacketHeaderHandler.hpp
+++ b/src/profiling/test/PrintPacketHeaderHandler.hpp
@@ -1,12 +1,13 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include <armnn/profiling/ILocalPacketHandler.hpp>
-#include <Packet.hpp>
+
+#include <common/include/Packet.hpp>
namespace armnn
{
@@ -18,7 +19,7 @@ class PrintPacketHeaderHandler : public ILocalPacketHandler
{
virtual std::vector<uint32_t> GetHeadersAccepted();
- virtual void HandlePacket(const Packet& packet);
+ virtual void HandlePacket(const arm::pipe::Packet& packet);
};
} // namespace profiling
diff --git a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
index 6784ddabcb..d6700bc41a 100644
--- a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
+++ b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -32,7 +32,7 @@ public:
{
// populate packet data and construct packet
std::memcpy(m_PacketData.get(), g_DataPtr, g_DataLength);
- m_Packet = std::make_unique<Packet>(0u, g_DataLength, m_PacketData);
+ m_Packet = std::make_unique<arm::pipe::Packet>(0u, g_DataLength, m_PacketData);
}
~DummyProfilingConnection() = default;
@@ -54,7 +54,7 @@ public:
return true;
}
- Packet ReadPacket(uint32_t timeout) override
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override
{
armnn::IgnoreUnused(timeout);
return std::move(*m_Packet);
@@ -63,7 +63,7 @@ public:
private:
bool m_Open;
std::unique_ptr<unsigned char[]> m_PacketData;
- std::unique_ptr<Packet> m_Packet;
+ std::unique_ptr<arm::pipe::Packet> m_Packet;
};
std::vector<char> ReadDumpFile(const std::string& dumpFileName)
@@ -105,8 +105,8 @@ BOOST_AUTO_TEST_CASE(DumpIncomingValidFile)
ProfilingConnectionDumpToFileDecorator decorator(std::make_unique<DummyProfilingConnection>(), options, false);
// NOTE: unique_ptr is needed here because operator=() is deleted for Packet
- std::unique_ptr<Packet> packet;
- BOOST_CHECK_NO_THROW(packet = std::make_unique<Packet>(decorator.ReadPacket(0)));
+ std::unique_ptr<arm::pipe::Packet> packet;
+ BOOST_CHECK_NO_THROW(packet = std::make_unique<arm::pipe::Packet>(decorator.ReadPacket(0)));
decorator.Close();
diff --git a/src/profiling/test/ProfilingMocks.hpp b/src/profiling/test/ProfilingMocks.hpp
index e4f71f932c..8bcf27a8d1 100644
--- a/src/profiling/test/ProfilingMocks.hpp
+++ b/src/profiling/test/ProfilingMocks.hpp
@@ -121,7 +121,7 @@ public:
}
}
- bool WritePacket(Packet&& packet)
+ bool WritePacket(arm::pipe::Packet&& packet)
{
std::lock_guard<std::mutex> lock(m_Mutex);
@@ -129,7 +129,7 @@ public:
return true;
}
- Packet ReadPacket(uint32_t timeout) override
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override
{
IgnoreUnused(timeout);
@@ -156,7 +156,7 @@ public:
private:
bool m_IsOpen;
std::vector<std::pair<PacketType, uint32_t>> m_WrittenData;
- Packet m_Packet;
+ arm::pipe::Packet m_Packet;
mutable std::mutex m_Mutex;
};
diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp
index bc16bb952b..f616442df0 100644
--- a/src/profiling/test/ProfilingTests.cpp
+++ b/src/profiling/test/ProfilingTests.cpp
@@ -7,18 +7,15 @@
#include "ProfilingTestUtils.hpp"
#include <backends/BackendProfiling.hpp>
+#include <common/include/EncodeVersion.hpp>
+#include <common/include/PacketVersionResolver.hpp>
+#include <common/include/SwTrace.hpp>
#include <CommandHandler.hpp>
-#include <CommandHandlerKey.hpp>
-#include <CommandHandlerRegistry.hpp>
-#include <common/include/SocketConnectionException.hpp>
#include <ConnectionAcknowledgedCommandHandler.hpp>
#include <CounterDirectory.hpp>
#include <CounterIdMap.hpp>
-#include <EncodeVersion.hpp>
#include <Holder.hpp>
#include <ICounterValues.hpp>
-#include <Packet.hpp>
-#include <PacketVersionResolver.hpp>
#include <PeriodicCounterCapture.hpp>
#include <PeriodicCounterSelectionCommandHandler.hpp>
#include <ProfilingStateMachine.hpp>
@@ -37,6 +34,11 @@
#include <armnn/Utils.hpp>
#include <armnn/utility/IgnoreUnused.hpp>
+#include <common/include/CommandHandlerKey.hpp>
+#include <common/include/CommandHandlerRegistry.hpp>
+#include <common/include/SocketConnectionException.hpp>
+#include <common/include/Packet.hpp>
+
#include <boost/numeric/conversion/cast.hpp>
#include <cstdint>
@@ -54,16 +56,16 @@ BOOST_AUTO_TEST_SUITE(ExternalProfiling)
BOOST_AUTO_TEST_CASE(CheckCommandHandlerKeyComparisons)
{
- CommandHandlerKey testKey1_0(1, 1, 1);
- CommandHandlerKey testKey1_1(1, 1, 1);
- CommandHandlerKey testKey1_2(1, 2, 1);
+ arm::pipe::CommandHandlerKey testKey1_0(1, 1, 1);
+ arm::pipe::CommandHandlerKey testKey1_1(1, 1, 1);
+ arm::pipe::CommandHandlerKey testKey1_2(1, 2, 1);
- CommandHandlerKey testKey0(0, 1, 1);
- CommandHandlerKey testKey1(0, 1, 1);
- CommandHandlerKey testKey2(0, 1, 1);
- CommandHandlerKey testKey3(0, 0, 0);
- CommandHandlerKey testKey4(0, 2, 2);
- CommandHandlerKey testKey5(0, 0, 2);
+ arm::pipe::CommandHandlerKey testKey0(0, 1, 1);
+ arm::pipe::CommandHandlerKey testKey1(0, 1, 1);
+ arm::pipe::CommandHandlerKey testKey2(0, 1, 1);
+ arm::pipe::CommandHandlerKey testKey3(0, 0, 0);
+ arm::pipe::CommandHandlerKey testKey4(0, 2, 2);
+ arm::pipe::CommandHandlerKey testKey5(0, 0, 2);
BOOST_CHECK(testKey1_0 > testKey0);
BOOST_CHECK(testKey1_0 == testKey1_1);
@@ -88,30 +90,32 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerKeyComparisons)
BOOST_CHECK(testKey1.GetPacketId() == 1);
BOOST_CHECK(testKey1.GetVersion() == 1);
- std::vector<CommandHandlerKey> vect = { CommandHandlerKey(0, 0, 1), CommandHandlerKey(0, 2, 0),
- CommandHandlerKey(0, 1, 0), CommandHandlerKey(0, 2, 1),
- CommandHandlerKey(0, 1, 1), CommandHandlerKey(0, 0, 1),
- CommandHandlerKey(0, 2, 0), CommandHandlerKey(0, 0, 0) };
+ std::vector<arm::pipe::CommandHandlerKey> vect = {
+ arm::pipe::CommandHandlerKey(0, 0, 1), arm::pipe::CommandHandlerKey(0, 2, 0),
+ arm::pipe::CommandHandlerKey(0, 1, 0), arm::pipe::CommandHandlerKey(0, 2, 1),
+ arm::pipe::CommandHandlerKey(0, 1, 1), arm::pipe::CommandHandlerKey(0, 0, 1),
+ arm::pipe::CommandHandlerKey(0, 2, 0), arm::pipe::CommandHandlerKey(0, 0, 0) };
std::sort(vect.begin(), vect.end());
- std::vector<CommandHandlerKey> expectedVect = { CommandHandlerKey(0, 0, 0), CommandHandlerKey(0, 0, 1),
- CommandHandlerKey(0, 0, 1), CommandHandlerKey(0, 1, 0),
- CommandHandlerKey(0, 1, 1), CommandHandlerKey(0, 2, 0),
- CommandHandlerKey(0, 2, 0), CommandHandlerKey(0, 2, 1) };
+ std::vector<arm::pipe::CommandHandlerKey> expectedVect = {
+ arm::pipe::CommandHandlerKey(0, 0, 0), arm::pipe::CommandHandlerKey(0, 0, 1),
+ arm::pipe::CommandHandlerKey(0, 0, 1), arm::pipe::CommandHandlerKey(0, 1, 0),
+ arm::pipe::CommandHandlerKey(0, 1, 1), arm::pipe::CommandHandlerKey(0, 2, 0),
+ arm::pipe::CommandHandlerKey(0, 2, 0), arm::pipe::CommandHandlerKey(0, 2, 1) };
BOOST_CHECK(vect == expectedVect);
}
BOOST_AUTO_TEST_CASE(CheckPacketKeyComparisons)
{
- PacketKey key0(0, 0);
- PacketKey key1(0, 0);
- PacketKey key2(0, 1);
- PacketKey key3(0, 2);
- PacketKey key4(1, 0);
- PacketKey key5(1, 0);
- PacketKey key6(1, 1);
+ arm::pipe::PacketKey key0(0, 0);
+ arm::pipe::PacketKey key1(0, 0);
+ arm::pipe::PacketKey key2(0, 1);
+ arm::pipe::PacketKey key3(0, 2);
+ arm::pipe::PacketKey key4(1, 0);
+ arm::pipe::PacketKey key5(1, 0);
+ arm::pipe::PacketKey key6(1, 1);
BOOST_CHECK(!(key0 < key1));
BOOST_CHECK(!(key0 > key1));
@@ -130,7 +134,7 @@ BOOST_AUTO_TEST_CASE(CheckPacketKeyComparisons)
BOOST_AUTO_TEST_CASE(CheckCommandHandler)
{
- PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
ProfilingStateMachine profilingStateMachine;
TestProfilingConnectionBase testProfilingConnectionBase;
@@ -147,7 +151,7 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandler)
sendCounterPacket, sendTimelinePacket,
profilingStateMachine,
mockProfilingServiceStatus);
- CommandHandlerRegistry commandHandlerRegistry;
+ arm::pipe::CommandHandlerRegistry commandHandlerRegistry;
commandHandlerRegistry.RegisterFunctor(&connectionAcknowledgedCommandHandler);
@@ -260,31 +264,31 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandler)
BOOST_AUTO_TEST_CASE(CheckEncodeVersion)
{
- Version version1(12);
+ arm::pipe::Version version1(12);
BOOST_CHECK(version1.GetMajor() == 0);
BOOST_CHECK(version1.GetMinor() == 0);
BOOST_CHECK(version1.GetPatch() == 12);
- Version version2(4108);
+ arm::pipe::Version version2(4108);
BOOST_CHECK(version2.GetMajor() == 0);
BOOST_CHECK(version2.GetMinor() == 1);
BOOST_CHECK(version2.GetPatch() == 12);
- Version version3(4198412);
+ arm::pipe::Version version3(4198412);
BOOST_CHECK(version3.GetMajor() == 1);
BOOST_CHECK(version3.GetMinor() == 1);
BOOST_CHECK(version3.GetPatch() == 12);
- Version version4(0);
+ arm::pipe::Version version4(0);
BOOST_CHECK(version4.GetMajor() == 0);
BOOST_CHECK(version4.GetMinor() == 0);
BOOST_CHECK(version4.GetPatch() == 0);
- Version version5(1, 0, 0);
+ arm::pipe::Version version5(1, 0, 0);
BOOST_CHECK(version5.GetEncodedValue() == 4194304);
}
@@ -295,7 +299,7 @@ BOOST_AUTO_TEST_CASE(CheckPacketClass)
std::unique_ptr<unsigned char[]> packetData1 = std::make_unique<unsigned char[]>(0);
std::unique_ptr<unsigned char[]> nullPacketData;
- Packet packetTest0(472580096, length, packetData0);
+ arm::pipe::Packet packetTest0(472580096, length, packetData0);
BOOST_CHECK(packetTest0.GetHeader() == 472580096);
BOOST_CHECK(packetTest0.GetPacketFamily() == 7);
@@ -304,15 +308,15 @@ BOOST_AUTO_TEST_CASE(CheckPacketClass)
BOOST_CHECK(packetTest0.GetPacketType() == 3);
BOOST_CHECK(packetTest0.GetPacketClass() == 5);
- BOOST_CHECK_THROW(Packet packetTest1(472580096, 0, packetData1), armnn::Exception);
- BOOST_CHECK_NO_THROW(Packet packetTest2(472580096, 0, nullPacketData));
+ BOOST_CHECK_THROW(arm::pipe::Packet packetTest1(472580096, 0, packetData1), arm::pipe::InvalidArgumentException);
+ BOOST_CHECK_NO_THROW(arm::pipe::Packet packetTest2(472580096, 0, nullPacketData));
- Packet packetTest3(472580096, 0, nullPacketData);
+ arm::pipe::Packet packetTest3(472580096, 0, nullPacketData);
BOOST_CHECK(packetTest3.GetLength() == 0);
BOOST_CHECK(packetTest3.GetData() == nullptr);
const unsigned char* packetTest0Data = packetTest0.GetData();
- Packet packetTest4(std::move(packetTest0));
+ arm::pipe::Packet packetTest4(std::move(packetTest0));
BOOST_CHECK(packetTest0.GetData() == nullptr);
BOOST_CHECK(packetTest4.GetData() == packetTest0Data);
@@ -334,12 +338,15 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerFunctor)
TestFunctorB testFunctorB(8, 963, version);
TestFunctorC testFunctorC(5, 983, version);
- CommandHandlerKey keyA(testFunctorA.GetFamilyId(), testFunctorA.GetPacketId(), testFunctorA.GetVersion());
- CommandHandlerKey keyB(testFunctorB.GetFamilyId(), testFunctorB.GetPacketId(), testFunctorB.GetVersion());
- CommandHandlerKey keyC(testFunctorC.GetFamilyId(), testFunctorC.GetPacketId(), testFunctorC.GetVersion());
+ arm::pipe::CommandHandlerKey keyA(
+ testFunctorA.GetFamilyId(), testFunctorA.GetPacketId(), testFunctorA.GetVersion());
+ arm::pipe::CommandHandlerKey keyB(
+ testFunctorB.GetFamilyId(), testFunctorB.GetPacketId(), testFunctorB.GetVersion());
+ arm::pipe::CommandHandlerKey keyC(
+ testFunctorC.GetFamilyId(), testFunctorC.GetPacketId(), testFunctorC.GetVersion());
// Create the unwrapped map to simulate the Command Handler Registry
- std::map<CommandHandlerKey, CommandHandlerFunctor*> registry;
+ std::map<arm::pipe::CommandHandlerKey, arm::pipe::CommandHandlerFunctor*> registry;
registry.insert(std::make_pair(keyB, &testFunctorB));
registry.insert(std::make_pair(keyA, &testFunctorA));
@@ -357,22 +364,25 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerFunctor)
std::unique_ptr<unsigned char[]> packetDataB;
std::unique_ptr<unsigned char[]> packetDataC;
- Packet packetA(500000000, 0, packetDataA);
- Packet packetB(600000000, 0, packetDataB);
- Packet packetC(400000000, 0, packetDataC);
+ arm::pipe::Packet packetA(500000000, 0, packetDataA);
+ arm::pipe::Packet packetB(600000000, 0, packetDataB);
+ arm::pipe::Packet packetC(400000000, 0, packetDataC);
// Check the correct operator of derived class is called
- registry.at(CommandHandlerKey(packetA.GetPacketFamily(), packetA.GetPacketId(), version))->operator()(packetA);
+ registry.at(arm::pipe::CommandHandlerKey(
+ packetA.GetPacketFamily(), packetA.GetPacketId(), version))->operator()(packetA);
BOOST_CHECK(testFunctorA.GetCount() == 1);
BOOST_CHECK(testFunctorB.GetCount() == 0);
BOOST_CHECK(testFunctorC.GetCount() == 0);
- registry.at(CommandHandlerKey(packetB.GetPacketFamily(), packetB.GetPacketId(), version))->operator()(packetB);
+ registry.at(arm::pipe::CommandHandlerKey(
+ packetB.GetPacketFamily(), packetB.GetPacketId(), version))->operator()(packetB);
BOOST_CHECK(testFunctorA.GetCount() == 1);
BOOST_CHECK(testFunctorB.GetCount() == 1);
BOOST_CHECK(testFunctorC.GetCount() == 0);
- registry.at(CommandHandlerKey(packetC.GetPacketFamily(), packetC.GetPacketId(), version))->operator()(packetC);
+ registry.at(arm::pipe::CommandHandlerKey(
+ packetC.GetPacketFamily(), packetC.GetPacketId(), version))->operator()(packetC);
BOOST_CHECK(testFunctorA.GetCount() == 1);
BOOST_CHECK(testFunctorB.GetCount() == 1);
BOOST_CHECK(testFunctorC.GetCount() == 1);
@@ -388,7 +398,7 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerRegistry)
TestFunctorC testFunctorC(5, 983, version);
// Create the Command Handler Registry
- CommandHandlerRegistry registry;
+ arm::pipe::CommandHandlerRegistry registry;
// Register multiple different derived classes
registry.RegisterFunctor(&testFunctorA);
@@ -399,9 +409,9 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerRegistry)
std::unique_ptr<unsigned char[]> packetDataB;
std::unique_ptr<unsigned char[]> packetDataC;
- Packet packetA(500000000, 0, packetDataA);
- Packet packetB(600000000, 0, packetDataB);
- Packet packetC(400000000, 0, packetDataC);
+ arm::pipe::Packet packetA(500000000, 0, packetDataA);
+ arm::pipe::Packet packetB(600000000, 0, packetDataB);
+ arm::pipe::Packet packetC(400000000, 0, packetDataC);
// Check the correct operator of derived class is called
registry.GetFunctor(packetA.GetPacketFamily(), packetA.GetPacketId(), version)->operator()(packetA);
@@ -427,7 +437,7 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerRegistry)
BOOST_CHECK(testFunctorC.GetCount() == 2);
// Check that non-existent key returns nullptr for its functor
- BOOST_CHECK_THROW(registry.GetFunctor(0, 0, 0), armnn::Exception);
+ BOOST_CHECK_THROW(registry.GetFunctor(0, 0, 0), arm::pipe::ProfilingException);
}
BOOST_AUTO_TEST_CASE(CheckPacketVersionResolver)
@@ -439,9 +449,9 @@ BOOST_AUTO_TEST_CASE(CheckPacketVersionResolver)
std::numeric_limits<uint32_t>::max());
// NOTE: Expected version is always 1.0.0, regardless of packetId
- const Version expectedVersion(1, 0, 0);
+ const arm::pipe::Version expectedVersion(1, 0, 0);
- PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
constexpr unsigned int numTests = 10u;
@@ -449,7 +459,7 @@ BOOST_AUTO_TEST_CASE(CheckPacketVersionResolver)
{
const uint32_t familyId = distribution(generator);
const uint32_t packetId = distribution(generator);
- Version resolvedVersion = packetVersionResolver.ResolvePacketVersion(familyId, packetId);
+ arm::pipe::Version resolvedVersion = packetVersionResolver.ResolvePacketVersion(familyId, packetId);
BOOST_TEST(resolvedVersion == expectedVersion);
}
@@ -1407,16 +1417,16 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a counter with a valid parent category name and not associated with a device
const Counter* counterWoDevice = nullptr;
BOOST_CHECK_NO_THROW(counterWoDevice = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID,
- 26,
- categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 3",
- "valid description",
- armnn::EmptyOptional(),// Units
- armnn::EmptyOptional(),// Number of cores
- 0)); // Device UID
+ 26,
+ categoryName,
+ 0,
+ 1,
+ 123.45f,
+ "valid name 3",
+ "valid description",
+ armnn::EmptyOptional(),// Units
+ armnn::EmptyOptional(),// Number of cores
+ 0)); // Device UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 3);
BOOST_CHECK(counterWoDevice);
BOOST_CHECK(counterWoDevice->m_Uid > counter->m_Uid);
@@ -1468,9 +1478,9 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
123.45f,
"valid name 5",
std::string("valid description"),
- armnn::EmptyOptional(), // Units
- armnn::EmptyOptional(), // Number of cores
- device->m_Uid)); // Device UID
+ armnn::EmptyOptional(), // Units
+ armnn::EmptyOptional(), // Number of cores
+ device->m_Uid)); // Device UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 4);
BOOST_CHECK(counterWDevice);
BOOST_CHECK(counterWDevice->m_Uid > counter->m_Uid);
@@ -1499,7 +1509,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
armnn::EmptyOptional(),// Units
armnn::EmptyOptional(),// No of cores
armnn::EmptyOptional(),// Device UID
- 0)); // CounterSet UID
+ 0)); // CounterSet UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 5);
BOOST_CHECK(counterWoCounterSet);
BOOST_CHECK(counterWoCounterSet->m_Uid > counter->m_Uid);
@@ -1615,18 +1625,19 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
const Counter* counterWMultiCoreDeviceWParentCategory = nullptr;
uint16_t numberOfCourse = multiCoreDeviceWParentCategory->m_Cores;
BOOST_CHECK_NO_THROW(counterWMultiCoreDeviceWParentCategory =
- counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID,
- 100,
- categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 10",
- "valid description",
- armnn::EmptyOptional(), // Units
- numberOfCourse, // Number of cores
- armnn::EmptyOptional(), // Device UID
- armnn::EmptyOptional()));// Counter set UID
+ counterDirectory.RegisterCounter(
+ armnn::profiling::BACKEND_ID,
+ 100,
+ categoryName,
+ 0,
+ 1,
+ 123.45f,
+ "valid name 10",
+ "valid description",
+ armnn::EmptyOptional(), // Units
+ numberOfCourse, // Number of cores
+ armnn::EmptyOptional(), // Device UID
+ armnn::EmptyOptional()));// Counter set UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 26);
BOOST_CHECK(counterWMultiCoreDeviceWParentCategory);
BOOST_CHECK(counterWMultiCoreDeviceWParentCategory->m_Uid > counter->m_Uid);
@@ -1718,10 +1729,10 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
BOOST_CHECK_NO_THROW(anotherCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, 24,
anotherCategoryName, 1, 0, .00043f,
"valid name", "valid description",
- armnn::EmptyOptional(), // Units
- armnn::EmptyOptional(), // Number of cores
- device->m_Uid, // Device UID
- counterSet->m_Uid)); // Counter set UID
+ armnn::EmptyOptional(), // Units
+ armnn::EmptyOptional(), // Number of cores
+ device->m_Uid, // Device UID
+ counterSet->m_Uid)); // Counter set UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 29);
BOOST_CHECK(anotherCounter);
BOOST_CHECK(anotherCounter->m_MaxCounterUid == anotherCounter->m_Uid);
@@ -1804,7 +1815,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData)
offset += sizeOfUint16;
WriteUint16(data1, offset, 5000);
- Packet packetA(packetId, dataLength1, uniqueData1);
+ arm::pipe::Packet packetA(packetId, dataLength1, uniqueData1);
PeriodicCounterSelectionCommandHandler commandHandler(familyId, packetId, version, backendProfilingContext,
counterIdMap, holder, 10000u, captureThread,
@@ -1859,7 +1870,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData)
WriteUint32(reinterpret_cast<unsigned char*>(uniqueData2.get()), 0, period2);
- Packet packetB(packetId, dataLength2, uniqueData2);
+ arm::pipe::Packet packetB(packetId, dataLength2, uniqueData2);
commandHandler(packetB);
@@ -1911,7 +1922,7 @@ BOOST_AUTO_TEST_CASE(CheckTimelineActivationAndDeactivation)
std::atomic<bool> m_timelineReporting;
};
- PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
BufferManager bufferManager(512);
SendTimelinePacket sendTimelinePacket(bufferManager);
@@ -1936,7 +1947,7 @@ BOOST_AUTO_TEST_CASE(CheckTimelineActivationAndDeactivation)
uint32_t packetHeader1 = ConstructHeader(packetFamily1, packetId1);
// Create the ActivateTimelineReportingPacket
- Packet ActivateTimelineReportingPacket(packetHeader1); // Length == 0
+ arm::pipe::Packet ActivateTimelineReportingPacket(packetHeader1); // Length == 0
BOOST_CHECK_THROW(
activateTimelineReportingCommandHandler.operator()(ActivateTimelineReportingPacket), armnn::Exception);
@@ -1968,7 +1979,7 @@ BOOST_AUTO_TEST_CASE(CheckTimelineActivationAndDeactivation)
uint32_t packetHeader2 = ConstructHeader(packetFamily2, packetId2);
// Create the DeactivateTimelineReportingPacket
- Packet deactivateTimelineReportingPacket(packetHeader2); // Length == 0
+ arm::pipe::Packet deactivateTimelineReportingPacket(packetHeader2); // Length == 0
stateMachine.Reset();
BOOST_CHECK_THROW(
@@ -2036,7 +2047,7 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged)
offset += sizeOfUint16;
WriteUint16(data1, offset, 5000);
- Packet packetA(connectionPacketId, dataLength1, uniqueData1);
+ arm::pipe::Packet packetA(connectionPacketId, dataLength1, uniqueData1);
ProfilingStateMachine profilingState(ProfilingState::Uninitialised);
BOOST_CHECK(profilingState.GetCurrentState() == ProfilingState::Uninitialised);
@@ -2076,7 +2087,7 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged)
// command handler received different packet
const uint32_t differentPacketId = 0x40000;
- Packet packetB(differentPacketId, dataLength1, uniqueData1);
+ arm::pipe::Packet packetB(differentPacketId, dataLength1, uniqueData1);
profilingState.TransitionToState(ProfilingState::NotConnected);
profilingState.TransitionToState(ProfilingState::WaitingForAck);
ConnectionAcknowledgedCommandHandler differentCommandHandler(packetFamilyId,
@@ -2093,7 +2104,7 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged)
BOOST_AUTO_TEST_CASE(CheckSocketConnectionException)
{
// Check that creating a SocketProfilingConnection armnnProfiling in an exception as the Gator UDS doesn't exist.
- BOOST_CHECK_THROW(new SocketProfilingConnection(), armnnProfiling::SocketConnectionException);
+ BOOST_CHECK_THROW(new SocketProfilingConnection(), arm::pipe::SocketConnectionException);
}
BOOST_AUTO_TEST_CASE(CheckSocketConnectionException2)
@@ -2102,7 +2113,7 @@ BOOST_AUTO_TEST_CASE(CheckSocketConnectionException2)
{
new SocketProfilingConnection();
}
- catch (const armnnProfiling::SocketConnectionException& ex)
+ catch (const arm::pipe::SocketConnectionException& ex)
{
BOOST_CHECK(ex.GetSocketFd() == 0);
BOOST_CHECK(ex.GetErrorNo() == 111);
@@ -2116,13 +2127,13 @@ BOOST_AUTO_TEST_CASE(SwTraceIsValidCharTest)
// Only ASCII 7-bit encoding supported
for (unsigned char c = 0; c < 128; c++)
{
- BOOST_CHECK(SwTraceCharPolicy::IsValidChar(c));
+ BOOST_CHECK(arm::pipe::SwTraceCharPolicy::IsValidChar(c));
}
// Not ASCII
for (unsigned char c = 255; c >= 128; c++)
{
- BOOST_CHECK(!SwTraceCharPolicy::IsValidChar(c));
+ BOOST_CHECK(!arm::pipe::SwTraceCharPolicy::IsValidChar(c));
}
}
@@ -2132,81 +2143,81 @@ BOOST_AUTO_TEST_CASE(SwTraceIsValidNameCharTest)
const unsigned char validChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
for (unsigned char i = 0; i < sizeof(validChars) / sizeof(validChars[0]) - 1; i++)
{
- BOOST_CHECK(SwTraceNameCharPolicy::IsValidChar(validChars[i]));
+ BOOST_CHECK(arm::pipe::SwTraceNameCharPolicy::IsValidChar(validChars[i]));
}
// Non alpha-numeric chars
for (unsigned char c = 0; c < 48; c++)
{
- BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c));
+ BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c));
}
for (unsigned char c = 58; c < 65; c++)
{
- BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c));
+ BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c));
}
for (unsigned char c = 91; c < 95; c++)
{
- BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c));
+ BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c));
}
for (unsigned char c = 96; c < 97; c++)
{
- BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c));
+ BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c));
}
for (unsigned char c = 123; c < 128; c++)
{
- BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c));
+ BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c));
}
// Not ASCII
for (unsigned char c = 255; c >= 128; c++)
{
- BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c));
+ BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c));
}
}
BOOST_AUTO_TEST_CASE(IsValidSwTraceStringTest)
{
// Valid SWTrace strings
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>(""));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("_"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("0123"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("valid_string"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("VALID_string_456"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>(" "));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("valid string"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("!$%"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("valid|\\~string#123"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(""));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("_"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("0123"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("valid_string"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("VALID_string_456"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(" "));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("valid string"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("!$%"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("valid|\\~string#123"));
// Invalid SWTrace strings
- BOOST_CHECK(!IsValidSwTraceString<SwTraceCharPolicy>("€£"));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceCharPolicy>("invalid‡string"));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceCharPolicy>("12Ž34"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("€£"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("invalid‡string"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("12Ž34"));
}
BOOST_AUTO_TEST_CASE(IsValidSwTraceNameStringTest)
{
// Valid SWTrace name strings
- BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>(""));
- BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>("_"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>("0123"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>("valid_string"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>("VALID_string_456"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(""));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("_"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("0123"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("valid_string"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("VALID_string_456"));
// Invalid SWTrace name strings
- BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>(" "));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("invalid string"));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("!$%"));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("invalid|\\~string#123"));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("€£"));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("invalid‡string"));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("12Ž34"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(" "));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid string"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("!$%"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid|\\~string#123"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("€£"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid‡string"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("12Ž34"));
}
template <typename SwTracePolicy>
void StringToSwTraceStringTestHelper(const std::string& testString, std::vector<uint32_t> buffer, size_t expectedSize)
{
// Convert the test string to a SWTrace string
- BOOST_CHECK(StringToSwTraceString<SwTracePolicy>(testString, buffer));
+ BOOST_CHECK(arm::pipe::StringToSwTraceString<SwTracePolicy>(testString, buffer));
// The buffer must contain at least the length of the string
BOOST_CHECK(!buffer.empty());
@@ -2230,22 +2241,22 @@ BOOST_AUTO_TEST_CASE(StringToSwTraceStringTest)
std::vector<uint32_t> buffer;
// Valid SWTrace strings (expected size in words)
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("", buffer, 2);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("_", buffer, 2);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("0123", buffer, 3);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("valid_string", buffer, 5);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("VALID_string_456", buffer, 6);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>(" ", buffer, 2);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("valid string", buffer, 5);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("!$%", buffer, 2);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("valid|\\~string#123", buffer, 6);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("", buffer, 2);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("_", buffer, 2);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("0123", buffer, 3);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("valid_string", buffer, 5);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("VALID_string_456", buffer, 6);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>(" ", buffer, 2);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("valid string", buffer, 5);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("!$%", buffer, 2);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("valid|\\~string#123", buffer, 6);
// Invalid SWTrace strings
- BOOST_CHECK(!StringToSwTraceString<SwTraceCharPolicy>("€£", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>("€£", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceCharPolicy>("invalid‡string", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>("invalid‡string", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceCharPolicy>("12Ž34", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>("12Ž34", buffer));
BOOST_CHECK(buffer.empty());
}
@@ -2254,26 +2265,26 @@ BOOST_AUTO_TEST_CASE(StringToSwTraceNameStringTest)
std::vector<uint32_t> buffer;
// Valid SWTrace namestrings (expected size in words)
- StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("", buffer, 2);
- StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("_", buffer, 2);
- StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("0123", buffer, 3);
- StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("valid_string", buffer, 5);
- StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("VALID_string_456", buffer, 6);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("", buffer, 2);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("_", buffer, 2);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("0123", buffer, 3);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("valid_string", buffer, 5);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("VALID_string_456", buffer, 6);
// Invalid SWTrace namestrings
- BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>(" ", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>(" ", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("invalid string", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid string", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("!$%", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("!$%", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("invalid|\\~string#123", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid|\\~string#123", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("€£", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("€£", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("invalid‡string", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid‡string", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("12Ž34", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("12Ž34", buffer));
BOOST_CHECK(buffer.empty());
}
@@ -2414,7 +2425,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1)
const uint32_t wrongPacketId = 47;
const uint32_t wrongHeader = (wrongPacketId & 0x000003FF) << 16;
- Packet wrongPacket(wrongHeader);
+ arm::pipe::Packet wrongPacket(wrongHeader);
profilingStateMachine.TransitionToState(ProfilingState::Uninitialised);
BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state
@@ -2427,7 +2438,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1)
const uint32_t rightHeader = (packetId & 0x000003FF) << 16;
- Packet rightPacket(rightHeader);
+ arm::pipe::Packet rightPacket(rightHeader);
BOOST_CHECK_NO_THROW(commandHandler(rightPacket)); // Right packet
@@ -2473,7 +2484,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2)
RequestCounterDirectoryCommandHandler commandHandler(familyId, packetId, version, counterDirectory,
sendCounterPacket, sendTimelinePacket, profilingStateMachine);
const uint32_t header = (packetId & 0x000003FF) << 16;
- const Packet packet(header);
+ const arm::pipe::Packet packet(header);
const Device* device = counterDirectory.RegisterDevice("deviceA", 1);
BOOST_CHECK(device != nullptr);
@@ -2587,7 +2598,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodConnectionAcknowledgedPacket)
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Connection Acknowledged Packet
- Packet connectionAcknowledgedPacket(header);
+ arm::pipe::Packet connectionAcknowledgedPacket(header);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(connectionAcknowledgedPacket));
@@ -2643,7 +2654,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodRequestCounterDirectoryPacket)
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Request Counter Directory packet
- Packet requestCounterDirectoryPacket(header);
+ arm::pipe::Packet requestCounterDirectoryPacket(header);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(requestCounterDirectoryPacket));
@@ -2720,8 +2731,9 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadPeriodicCounterSelectionPacketInval
WriteUint16(data.get(), 6, counterUidB);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter
- // Capture thread
+ // Length > 0, this will start the Period Counter Capture thread
+ arm::pipe::Packet periodicCounterSelectionPacket(header, length, data);
+
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -2783,7 +2795,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketNoCo
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters
+ // Length == 0, this will disable the collection of counters
+ arm::pipe::Packet periodicCounterSelectionPacket(header);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -2861,8 +2874,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketSing
WriteUint16(data.get(), 4, counterUid);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter
- // Capture thread
+ // Length > 0, this will start the Period Counter Capture thread
+ arm::pipe::Packet periodicCounterSelectionPacket(header, length, data);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -2940,8 +2953,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketMult
WriteUint16(data.get(), 6, counterUidB);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter
- // Capture thread
+ // Length > 0, this will start the Period Counter Capture thread
+ arm::pipe::Packet periodicCounterSelectionPacket(header, length, data);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -3061,7 +3074,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPerJobCounterSelectionPacket)
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Per-Job Counter Selection packet
- Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters
+ // Length == 0, this will disable the collection of counters
+ arm::pipe::Packet periodicCounterSelectionPacket(header);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -3218,7 +3232,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadConnectionAcknowledgedPacket)
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Connection Acknowledged Packet
- Packet connectionAcknowledgedPacket(header);
+ arm::pipe::Packet connectionAcknowledgedPacket(header);
// Write an invalid "Connection Acknowledged" packet into the mock profiling connection, to simulate an invalid
// reply from an external profiling service
mockProfilingConnection->WritePacket(std::move(connectionAcknowledgedPacket));
@@ -3282,7 +3296,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadRequestCounterDirectoryPacket)
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Request Counter Directory packet
- Packet requestCounterDirectoryPacket(header);
+ arm::pipe::Packet requestCounterDirectoryPacket(header);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(requestCounterDirectoryPacket));
@@ -3347,7 +3361,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadPeriodicCounterSelectionPacket)
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters
+ // Length == 0, this will disable the collection of counters
+ arm::pipe::Packet periodicCounterSelectionPacket(header);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
diff --git a/src/profiling/test/ProfilingTests.hpp b/src/profiling/test/ProfilingTests.hpp
index c350fd2860..f96a1c89ab 100644
--- a/src/profiling/test/ProfilingTests.hpp
+++ b/src/profiling/test/ProfilingTests.hpp
@@ -10,10 +10,12 @@
#include <armnn/Logging.hpp>
#include <armnn/utility/PolymorphicDowncast.hpp>
-#include <CommandHandlerFunctor.hpp>
#include <IProfilingConnection.hpp>
#include <ProfilingService.hpp>
+#include <common/include/CommandHandlerFunctor.hpp>
+
+
#include <boost/test/unit_test.hpp>
#include <chrono>
@@ -82,14 +84,14 @@ public:
return false;
}
- Packet ReadPacket(uint32_t timeout) override
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override
{
// First time we're called return a connection ack packet. After that always timeout.
if (m_FirstCall)
{
m_FirstCall = false;
// Return connection acknowledged packet
- return Packet(65536);
+ return arm::pipe::Packet(65536);
}
else
{
@@ -108,7 +110,7 @@ public:
: m_ReadRequests(0)
{}
- Packet ReadPacket(uint32_t timeout) override
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override
{
// Return connection acknowledged packet after three timeouts
if (m_ReadRequests % 3 == 0)
@@ -118,7 +120,7 @@ public:
throw armnn::TimeoutException("Simulate a timeout error\n");
}
- return Packet(65536);
+ return arm::pipe::Packet(65536);
}
int ReadCalledCount()
@@ -137,7 +139,7 @@ public:
: m_ReadRequests(0)
{}
- Packet ReadPacket(uint32_t timeout) override
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override
{
IgnoreUnused(timeout);
++m_ReadRequests;
@@ -156,7 +158,7 @@ private:
class TestProfilingConnectionBadAckPacket : public TestProfilingConnectionBase
{
public:
- Packet ReadPacket(uint32_t timeout) override
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override
{
IgnoreUnused(timeout);
// Connection Acknowledged Packet header (word 0, word 1 is always zero):
@@ -168,18 +170,18 @@ public:
uint32_t packetId = 37; // Wrong packet id!!!
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
- return Packet(header);
+ return arm::pipe::Packet(header);
}
};
-class TestFunctorA : public CommandHandlerFunctor
+class TestFunctorA : public arm::pipe::CommandHandlerFunctor
{
public:
using CommandHandlerFunctor::CommandHandlerFunctor;
int GetCount() { return m_Count; }
- void operator()(const Packet& packet) override
+ void operator()(const arm::pipe::Packet& packet) override
{
IgnoreUnused(packet);
m_Count++;
diff --git a/src/profiling/test/RequestCountersPacketHandler.cpp b/src/profiling/test/RequestCountersPacketHandler.cpp
index 76c4b0cdc6..230c38857f 100644
--- a/src/profiling/test/RequestCountersPacketHandler.cpp
+++ b/src/profiling/test/RequestCountersPacketHandler.cpp
@@ -1,12 +1,12 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "RequestCountersPacketHandler.hpp"
#include "DirectoryCaptureCommandHandler.hpp"
-#include "PacketVersionResolver.hpp"
+#include <common/include/PacketVersionResolver.hpp>
#include <common/include/ProfilingException.hpp>
@@ -23,13 +23,13 @@ std::vector<uint32_t> RequestCountersPacketHandler::GetHeadersAccepted()
return headers;
}
-void RequestCountersPacketHandler::HandlePacket(const Packet& packet)
+void RequestCountersPacketHandler::HandlePacket(const arm::pipe::Packet& packet)
{
if (packet.GetHeader() != m_CounterDirectoryMessageHeader)
{
return;
}
- armnn::profiling::PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
DirectoryCaptureCommandHandler directoryCaptureCommandHandler(
0, 2, packetVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue());
directoryCaptureCommandHandler.operator()(packet);
@@ -69,7 +69,7 @@ void RequestCountersPacketHandler::SendCounterSelectionPacket()
offset += uint16_t_size;
}
- Packet packet(0x40000, bodySize, uniqueData);
+ arm::pipe::Packet packet(0x40000, bodySize, uniqueData);
m_Connection->ReturnPacket(packet);
}
diff --git a/src/profiling/test/RequestCountersPacketHandler.hpp b/src/profiling/test/RequestCountersPacketHandler.hpp
index 203edcc9df..b5e48626a7 100644
--- a/src/profiling/test/RequestCountersPacketHandler.hpp
+++ b/src/profiling/test/RequestCountersPacketHandler.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -7,9 +7,10 @@
#include <armnn/Types.hpp>
#include <armnn/profiling/ILocalPacketHandler.hpp>
-#include "Packet.hpp"
#include "ProfilingUtils.hpp"
+#include <common/include/Packet.hpp>
+
namespace armnn
{
@@ -26,7 +27,7 @@ public:
std::vector<uint32_t> GetHeadersAccepted() override; // ILocalPacketHandler
- void HandlePacket(const Packet& packet) override; // ILocalPacketHandler
+ void HandlePacket(const arm::pipe::Packet& packet) override; // ILocalPacketHandler
void SetConnection(IInternalProfilingConnection* profilingConnection) override // ILocalPacketHandler
{
diff --git a/src/profiling/test/SendCounterPacketTests.cpp b/src/profiling/test/SendCounterPacketTests.cpp
index c5f9177c90..87cfb5bf58 100644
--- a/src/profiling/test/SendCounterPacketTests.cpp
+++ b/src/profiling/test/SendCounterPacketTests.cpp
@@ -9,7 +9,7 @@
#include <BufferManager.hpp>
#include <CounterDirectory.hpp>
-#include <EncodeVersion.hpp>
+#include <common/include/EncodeVersion.hpp>
#include <ProfilingUtils.hpp>
#include <SendCounterPacket.hpp>
#include <Processes.hpp>
@@ -325,19 +325,19 @@ BOOST_AUTO_TEST_CASE(SendStreamMetaDataPacketTest)
// Timeline Message Directory (packet_family = 1, packet_class = 0, packet_type = 0) Version 1.0.0
// Timeline Message (packet_family = 1, packet_class = 0, packet_type = 1) Version 1.0.0
std::vector<std::pair<uint32_t, uint32_t>> packetVersions;
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 1), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 2), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 3), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 4), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 5), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 6), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 7), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(3, 0, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 1), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 1), EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 0), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 1), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 2), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 3), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 4), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 5), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 6), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 7), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(3, 0, 0), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 0), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 1), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 0), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 1), arm::pipe::EncodeVersion(1, 0, 0)));
uint32_t packetEntries = static_cast<uint32_t>(packetVersions.size());
@@ -359,9 +359,9 @@ BOOST_AUTO_TEST_CASE(SendStreamMetaDataPacketTest)
BOOST_TEST(headerWord1 == totalLength - (2 * sizeUint32)); // data length
uint32_t offset = sizeUint32 * 2;
- BOOST_TEST(ReadUint32(readBuffer2, offset) == armnnProfiling::PIPE_MAGIC); // pipe_magic
+ BOOST_TEST(ReadUint32(readBuffer2, offset) == arm::pipe::PIPE_MAGIC); // pipe_magic
offset += sizeUint32;
- BOOST_TEST(ReadUint32(readBuffer2, offset) == EncodeVersion(1, 0, 0)); // stream_metadata_version
+ BOOST_TEST(ReadUint32(readBuffer2, offset) == arm::pipe::EncodeVersion(1, 0, 0)); // stream_metadata_version
offset += sizeUint32;
BOOST_TEST(ReadUint32(readBuffer2, offset) == MAX_METADATA_PACKET_LENGTH); // max_data_len
offset += sizeUint32;
diff --git a/src/profiling/test/SendTimelinePacketTests.cpp b/src/profiling/test/SendTimelinePacketTests.cpp
index 5e9f6bddea..7b68bb9753 100644
--- a/src/profiling/test/SendTimelinePacketTests.cpp
+++ b/src/profiling/test/SendTimelinePacketTests.cpp
@@ -6,14 +6,16 @@
#include "ProfilingMocks.hpp"
#include <BufferManager.hpp>
-#include <Threads.hpp>
+#include <LabelsAndEventClasses.hpp>
#include <ProfilingService.hpp>
#include <ProfilingUtils.hpp>
#include <SendTimelinePacket.hpp>
+#include <Threads.hpp>
#include <TimelinePacketWriterFactory.hpp>
+#include <common/include/SwTrace.hpp>
+
#include <boost/test/unit_test.hpp>
-#include <LabelsAndEventClasses.hpp>
#include <functional>
#include <Runtime.hpp>
@@ -72,9 +74,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest)
BOOST_CHECK(DeclCount == 5);
offset += uint32_t_size;
- SwTraceMessage swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(),
- offset,
- packetBuffer->GetSize());
+ arm::pipe::SwTraceMessage swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(),
+ offset,
+ packetBuffer->GetSize());
BOOST_CHECK(swTraceMessage.m_Id == 0);
BOOST_CHECK(swTraceMessage.m_Name == "declareLabel");
@@ -86,7 +88,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest)
BOOST_CHECK(swTraceMessage.m_ArgNames[0] == "guid");
BOOST_CHECK(swTraceMessage.m_ArgNames[1] == "value");
- swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize());
+ swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(),
+ offset,
+ packetBuffer->GetSize());
BOOST_CHECK(swTraceMessage.m_Id == 1);
BOOST_CHECK(swTraceMessage.m_Name == "declareEntity");
@@ -96,7 +100,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest)
BOOST_CHECK(swTraceMessage.m_ArgNames.size() == 1);
BOOST_CHECK(swTraceMessage.m_ArgNames[0] == "guid");
- swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize());
+ swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(),
+ offset,
+ packetBuffer->GetSize());
BOOST_CHECK(swTraceMessage.m_Id == 2);
BOOST_CHECK(swTraceMessage.m_Name == "declareEventClass");
@@ -108,7 +114,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest)
BOOST_CHECK(swTraceMessage.m_ArgNames[0] == "guid");
BOOST_CHECK(swTraceMessage.m_ArgNames[1] == "nameGuid");
- swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize());
+ swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(),
+ offset,
+ packetBuffer->GetSize());
BOOST_CHECK(swTraceMessage.m_Id == 3);
BOOST_CHECK(swTraceMessage.m_Name == "declareRelationship");
@@ -126,7 +134,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest)
BOOST_CHECK(swTraceMessage.m_ArgNames[3] == "tailGuid");
BOOST_CHECK(swTraceMessage.m_ArgNames[4] == "attributeGuid");
- swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize());
+ swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(),
+ offset,
+ packetBuffer->GetSize());
BOOST_CHECK(swTraceMessage.m_Id == 4);
BOOST_CHECK(swTraceMessage.m_Name == "declareEvent");
diff --git a/src/profiling/test/TestTimelinePacketHandler.cpp b/src/profiling/test/TestTimelinePacketHandler.cpp
index ccb806b238..df847d4c7c 100644
--- a/src/profiling/test/TestTimelinePacketHandler.cpp
+++ b/src/profiling/test/TestTimelinePacketHandler.cpp
@@ -7,11 +7,8 @@
#include "IProfilingConnection.hpp"
#include <LabelsAndEventClasses.hpp>
-#include <armnn/utility/IgnoreUnused.hpp>
-
#include <chrono>
#include <iostream>
-#include <sstream>
namespace armnn
{
@@ -27,7 +24,7 @@ std::vector<uint32_t> TestTimelinePacketHandler::GetHeadersAccepted()
return headers;
}
-void TestTimelinePacketHandler::HandlePacket(const Packet& packet)
+void TestTimelinePacketHandler::HandlePacket(const arm::pipe::Packet& packet)
{
if (packet.GetHeader() == m_DirectoryHeader)
{
@@ -79,44 +76,46 @@ void TestTimelinePacketHandler::SetInferenceComplete()
m_InferenceCompletedConditionVariable.notify_one();
}
-void TestTimelinePacketHandler::ProcessDirectoryPacket(const Packet& packet)
+void TestTimelinePacketHandler::ProcessDirectoryPacket(const arm::pipe::Packet& packet)
{
m_DirectoryDecoder(packet);
}
-void TestTimelinePacketHandler::ProcessMessagePacket(const Packet& packet)
+void TestTimelinePacketHandler::ProcessMessagePacket(const arm::pipe::Packet& packet)
{
m_Decoder(packet);
}
// TimelineMessageDecoder functions
-ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEntity(const Entity& entity)
+arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEntity(const Entity& entity)
{
m_TimelineModel.AddEntity(entity.m_Guid);
- return ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
+ return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
}
-ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEventClass(
- const ITimelineDecoder::EventClass& eventClass)
+arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEventClass(
+ const arm::pipe::ITimelineDecoder::EventClass& eventClass)
{
m_TimelineModel.AddEventClass(eventClass);
- return ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
+ return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
}
-ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEvent(const ITimelineDecoder::Event& event)
+arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEvent(
+ const arm::pipe::ITimelineDecoder::Event& event)
{
m_TimelineModel.AddEvent(event);
- return ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
+ return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
}
-ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateLabel(const ITimelineDecoder::Label& label)
+arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateLabel(
+ const arm::pipe::ITimelineDecoder::Label& label)
{
m_TimelineModel.AddLabel(label);
- return ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
+ return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
}
-ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateRelationship(
- const ITimelineDecoder::Relationship& relationship)
+arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateRelationship(
+ const arm::pipe::ITimelineDecoder::Relationship& relationship)
{
m_TimelineModel.AddRelationship(relationship);
// check to see if this is an execution link to an inference of event class end of life
@@ -133,7 +132,7 @@ ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateRelationship(
}
}
}
- return ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
+ return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
}
} // namespace profiling
diff --git a/src/profiling/test/TestTimelinePacketHandler.hpp b/src/profiling/test/TestTimelinePacketHandler.hpp
index 08239fc38f..ab6eee5121 100644
--- a/src/profiling/test/TestTimelinePacketHandler.hpp
+++ b/src/profiling/test/TestTimelinePacketHandler.hpp
@@ -6,14 +6,15 @@
#pragma once
#include <armnn/profiling/ILocalPacketHandler.hpp>
-#include <armnn/profiling/ITimelineDecoder.hpp>
-#include <Packet.hpp>
+#include <server/include/timelineDecoder/ITimelineDecoder.hpp>
#include "ProfilingUtils.hpp"
-#include "TimelineCaptureCommandHandler.hpp"
-#include "TimelineDirectoryCaptureCommandHandler.hpp"
+#include <server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp>
+#include <server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp>
#include "TimelineModel.hpp"
+#include <common/include/Packet.hpp>
+
#include <condition_variable>
#include <map>
#include <mutex>
@@ -27,7 +28,7 @@ namespace profiling
// forward declaration of class
class TestTimelinePacketHandler;
-class TimelineMessageDecoder : public ITimelineDecoder
+class TimelineMessageDecoder : public arm::pipe::ITimelineDecoder
{
public:
TimelineMessageDecoder(TimelineModel& model) : m_PacketHandler(nullptr), m_TimelineModel(model) {}
@@ -57,7 +58,7 @@ public:
virtual std::vector<uint32_t> GetHeadersAccepted() override; // ILocalPacketHandler
- virtual void HandlePacket(const Packet& packet) override; // ILocalPacketHandler
+ virtual void HandlePacket(const arm::pipe::Packet& packet) override; // ILocalPacketHandler
void Stop();
@@ -72,8 +73,8 @@ public:
}
private:
- void ProcessDirectoryPacket(const Packet& packet);
- void ProcessMessagePacket(const Packet& packet);
+ void ProcessDirectoryPacket(const arm::pipe::Packet& packet);
+ void ProcessMessagePacket(const arm::pipe::Packet& packet);
IInternalProfilingConnection* m_Connection;
std::mutex m_InferenceCompletedMutex;
std::condition_variable m_InferenceCompletedConditionVariable;
@@ -82,8 +83,8 @@ private:
uint32_t m_DirectoryHeader;
uint32_t m_MessageHeader;
TimelineMessageDecoder m_MessageDecoder;
- timelinedecoder::TimelineCaptureCommandHandler m_Decoder;
- timelinedecoder::TimelineDirectoryCaptureCommandHandler m_DirectoryDecoder;
+ arm::pipe::TimelineCaptureCommandHandler m_Decoder;
+ arm::pipe::TimelineDirectoryCaptureCommandHandler m_DirectoryDecoder;
};
} // namespace profiling
diff --git a/src/profiling/test/TimelineModel.cpp b/src/profiling/test/TimelineModel.cpp
index 2e4fd06013..1f02addcf9 100644
--- a/src/profiling/test/TimelineModel.cpp
+++ b/src/profiling/test/TimelineModel.cpp
@@ -14,7 +14,7 @@ namespace armnn
namespace profiling
{
-void TimelineModel::AddLabel(const ITimelineDecoder::Label& label)
+void TimelineModel::AddLabel(const arm::pipe::ITimelineDecoder::Label& label)
{
m_LabelMap.emplace(label.m_Guid, label);
}
@@ -50,14 +50,14 @@ Entity* TimelineModel::FindEntity(uint64_t id)
}
}
-void TimelineModel::AddRelationship(const ITimelineDecoder::Relationship& relationship)
+void TimelineModel::AddRelationship(const arm::pipe::ITimelineDecoder::Relationship& relationship)
{
m_Relationships.emplace(relationship.m_Guid, relationship);
- if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::LabelLink)
+ if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::LabelLink)
{
HandleLabelLink(relationship);
}
- else if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::RetentionLink)
+ else if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink)
{
// Take care of the special case of a connection between layers in ArmNN
// modelled by a retention link between two layer entities with an attribute GUID
@@ -79,16 +79,16 @@ void TimelineModel::AddRelationship(const ITimelineDecoder::Relationship& relati
// report unknown relationship type
std::stringstream ss;
ss << "Encountered a RetentionLink of unknown type [" << relationship.m_AttributeGuid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
}
}
- else if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::ExecutionLink)
+ else if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink)
{
HandleExecutionLink(relationship);
}
}
-void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relationship)
+void TimelineModel::HandleLabelLink(const arm::pipe::ITimelineDecoder::Relationship& relationship)
{
Entity* entity = FindEntity(relationship.m_HeadGuid);
// we have a label attribute of an entity
@@ -101,7 +101,7 @@ void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relati
std::stringstream ss;
ss << "could not find label link [" << relationship.m_Guid <<
"] value [" << relationship.m_TailGuid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
}
if (relationship.m_AttributeGuid != 0)
{
@@ -112,7 +112,7 @@ void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relati
std::stringstream ss;
ss << "could not find label link [" << relationship.m_Guid <<
"] attribute [" << relationship.m_AttributeGuid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
}
}
else
@@ -120,7 +120,7 @@ void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relati
//report an error
std::stringstream ss;
ss << "label link [" << relationship.m_Guid << "] has a zero attribute guid";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
}
if (entity != nullptr && attribute != nullptr && value != nullptr)
{
@@ -148,11 +148,11 @@ void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relati
{
ss << "attribute [" << *attribute << "] ";
}
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
}
}
-void TimelineModel::HandleConnection(const ITimelineDecoder::Relationship& relationship)
+void TimelineModel::HandleConnection(const arm::pipe::ITimelineDecoder::Relationship& relationship)
{
Entity* outputLayer = FindEntity(relationship.m_HeadGuid);
if (outputLayer == nullptr)
@@ -160,7 +160,7 @@ void TimelineModel::HandleConnection(const ITimelineDecoder::Relationship& relat
std::stringstream ss;
ss << "could not find output entity [" << relationship.m_HeadGuid << "]";
ss << " of connection [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
Entity* inputLayer = FindEntity(relationship.m_TailGuid);
@@ -169,14 +169,14 @@ void TimelineModel::HandleConnection(const ITimelineDecoder::Relationship& relat
std::stringstream ss;
ss << "could not find input entity [" << relationship.m_TailGuid << "]";
ss << " of connection [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
Connection connection(relationship.m_Guid, outputLayer, inputLayer);
outputLayer->AddConnection(connection);
}
-void TimelineModel::HandleChild(const ITimelineDecoder::Relationship& relationship)
+void TimelineModel::HandleChild(const arm::pipe::ITimelineDecoder::Relationship& relationship)
{
Entity* parentEntity = FindEntity(relationship.m_HeadGuid);
if (parentEntity == nullptr)
@@ -184,7 +184,7 @@ void TimelineModel::HandleChild(const ITimelineDecoder::Relationship& relationsh
std::stringstream ss;
ss << "could not find parent entity [" << relationship.m_HeadGuid << "]";
ss << " of child relationship [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
Entity* childEntity = FindEntity(relationship.m_TailGuid);
@@ -193,13 +193,13 @@ void TimelineModel::HandleChild(const ITimelineDecoder::Relationship& relationsh
std::stringstream ss;
ss << "could not find child entity [" << relationship.m_TailGuid << "]";
ss << " of child relationship [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
parentEntity->AddChild(childEntity);
}
-void TimelineModel::HandleExecutionOf(const ITimelineDecoder::Relationship& relationship)
+void TimelineModel::HandleExecutionOf(const arm::pipe::ITimelineDecoder::Relationship& relationship)
{
Entity* parentEntity = FindEntity(relationship.m_HeadGuid);
if (parentEntity == nullptr)
@@ -207,7 +207,7 @@ void TimelineModel::HandleExecutionOf(const ITimelineDecoder::Relationship& rela
std::stringstream ss;
ss << "could not find parent entity [" << relationship.m_HeadGuid << "]";
ss << " of execution relationship [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
Entity* executedEntity = FindEntity(relationship.m_TailGuid);
@@ -216,13 +216,13 @@ void TimelineModel::HandleExecutionOf(const ITimelineDecoder::Relationship& rela
std::stringstream ss;
ss << "could not find executed entity [" << relationship.m_TailGuid << "]";
ss << " of execution relationship [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
parentEntity->AddExecution(executedEntity);
}
-void TimelineModel::HandleExecutionLink(const ITimelineDecoder::Relationship& relationship)
+void TimelineModel::HandleExecutionLink(const arm::pipe::ITimelineDecoder::Relationship& relationship)
{
// entityGuid,
Entity* parentEntity = FindEntity(relationship.m_HeadGuid);
@@ -231,7 +231,7 @@ void TimelineModel::HandleExecutionLink(const ITimelineDecoder::Relationship& re
std::stringstream ss;
ss << "could not find entity [" << relationship.m_HeadGuid << "]";
ss << " of ExecutionLink [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
// eventGuid,
@@ -241,7 +241,7 @@ void TimelineModel::HandleExecutionLink(const ITimelineDecoder::Relationship& re
std::stringstream ss;
ss << "could not find event [" << relationship.m_TailGuid << "]";
ss << " of ExecutionLink [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
// eventClassGuid
@@ -251,7 +251,7 @@ void TimelineModel::HandleExecutionLink(const ITimelineDecoder::Relationship& re
std::stringstream ss;
ss << "could not find event class [" << relationship.m_TailGuid << "]";
ss << " of ExecutionLink [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
eventObj->SetEventClass(eventClassObj);
@@ -277,7 +277,7 @@ bool TimelineModel::IsInferenceGuid(uint64_t guid) const
return it != m_InferenceGuids.end();
}
-void TimelineModel::AddEventClass(const ITimelineDecoder::EventClass& eventClass)
+void TimelineModel::AddEventClass(const arm::pipe::ITimelineDecoder::EventClass& eventClass)
{
std::string* eventClassName = FindLabel(eventClass.m_NameGuid);
if (eventClassName != nullptr)
@@ -290,7 +290,7 @@ void TimelineModel::AddEventClass(const ITimelineDecoder::EventClass& eventClass
std::stringstream ss;
ss << "could not find name [" << eventClass.m_NameGuid << "]";
ss << " of of event class [" << eventClass.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
}
}
@@ -307,7 +307,7 @@ EventClassObj* TimelineModel::FindEventClass(uint64_t id)
}
}
-void TimelineModel::AddEvent(const ITimelineDecoder::Event& event)
+void TimelineModel::AddEvent(const arm::pipe::ITimelineDecoder::Event& event)
{
EventObj evt(event.m_Guid, event.m_TimeStamp, event.m_ThreadId);
m_Events.emplace(event.m_Guid, evt);
diff --git a/src/profiling/test/TimelineModel.hpp b/src/profiling/test/TimelineModel.hpp
index a6d62ce3e8..ccbec7b01d 100644
--- a/src/profiling/test/TimelineModel.hpp
+++ b/src/profiling/test/TimelineModel.hpp
@@ -5,8 +5,8 @@
#pragma once
-#include <armnn/profiling/ITimelineDecoder.hpp>
#include <common/include/ProfilingException.hpp>
+#include <server/include/timelineDecoder/ITimelineDecoder.hpp>
#include <map>
#include <sstream>
@@ -17,7 +17,7 @@ namespace armnn
namespace profiling
{
-using LabelMap = std::map<uint64_t, ITimelineDecoder::Label>;
+using LabelMap = std::map<uint64_t, arm::pipe::ITimelineDecoder::Label>;
using Attribute = std::pair<std::string, std::string>;
using Attributes = std::map<std::string, Attribute>;
class Entity;
@@ -31,13 +31,13 @@ public:
{
std::stringstream ss;
ss << "connection [" << guid << "] head cannot be null";
- throw armnnProfiling::ProfilingException(ss.str());
+ throw arm::pipe::ProfilingException(ss.str());
}
if (tail == nullptr)
{
std::stringstream ss;
ss << "connection [" << guid << "] tail cannot be null";
- throw armnnProfiling::ProfilingException(ss.str());
+ throw arm::pipe::ProfilingException(ss.str());
}
}
@@ -136,8 +136,8 @@ private:
using Entities = std::map<uint64_t, Entity>;
struct ModelRelationship
{
- ModelRelationship(const ITimelineDecoder::Relationship& relationship) : m_Relationship(relationship) {}
- ITimelineDecoder::Relationship m_Relationship;
+ ModelRelationship(const arm::pipe::ITimelineDecoder::Relationship& relationship) : m_Relationship(relationship) {}
+ arm::pipe::ITimelineDecoder::Relationship m_Relationship;
std::vector<Entity*> m_RelatedEntities;
};
using Relationships = std::map<uint64_t, ModelRelationship>;
@@ -146,35 +146,35 @@ using Events = std::map<uint64_t, EventObj>;
class TimelineModel
{
public:
- void AddLabel(const ITimelineDecoder::Label& label);
+ void AddLabel(const arm::pipe::ITimelineDecoder::Label& label);
std::string* FindLabel(uint64_t guid);
void AddEntity(uint64_t guid);
Entity* FindEntity(uint64_t id);
- void AddRelationship(const ITimelineDecoder::Relationship& relationship);
+ void AddRelationship(const arm::pipe::ITimelineDecoder::Relationship& relationship);
ModelRelationship* FindRelationship(uint64_t id);
const LabelMap& GetLabelMap() const {return m_LabelMap;}
const Entities& GetEntities() const {return m_Entities;}
- const std::vector<armnnProfiling::ProfilingException>& GetErrors() const {return m_Errors;}
+ const std::vector<arm::pipe::ProfilingException>& GetErrors() const {return m_Errors;}
bool IsInferenceGuid(uint64_t guid) const;
- void AddEventClass(const ITimelineDecoder::EventClass& eventClass);
+ void AddEventClass(const arm::pipe::ITimelineDecoder::EventClass& eventClass);
const EventClasses& GetEventClasses() const {return m_EventClasses;}
EventClassObj* FindEventClass(uint64_t id);
- void AddEvent(const ITimelineDecoder::Event& event);
+ void AddEvent(const arm::pipe::ITimelineDecoder::Event& event);
EventObj* FindEvent(uint64_t id);
private:
LabelMap m_LabelMap;
Entities m_Entities;
Relationships m_Relationships;
- std::vector<armnnProfiling::ProfilingException> m_Errors;
+ std::vector<arm::pipe::ProfilingException> m_Errors;
std::vector<uint64_t> m_InferenceGuids;
EventClasses m_EventClasses;
Events m_Events;
- void HandleLabelLink(const ITimelineDecoder::Relationship& relationship);
- void HandleConnection(const ITimelineDecoder::Relationship& relationship);
- void HandleChild(const ITimelineDecoder::Relationship& relationship);
- void HandleExecutionOf(const ITimelineDecoder::Relationship& relationship);
- void HandleExecutionLink(const ITimelineDecoder::Relationship& relationship);
+ void HandleLabelLink(const arm::pipe::ITimelineDecoder::Relationship& relationship);
+ void HandleConnection(const arm::pipe::ITimelineDecoder::Relationship& relationship);
+ void HandleChild(const arm::pipe::ITimelineDecoder::Relationship& relationship);
+ void HandleExecutionOf(const arm::pipe::ITimelineDecoder::Relationship& relationship);
+ void HandleExecutionLink(const arm::pipe::ITimelineDecoder::Relationship& relationship);
};
std::vector<std::string> GetModelDescription(const TimelineModel& model);
diff --git a/src/profiling/test/TimelinePacketTests.cpp b/src/profiling/test/TimelinePacketTests.cpp
index 71c6915a8c..4f056ce761 100644
--- a/src/profiling/test/TimelinePacketTests.cpp
+++ b/src/profiling/test/TimelinePacketTests.cpp
@@ -6,6 +6,8 @@
#include <Threads.hpp>
#include <ProfilingUtils.hpp>
+#include <common/include/SwTrace.hpp>
+
#include <boost/test/unit_test.hpp>
#include <boost/numeric/conversion/cast.hpp>
@@ -524,7 +526,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction)
// Check the ui_name
std::vector<uint32_t> swTraceString;
- StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
+ arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(label, swTraceString);
offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
uint32_t swTraceUINameLength = ReadUint32(buffer.data(), offset);
BOOST_CHECK(swTraceUINameLength == 14); // ui_name length including the null-terminator
@@ -536,7 +538,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction)
swTraceUINameLength - 1) == 0); // The length of the label
// Check arg_types
- StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
+ arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(label, swTraceString);
offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
uint32_t swTraceArgTypesLength = ReadUint32(buffer.data(), offset);
BOOST_CHECK(swTraceArgTypesLength == 3); // arg_types length including the null-terminator
@@ -548,7 +550,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction)
swTraceArgTypesLength - 1) == 0); // The length of the label
// Check arg_names
- StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
+ arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(label, swTraceString);
offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
uint32_t swTraceArgNamesLength = ReadUint32(buffer.data(), offset);
BOOST_CHECK(swTraceArgNamesLength == 11); // arg_names length including the null-terminator
@@ -560,7 +562,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction)
swTraceArgNamesLength - 1) == 0); // The length of the label
// Check second message decl_id
- StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
+ arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(label, swTraceString);
offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
readDeclId = ReadUint32(buffer.data(), offset);
BOOST_CHECK(readDeclId == 1);
diff --git a/src/timelineDecoder/CMakeLists.txt b/src/timelineDecoder/CMakeLists.txt
index 695aa5cbe8..e7d5481eb5 100644
--- a/src/timelineDecoder/CMakeLists.txt
+++ b/src/timelineDecoder/CMakeLists.txt
@@ -1,37 +1,31 @@
#
-# Copyright © 2020 Arm Ltd. All rights reserved.
+# Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
# SPDX-License-Identifier: MIT
#
if(BUILD_TIMELINE_DECODER)
- set(timelineDecoder_sources)
- list(APPEND timelineDecoder_sources
- ${PROJECT_SOURCE_DIR}/include/armnn/profiling/ITimelineDecoder.hpp
- TimelineCaptureCommandHandler.cpp
- TimelineCaptureCommandHandler.hpp
+ set(jsonTimelineDecoder_sources)
+ list(APPEND jsonTimelineDecoder_sources
JSONTimelineDecoder.cpp
- JSONTimelineDecoder.hpp
- TimelineDecoder.cpp
- TimelineDecoder.hpp
- TimelineDirectoryCaptureCommandHandler.cpp
- TimelineDirectoryCaptureCommandHandler.hpp)
+ JSONTimelineDecoder.hpp)
include_directories(${PROJECT_SOURCE_DIR}/src/profiling
${PROJECT_SOURCE_DIR}/profiling/common/include
+ ${PROJECT_SOURCE_DIR}/profiling/server/include/timelineDecoder
${PROJECT_SOURCE_DIR}/src/armnnUtils)
if(BUILD_UNIT_TESTS)
target_include_directories(UnitTests PRIVATE ${PROJECT_SOURCE_DIR}/src/timelineDecoder)
endif()
- add_library_ex(timelineDecoder SHARED ${timelineDecoder_sources})
+ add_library_ex(jsonTimelineDecoder SHARED ${jsonTimelineDecoder_sources})
- set_target_properties(timelineDecoder PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
- set_target_properties(timelineDecoder PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
+ set_target_properties(jsonTimelineDecoder PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
+ set_target_properties(jsonTimelineDecoder PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
- target_link_libraries(timelineDecoder armnn)
+ target_link_libraries(jsonTimelineDecoder armnn)
- install(TARGETS timelineDecoder
+ install(TARGETS jsonTimelineDecoder
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
diff --git a/src/timelineDecoder/JSONTimelineDecoder.cpp b/src/timelineDecoder/JSONTimelineDecoder.cpp
index c0e81370ed..0eafe493aa 100644
--- a/src/timelineDecoder/JSONTimelineDecoder.cpp
+++ b/src/timelineDecoder/JSONTimelineDecoder.cpp
@@ -7,7 +7,6 @@
#include "../profiling/ProfilingUtils.hpp"
#include <string>
-#include <fstream>
namespace armnn
{
diff --git a/src/timelineDecoder/JSONTimelineDecoder.hpp b/src/timelineDecoder/JSONTimelineDecoder.hpp
index a6e2579b45..7fed9a1a86 100644
--- a/src/timelineDecoder/JSONTimelineDecoder.hpp
+++ b/src/timelineDecoder/JSONTimelineDecoder.hpp
@@ -5,7 +5,7 @@
#pragma once
-#include <armnn/profiling/ITimelineDecoder.hpp>
+#include <server/include/timelineDecoder/ITimelineDecoder.hpp>
#include <Filesystem.hpp>
#include <map>
@@ -15,7 +15,7 @@ namespace armnn
{
namespace timelinedecoder
{
-class JSONTimelineDecoder : public ITimelineDecoder
+class JSONTimelineDecoder : public arm::pipe::ITimelineDecoder
{
public:
struct JSONEntity
diff --git a/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp b/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp
index 3961f9bfb5..dfe5fd0609 100644
--- a/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp
+++ b/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp
@@ -4,8 +4,8 @@
//
#include <JSONTimelineDecoder.hpp>
-#include <TimelineCaptureCommandHandler.hpp>
-#include <TimelineDecoder.hpp>
+#include <server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp>
+#include <server/include/timelineDecoder/TimelineDecoder.hpp>
#include <Filesystem.hpp>
#include <boost/test/test_tools.hpp>
@@ -23,661 +23,661 @@ void RunSimpleModelThroughDecoder(JSONTimelineDecoder& timelineDecoder)
/*
* Building Simple model structure to test
*/
- ITimelineDecoder::Label name;
+ arm::pipe::ITimelineDecoder::Label name;
name.m_Guid = uint64_t(10420554295983197538U);
name.m_Name = "name";
timelineDecoder.CreateLabel(name);
- ITimelineDecoder::Label type;
+ arm::pipe::ITimelineDecoder::Label type;
type.m_Guid = uint64_t(14196220359693045352U);
type.m_Name = "type";
timelineDecoder.CreateLabel(type);
- ITimelineDecoder::Label index;
+ arm::pipe::ITimelineDecoder::Label index;
index.m_Guid = uint64_t(13922236767355949814U);
index.m_Name = "index";
timelineDecoder.CreateLabel(index);
- ITimelineDecoder::Label backendId;
+ arm::pipe::ITimelineDecoder::Label backendId;
backendId.m_Guid = uint64_t(10874037804557439415U);
backendId.m_Name = "backendId";
timelineDecoder.CreateLabel(backendId);
- ITimelineDecoder::Label layer;
+ arm::pipe::ITimelineDecoder::Label layer;
layer.m_Guid = uint64_t(14761340794127440397U);
layer.m_Name = "layer";
timelineDecoder.CreateLabel(layer);
- ITimelineDecoder::Label workload;
+ arm::pipe::ITimelineDecoder::Label workload;
workload.m_Guid = uint64_t(15704252740552608110U);
workload.m_Name = "workload";
timelineDecoder.CreateLabel(workload);
- ITimelineDecoder::Label network;
+ arm::pipe::ITimelineDecoder::Label network;
network.m_Guid = uint64_t(16862199137063532871U);
network.m_Name = "network";
timelineDecoder.CreateLabel(network);
- ITimelineDecoder::Label connection;
+ arm::pipe::ITimelineDecoder::Label connection;
connection.m_Guid = uint64_t(15733717748792475675U);
connection.m_Name = "connection";
timelineDecoder.CreateLabel(connection);
- ITimelineDecoder::Label inference;
+ arm::pipe::ITimelineDecoder::Label inference;
inference.m_Guid = uint64_t(15026600058430441282U);
inference.m_Name = "inference";
timelineDecoder.CreateLabel(inference);
- ITimelineDecoder::Label workload_execution;
+ arm::pipe::ITimelineDecoder::Label workload_execution;
workload_execution.m_Guid = uint64_t(10172155312650606003U);
workload_execution.m_Name = "workload_execution";
timelineDecoder.CreateLabel(workload_execution);
- ITimelineDecoder::EventClass eventClass1;
+ arm::pipe::ITimelineDecoder::EventClass eventClass1;
eventClass1.m_Guid = uint64_t(17170418158534996719U);
timelineDecoder.CreateEventClass(eventClass1);
- ITimelineDecoder::EventClass eventClass2;
+ arm::pipe::ITimelineDecoder::EventClass eventClass2;
eventClass2.m_Guid = uint64_t(10812061579584851344U);
timelineDecoder.CreateEventClass(eventClass2);
- ITimelineDecoder::Entity entity6;
+ arm::pipe::ITimelineDecoder::Entity entity6;
entity6.m_Guid = uint64_t(6);
timelineDecoder.CreateEntity(entity6);
- ITimelineDecoder::Relationship relationship7;
+ arm::pipe::ITimelineDecoder::Relationship relationship7;
relationship7.m_Guid = uint64_t(7);
- relationship7.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship7.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship7.m_HeadGuid = uint64_t(6);
relationship7.m_TailGuid = uint64_t(16862199137063532871U);
timelineDecoder.CreateRelationship(relationship7);
- ITimelineDecoder::Relationship relationship8;
+ arm::pipe::ITimelineDecoder::Relationship relationship8;
relationship8.m_Guid = uint64_t(8);
- relationship8.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship8.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship8.m_HeadGuid = uint64_t(7);
relationship8.m_TailGuid = uint64_t(14196220359693045352U);
timelineDecoder.CreateRelationship(relationship8);
// Adding normalization layer
- ITimelineDecoder::Entity entity0;
+ arm::pipe::ITimelineDecoder::Entity entity0;
entity0.m_Guid = uint64_t(0);
timelineDecoder.CreateEntity(entity0);
- ITimelineDecoder::Label input;
+ arm::pipe::ITimelineDecoder::Label input;
input.m_Guid = uint64_t(18179123836411086572U);
input.m_Name = "input";
timelineDecoder.CreateLabel(input);
- ITimelineDecoder::Relationship relationship9;
+ arm::pipe::ITimelineDecoder::Relationship relationship9;
relationship9.m_Guid = uint64_t(9);
- relationship9.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship9.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship9.m_HeadGuid = uint64_t(0);
relationship9.m_TailGuid = uint64_t(18179123836411086572U);
timelineDecoder.CreateRelationship(relationship9);
- ITimelineDecoder::Relationship relationship10;
+ arm::pipe::ITimelineDecoder::Relationship relationship10;
relationship10.m_Guid = uint64_t(10);
- relationship10.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship10.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship10.m_HeadGuid = uint64_t(9);
relationship10.m_TailGuid = uint64_t(10420554295983197538U);
timelineDecoder.CreateRelationship(relationship10);
- ITimelineDecoder::Relationship relationship11;
+ arm::pipe::ITimelineDecoder::Relationship relationship11;
relationship11.m_Guid = uint64_t(11);
- relationship11.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship11.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship11.m_HeadGuid = uint64_t(0);
relationship11.m_TailGuid = uint64_t(14761340794127440397U);
timelineDecoder.CreateRelationship(relationship11);
- ITimelineDecoder::Relationship relationship12;
+ arm::pipe::ITimelineDecoder::Relationship relationship12;
relationship12.m_Guid = uint64_t(12);
- relationship12.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship12.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship12.m_HeadGuid = uint64_t(11);
relationship12.m_TailGuid = uint64_t(14196220359693045352U);
timelineDecoder.CreateRelationship(relationship12);
- ITimelineDecoder::Relationship relationship13;
+ arm::pipe::ITimelineDecoder::Relationship relationship13;
relationship13.m_Guid = uint64_t(13);
- relationship13.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink;
+ relationship13.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
relationship13.m_HeadGuid = uint64_t(6);
relationship13.m_TailGuid = uint64_t(0);
timelineDecoder.CreateRelationship(relationship13);
// Adding normalization layer
- ITimelineDecoder::Entity entity1;
+ arm::pipe::ITimelineDecoder::Entity entity1;
entity1.m_Guid = uint64_t(1);
timelineDecoder.CreateEntity(entity1);
- ITimelineDecoder::Label normalization;
+ arm::pipe::ITimelineDecoder::Label normalization;
normalization.m_Guid = uint64_t(15955949569988957863U);
normalization.m_Name = "normalization";
timelineDecoder.CreateLabel(normalization);
- ITimelineDecoder::Relationship relationship14;
+ arm::pipe::ITimelineDecoder::Relationship relationship14;
relationship14.m_Guid = uint64_t(14);
- relationship14.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship14.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship14.m_HeadGuid = uint64_t(1);
relationship14.m_TailGuid = uint64_t(15955949569988957863U);
timelineDecoder.CreateRelationship(relationship14);
- ITimelineDecoder::Relationship relationship15;
+ arm::pipe::ITimelineDecoder::Relationship relationship15;
relationship15.m_Guid = uint64_t(15);
- relationship15.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship15.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship15.m_HeadGuid = uint64_t(14);
relationship15.m_TailGuid = uint64_t(10420554295983197538U);
timelineDecoder.CreateRelationship(relationship15);
- ITimelineDecoder::Relationship relationship16;
+ arm::pipe::ITimelineDecoder::Relationship relationship16;
relationship16.m_Guid = uint64_t(16);
- relationship16.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship16.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship16.m_HeadGuid = uint64_t(1);
relationship16.m_TailGuid = uint64_t(14761340794127440397U);
timelineDecoder.CreateRelationship(relationship16);
- ITimelineDecoder::Relationship relationship17;
+ arm::pipe::ITimelineDecoder::Relationship relationship17;
relationship17.m_Guid = uint64_t(17);
- relationship17.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship17.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship17.m_HeadGuid = uint64_t(16);
relationship17.m_TailGuid = uint64_t(14196220359693045352U);
timelineDecoder.CreateRelationship(relationship17);
- ITimelineDecoder::Relationship relationship18;
+ arm::pipe::ITimelineDecoder::Relationship relationship18;
relationship18.m_Guid = uint64_t(18);
- relationship18.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink;
+ relationship18.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
relationship18.m_HeadGuid = uint64_t(6);
relationship18.m_TailGuid = uint64_t(1);
timelineDecoder.CreateRelationship(relationship18);
- ITimelineDecoder::Relationship relationship19;
+ arm::pipe::ITimelineDecoder::Relationship relationship19;
relationship19.m_Guid = uint64_t(19);
- relationship19.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink;
+ relationship19.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
relationship19.m_HeadGuid = uint64_t(0);
relationship19.m_TailGuid = uint64_t(1);
timelineDecoder.CreateRelationship(relationship19);
- ITimelineDecoder::Relationship relationship20;
+ arm::pipe::ITimelineDecoder::Relationship relationship20;
relationship20.m_Guid = uint64_t(20);
- relationship20.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship20.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship20.m_HeadGuid = uint64_t(19);
relationship20.m_TailGuid = uint64_t(15733717748792475675U);
timelineDecoder.CreateRelationship(relationship20);
- ITimelineDecoder::Relationship relationship21;
+ arm::pipe::ITimelineDecoder::Relationship relationship21;
relationship21.m_Guid = uint64_t(21);
- relationship21.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship21.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship21.m_HeadGuid = uint64_t(20);
relationship21.m_TailGuid = uint64_t(14196220359693045352U);
timelineDecoder.CreateRelationship(relationship21);
- ITimelineDecoder::Entity entity22;
+ arm::pipe::ITimelineDecoder::Entity entity22;
entity22.m_Guid = uint64_t(22);
timelineDecoder.CreateEntity(entity22);
- ITimelineDecoder::Relationship relationship23;
+ arm::pipe::ITimelineDecoder::Relationship relationship23;
relationship23.m_Guid = uint64_t(23);
- relationship23.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship23.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship23.m_HeadGuid = uint64_t(22);
relationship23.m_TailGuid = uint64_t(15704252740552608110U);
timelineDecoder.CreateRelationship(relationship23);
- ITimelineDecoder::Relationship relationship24;
+ arm::pipe::ITimelineDecoder::Relationship relationship24;
relationship24.m_Guid = uint64_t(24);
- relationship24.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship24.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship24.m_HeadGuid = uint64_t(23);
relationship24.m_TailGuid = uint64_t(14196220359693045352U);
timelineDecoder.CreateRelationship(relationship24);
- ITimelineDecoder::Label CpuRef;
+ arm::pipe::ITimelineDecoder::Label CpuRef;
CpuRef.m_Guid = uint64_t(9690680943817437852U);
CpuRef.m_Name = "CpuRef";
timelineDecoder.CreateLabel(CpuRef);
- ITimelineDecoder::Relationship relationship25;
+ arm::pipe::ITimelineDecoder::Relationship relationship25;
relationship25.m_Guid = uint64_t(25);
- relationship25.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship25.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship25.m_HeadGuid = uint64_t(22);
relationship25.m_TailGuid = uint64_t(9690680943817437852U);
timelineDecoder.CreateRelationship(relationship25);
- ITimelineDecoder::Relationship relationship26;
+ arm::pipe::ITimelineDecoder::Relationship relationship26;
relationship26.m_Guid = uint64_t(26);
- relationship26.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship26.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship26.m_HeadGuid = uint64_t(25);
relationship26.m_TailGuid = uint64_t(10874037804557439415U);
timelineDecoder.CreateRelationship(relationship26);
- ITimelineDecoder::Relationship relationship27;
+ arm::pipe::ITimelineDecoder::Relationship relationship27;
relationship27.m_Guid = uint64_t(27);
- relationship27.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink ;
+ relationship27.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink ;
relationship27.m_HeadGuid = uint64_t(1);
relationship27.m_TailGuid = uint64_t(22);
timelineDecoder.CreateRelationship(relationship27);
// Adding output layer
- ITimelineDecoder::Entity entity2;
+ arm::pipe::ITimelineDecoder::Entity entity2;
entity2.m_Guid = uint64_t(2);
timelineDecoder.CreateEntity(entity2);
- ITimelineDecoder::Label output;
+ arm::pipe::ITimelineDecoder::Label output;
output.m_Guid = uint64_t(18419179028513879730U);
output.m_Name = "output";
timelineDecoder.CreateLabel(output);
- ITimelineDecoder::Relationship relationship28;
+ arm::pipe::ITimelineDecoder::Relationship relationship28;
relationship28.m_Guid = uint64_t(28);
- relationship28.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship28.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship28.m_HeadGuid = uint64_t(2);
relationship28.m_TailGuid = uint64_t(18419179028513879730U);
timelineDecoder.CreateRelationship(relationship28);
- ITimelineDecoder::Relationship relationship29;
+ arm::pipe::ITimelineDecoder::Relationship relationship29;
relationship29.m_Guid = uint64_t(29);
- relationship29.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship29.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship29.m_HeadGuid = uint64_t(28);
relationship29.m_TailGuid = uint64_t(10420554295983197538U);
timelineDecoder.CreateRelationship(relationship29);
- ITimelineDecoder::Relationship relationship30;
+ arm::pipe::ITimelineDecoder::Relationship relationship30;
relationship30.m_Guid = uint64_t(30);
- relationship30.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship30.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship30.m_HeadGuid = uint64_t(2);
relationship30.m_TailGuid = uint64_t(14761340794127440397U);
timelineDecoder.CreateRelationship(relationship30);
- ITimelineDecoder::Relationship relationship31;
+ arm::pipe::ITimelineDecoder::Relationship relationship31;
relationship31.m_Guid = uint64_t(31);
- relationship31.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship31.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship31.m_HeadGuid = uint64_t(30);
relationship31.m_TailGuid = uint64_t(14196220359693045352U);
timelineDecoder.CreateRelationship(relationship31);
- ITimelineDecoder::Relationship relationship32;
+ arm::pipe::ITimelineDecoder::Relationship relationship32;
relationship32.m_Guid = uint64_t(32);
- relationship32.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink;
+ relationship32.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
relationship32.m_HeadGuid = uint64_t(6);
relationship32.m_TailGuid = uint64_t(2);
timelineDecoder.CreateRelationship(relationship32);
- ITimelineDecoder::Relationship relationship33;
+ arm::pipe::ITimelineDecoder::Relationship relationship33;
relationship33.m_Guid = uint64_t(33);
- relationship33.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink;
+ relationship33.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
relationship33.m_HeadGuid = uint64_t(1);
relationship33.m_TailGuid = uint64_t(2);
timelineDecoder.CreateRelationship(relationship33);
- ITimelineDecoder::Relationship relationship34;
+ arm::pipe::ITimelineDecoder::Relationship relationship34;
relationship34.m_Guid = uint64_t(34);
- relationship34.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship34.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship34.m_HeadGuid = uint64_t(33);
relationship34.m_TailGuid = uint64_t(15733717748792475675U);
timelineDecoder.CreateRelationship(relationship34);
- ITimelineDecoder::Relationship relationship35;
+ arm::pipe::ITimelineDecoder::Relationship relationship35;
relationship35.m_Guid = uint64_t(35);
- relationship35.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship35.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship35.m_HeadGuid = uint64_t(34);
relationship35.m_TailGuid = uint64_t(14196220359693045352U);
timelineDecoder.CreateRelationship(relationship35);
- ITimelineDecoder::Entity entity36;
+ arm::pipe::ITimelineDecoder::Entity entity36;
entity36.m_Guid = uint64_t(36);
timelineDecoder.CreateEntity(entity36);
- ITimelineDecoder::Relationship relationship37;
+ arm::pipe::ITimelineDecoder::Relationship relationship37;
relationship37.m_Guid = uint64_t(37);
- relationship37.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship37.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship37.m_HeadGuid = uint64_t(36);
relationship37.m_TailGuid = uint64_t(15704252740552608110U);
timelineDecoder.CreateRelationship(relationship37);
- ITimelineDecoder::Relationship relationship38;
+ arm::pipe::ITimelineDecoder::Relationship relationship38;
relationship38.m_Guid = uint64_t(38);
- relationship38.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship38.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship38.m_HeadGuid = uint64_t(37);
relationship38.m_TailGuid = uint64_t(14196220359693045352U);
timelineDecoder.CreateRelationship(relationship38);
- ITimelineDecoder::Relationship relationship39;
+ arm::pipe::ITimelineDecoder::Relationship relationship39;
relationship39.m_Guid = uint64_t(39);
- relationship39.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship39.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship39.m_HeadGuid = uint64_t(36);
relationship39.m_TailGuid = uint64_t(9690680943817437852U);
timelineDecoder.CreateRelationship(relationship39);
- ITimelineDecoder::Relationship relationship40;
+ arm::pipe::ITimelineDecoder::Relationship relationship40;
relationship40.m_Guid = uint64_t(40);
- relationship40.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship40.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship40.m_HeadGuid = uint64_t(39);
relationship40.m_TailGuid = uint64_t(10874037804557439415U);
timelineDecoder.CreateRelationship(relationship40);
- ITimelineDecoder::Relationship relationship41;
+ arm::pipe::ITimelineDecoder::Relationship relationship41;
relationship41.m_Guid = uint64_t(41);
- relationship41.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink;
+ relationship41.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
relationship41.m_HeadGuid = uint64_t(0);
relationship41.m_TailGuid = uint64_t(36);
timelineDecoder.CreateRelationship(relationship41);
- ITimelineDecoder::Entity entity42;
+ arm::pipe::ITimelineDecoder::Entity entity42;
entity42.m_Guid = uint64_t(42);
timelineDecoder.CreateEntity(entity42);
- ITimelineDecoder::Relationship relationship43;
+ arm::pipe::ITimelineDecoder::Relationship relationship43;
relationship43.m_Guid = uint64_t(43);
- relationship43.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship43.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship43.m_HeadGuid = uint64_t(42);
relationship43.m_TailGuid = uint64_t(15704252740552608110U);
timelineDecoder.CreateRelationship(relationship43);
- ITimelineDecoder::Relationship relationship44;
+ arm::pipe::ITimelineDecoder::Relationship relationship44;
relationship44.m_Guid = uint64_t(44);
- relationship44.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship44.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship44.m_HeadGuid = uint64_t(43);
relationship44.m_TailGuid = uint64_t(14196220359693045352U);
timelineDecoder.CreateRelationship(relationship44);
- ITimelineDecoder::Relationship relationship45;
+ arm::pipe::ITimelineDecoder::Relationship relationship45;
relationship45.m_Guid = uint64_t(45);
- relationship45.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship45.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship45.m_HeadGuid = uint64_t(42);
relationship45.m_TailGuid = uint64_t(9690680943817437852U);
timelineDecoder.CreateRelationship(relationship45);
- ITimelineDecoder::Relationship relationship46;
+ arm::pipe::ITimelineDecoder::Relationship relationship46;
relationship46.m_Guid = uint64_t(46);
- relationship46.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship46.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship46.m_HeadGuid = uint64_t(45);
relationship46.m_TailGuid = uint64_t(10874037804557439415U);
timelineDecoder.CreateRelationship(relationship46);
- ITimelineDecoder::Relationship relationship47;
+ arm::pipe::ITimelineDecoder::Relationship relationship47;
relationship47.m_Guid = uint64_t(47);
- relationship47.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink;
+ relationship47.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
relationship47.m_HeadGuid = uint64_t(2);
relationship47.m_TailGuid = uint64_t(42);
timelineDecoder.CreateRelationship(relationship47);
- ITimelineDecoder::Entity entity48;
+ arm::pipe::ITimelineDecoder::Entity entity48;
entity48.m_Guid = uint64_t(48);
timelineDecoder.CreateEntity(entity48);
- ITimelineDecoder::Relationship relationship49;
+ arm::pipe::ITimelineDecoder::Relationship relationship49;
relationship49.m_Guid = uint64_t(49);
- relationship49.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship49.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship49.m_HeadGuid = uint64_t(48);
relationship49.m_TailGuid = uint64_t(15026600058430441282U);
timelineDecoder.CreateRelationship(relationship49);
- ITimelineDecoder::Relationship relationship50;
+ arm::pipe::ITimelineDecoder::Relationship relationship50;
relationship50.m_Guid = uint64_t(50);
- relationship50.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship50.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship50.m_HeadGuid = uint64_t(49);
relationship50.m_TailGuid = uint64_t(14196220359693045352U);
timelineDecoder.CreateRelationship(relationship50);
- ITimelineDecoder::Relationship relationship51;
+ arm::pipe::ITimelineDecoder::Relationship relationship51;
relationship51.m_Guid = uint64_t(51);
- relationship51.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink;
+ relationship51.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
relationship51.m_HeadGuid = uint64_t(6);
relationship51.m_TailGuid = uint64_t(48);
timelineDecoder.CreateRelationship(relationship51);
- ITimelineDecoder::Relationship relationship53;
+ arm::pipe::ITimelineDecoder::Relationship relationship53;
relationship53.m_Guid = uint64_t(53);
- relationship53.m_RelationshipType = ITimelineDecoder::RelationshipType::DataLink;
+ relationship53.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
relationship53.m_HeadGuid = uint64_t(48);
relationship53.m_TailGuid = uint64_t(52);
timelineDecoder.CreateRelationship(relationship53);
- ITimelineDecoder::Relationship relationship54;
+ arm::pipe::ITimelineDecoder::Relationship relationship54;
relationship54.m_Guid = uint64_t(54);
- relationship54.m_RelationshipType = ITimelineDecoder::RelationshipType::ExecutionLink;
+ relationship54.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
relationship54.m_HeadGuid = uint64_t(52);
relationship54.m_TailGuid = uint64_t(17170418158534996719U);
timelineDecoder.CreateRelationship(relationship54);
- ITimelineDecoder::Entity entity55;
+ arm::pipe::ITimelineDecoder::Entity entity55;
entity55.m_Guid = uint64_t(55);
timelineDecoder.CreateEntity(entity55);
- ITimelineDecoder::Relationship relationship56;
+ arm::pipe::ITimelineDecoder::Relationship relationship56;
relationship56.m_Guid = uint64_t(56);
- relationship56.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship56.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship56.m_HeadGuid = uint64_t(55);
relationship56.m_TailGuid = uint64_t(10172155312650606003U);
timelineDecoder.CreateRelationship(relationship56);
- ITimelineDecoder::Relationship relationship57;
+ arm::pipe::ITimelineDecoder::Relationship relationship57;
relationship57.m_Guid = uint64_t(57);
- relationship57.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship57.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship57.m_HeadGuid = uint64_t(56);
relationship57.m_TailGuid = uint64_t(14196220359693045352U);
timelineDecoder.CreateRelationship(relationship57);
- ITimelineDecoder::Relationship relationship58;
+ arm::pipe::ITimelineDecoder::Relationship relationship58;
relationship58.m_Guid = uint64_t(58);
- relationship58.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink;
+ relationship58.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
relationship58.m_HeadGuid = uint64_t(48);
relationship58.m_TailGuid = uint64_t(55);
timelineDecoder.CreateRelationship(relationship58);
- ITimelineDecoder::Relationship relationship59;
+ arm::pipe::ITimelineDecoder::Relationship relationship59;
relationship59.m_Guid = uint64_t(59);
- relationship59.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink;
+ relationship59.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
relationship59.m_HeadGuid = uint64_t(36);
relationship59.m_TailGuid = uint64_t(55);
timelineDecoder.CreateRelationship(relationship59);
- ITimelineDecoder::Event event60;
+ arm::pipe::ITimelineDecoder::Event event60;
event60.m_Guid = uint64_t(60);
event60.m_TimeStamp = uint64_t(96557081111036);
event60.m_ThreadId = uint64_t(140522431862592);
timelineDecoder.CreateEvent(event60);
- ITimelineDecoder::Relationship relationship61;
+ arm::pipe::ITimelineDecoder::Relationship relationship61;
relationship61.m_Guid = uint64_t(61);
- relationship61.m_RelationshipType = ITimelineDecoder::RelationshipType::ExecutionLink;
+ relationship61.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
relationship61.m_HeadGuid = uint64_t(55);
relationship61.m_TailGuid = uint64_t(60);
timelineDecoder.CreateRelationship(relationship61);
- ITimelineDecoder::Relationship relationship62;
+ arm::pipe::ITimelineDecoder::Relationship relationship62;
relationship62.m_Guid = uint64_t(62);
- relationship62.m_RelationshipType = ITimelineDecoder::RelationshipType::DataLink;
+ relationship62.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
relationship62.m_HeadGuid = uint64_t(60);
relationship62.m_TailGuid = uint64_t(17170418158534996719U);
timelineDecoder.CreateRelationship(relationship62);
- ITimelineDecoder::Event event63;
+ arm::pipe::ITimelineDecoder::Event event63;
event63.m_Guid = uint64_t(63);
event63.m_TimeStamp = uint64_t(96557081149730);
event63.m_ThreadId = uint64_t(140522431862592);
timelineDecoder.CreateEvent(event63);
- ITimelineDecoder::Relationship relationship64;
+ arm::pipe::ITimelineDecoder::Relationship relationship64;
relationship64.m_Guid = uint64_t(61);
- relationship64.m_RelationshipType = ITimelineDecoder::RelationshipType::ExecutionLink;
+ relationship64.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
relationship64.m_HeadGuid = uint64_t(55);
relationship64.m_TailGuid = uint64_t(63);
timelineDecoder.CreateRelationship(relationship64);
- ITimelineDecoder::Relationship relationship65;
+ arm::pipe::ITimelineDecoder::Relationship relationship65;
relationship65.m_Guid = uint64_t(62);
- relationship65.m_RelationshipType = ITimelineDecoder::RelationshipType::DataLink;
+ relationship65.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
relationship65.m_HeadGuid = uint64_t(63);
relationship65.m_TailGuid = uint64_t(10812061579584851344U);
timelineDecoder.CreateRelationship(relationship65);
- ITimelineDecoder::Entity entity66;
+ arm::pipe::ITimelineDecoder::Entity entity66;
entity66.m_Guid = uint64_t(66);
timelineDecoder.CreateEntity(entity66);
- ITimelineDecoder::Relationship relationship67;
+ arm::pipe::ITimelineDecoder::Relationship relationship67;
relationship67.m_Guid = uint64_t(67);
- relationship67.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship67.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship67.m_HeadGuid = uint64_t(66);
relationship67.m_TailGuid = uint64_t(10172155312650606003U);
timelineDecoder.CreateRelationship(relationship67);
- ITimelineDecoder::Relationship relationship68;
+ arm::pipe::ITimelineDecoder::Relationship relationship68;
relationship68.m_Guid = uint64_t(68);
- relationship68.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship68.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship68.m_HeadGuid = uint64_t(67);
relationship68.m_TailGuid = uint64_t(14196220359693045352U);
timelineDecoder.CreateRelationship(relationship68);
- ITimelineDecoder::Relationship relationship69;
+ arm::pipe::ITimelineDecoder::Relationship relationship69;
relationship69.m_Guid = uint64_t(69);
- relationship69.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink;
+ relationship69.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
relationship69.m_HeadGuid = uint64_t(48);
relationship69.m_TailGuid = uint64_t(66);
timelineDecoder.CreateRelationship(relationship69);
- ITimelineDecoder::Relationship relationship70;
+ arm::pipe::ITimelineDecoder::Relationship relationship70;
relationship70.m_Guid = uint64_t(70);
- relationship70.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink;
+ relationship70.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
relationship70.m_HeadGuid = uint64_t(22);
relationship70.m_TailGuid = uint64_t(66);
timelineDecoder.CreateRelationship(relationship70);
- ITimelineDecoder::Event event71;
+ arm::pipe::ITimelineDecoder::Event event71;
event71.m_Guid = uint64_t(71);
event71.m_TimeStamp = uint64_t(96557081156464);
event71.m_ThreadId = uint64_t(140522431862592);
timelineDecoder.CreateEvent(event71);
- ITimelineDecoder::Relationship relationship72;
+ arm::pipe::ITimelineDecoder::Relationship relationship72;
relationship72.m_Guid = uint64_t(72);
- relationship72.m_RelationshipType = ITimelineDecoder::RelationshipType::ExecutionLink;
+ relationship72.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
relationship72.m_HeadGuid = uint64_t(66);
relationship72.m_TailGuid = uint64_t(71);
timelineDecoder.CreateRelationship(relationship72);
- ITimelineDecoder::Relationship relationship73;
+ arm::pipe::ITimelineDecoder::Relationship relationship73;
relationship73.m_Guid = uint64_t(73);
- relationship73.m_RelationshipType = ITimelineDecoder::RelationshipType::DataLink;
+ relationship73.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
relationship73.m_HeadGuid = uint64_t(71);
relationship73.m_TailGuid = uint64_t(17170418158534996719U);
timelineDecoder.CreateRelationship(relationship73);
- ITimelineDecoder::Event event74;
+ arm::pipe::ITimelineDecoder::Event event74;
event74.m_Guid = uint64_t(74);
event74.m_TimeStamp = uint64_t(96557081220825);
event74.m_ThreadId = uint64_t(140522431862592);
timelineDecoder.CreateEvent(event74);
- ITimelineDecoder::Relationship relationship75;
+ arm::pipe::ITimelineDecoder::Relationship relationship75;
relationship75.m_Guid = uint64_t(75);
- relationship75.m_RelationshipType = ITimelineDecoder::RelationshipType::ExecutionLink;
+ relationship75.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
relationship75.m_HeadGuid = uint64_t(66);
relationship75.m_TailGuid = uint64_t(74);
timelineDecoder.CreateRelationship(relationship75);
- ITimelineDecoder::Relationship relationship76;
+ arm::pipe::ITimelineDecoder::Relationship relationship76;
relationship76.m_Guid = uint64_t(76);
- relationship76.m_RelationshipType = ITimelineDecoder::RelationshipType::DataLink;
+ relationship76.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
relationship76.m_HeadGuid = uint64_t(74);
relationship76.m_TailGuid = uint64_t(10812061579584851344U);
timelineDecoder.CreateRelationship(relationship76);
- ITimelineDecoder::Entity entity77;
+ arm::pipe::ITimelineDecoder::Entity entity77;
entity77.m_Guid = uint64_t(77);
timelineDecoder.CreateEntity(entity77);
- ITimelineDecoder::Relationship relationship78;
+ arm::pipe::ITimelineDecoder::Relationship relationship78;
relationship78.m_Guid = uint64_t(78);
- relationship78.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship78.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship78.m_HeadGuid = uint64_t(77);
relationship78.m_TailGuid = uint64_t(10172155312650606003U);
timelineDecoder.CreateRelationship(relationship78);
- ITimelineDecoder::Relationship relationship79;
+ arm::pipe::ITimelineDecoder::Relationship relationship79;
relationship79.m_Guid = uint64_t(79);
- relationship79.m_RelationshipType = ITimelineDecoder::RelationshipType::LabelLink;
+ relationship79.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
relationship79.m_HeadGuid = uint64_t(78);
relationship79.m_TailGuid = uint64_t(14196220359693045352U);
timelineDecoder.CreateRelationship(relationship79);
- ITimelineDecoder::Relationship relationship80;
+ arm::pipe::ITimelineDecoder::Relationship relationship80;
relationship80.m_Guid = uint64_t(80);
- relationship80.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink;
+ relationship80.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
relationship80.m_HeadGuid = uint64_t(48);
relationship80.m_TailGuid = uint64_t(77);
timelineDecoder.CreateRelationship(relationship80);
- ITimelineDecoder::Relationship relationship81;
+ arm::pipe::ITimelineDecoder::Relationship relationship81;
relationship81.m_Guid = uint64_t(81);
- relationship81.m_RelationshipType = ITimelineDecoder::RelationshipType::RetentionLink;
+ relationship81.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
relationship81.m_HeadGuid = uint64_t(42);
relationship81.m_TailGuid = uint64_t(77);
timelineDecoder.CreateRelationship(relationship81);
- ITimelineDecoder::Event event82;
+ arm::pipe::ITimelineDecoder::Event event82;
event82.m_Guid = uint64_t(82);
event82.m_TimeStamp = uint64_t(96557081227643);
event82.m_ThreadId = uint64_t(140522431862592);
timelineDecoder.CreateEvent(event82);
- ITimelineDecoder::Relationship relationship83;
+ arm::pipe::ITimelineDecoder::Relationship relationship83;
relationship83.m_Guid = uint64_t(83);
- relationship83.m_RelationshipType = ITimelineDecoder::RelationshipType::ExecutionLink;
+ relationship83.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
relationship83.m_HeadGuid = uint64_t(77);
relationship83.m_TailGuid = uint64_t(82);
timelineDecoder.CreateRelationship(relationship83);
- ITimelineDecoder::Relationship relationship84;
+ arm::pipe::ITimelineDecoder::Relationship relationship84;
relationship84.m_Guid = uint64_t(84);
- relationship84.m_RelationshipType = ITimelineDecoder::RelationshipType::DataLink;
+ relationship84.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
relationship84.m_HeadGuid = uint64_t(82);
relationship84.m_TailGuid = uint64_t(17170418158534996719U);
timelineDecoder.CreateRelationship(relationship84);
- ITimelineDecoder::Event event85;
+ arm::pipe::ITimelineDecoder::Event event85;
event85.m_Guid = uint64_t(85);
event85.m_TimeStamp = uint64_t(96557081240332);
event85.m_ThreadId = uint64_t(140522431862592);
timelineDecoder.CreateEvent(event85);
- ITimelineDecoder::Relationship relationship86;
+ arm::pipe::ITimelineDecoder::Relationship relationship86;
relationship86.m_Guid = uint64_t(86);
- relationship86.m_RelationshipType = ITimelineDecoder::RelationshipType::ExecutionLink;
+ relationship86.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
relationship86.m_HeadGuid = uint64_t(77);
relationship86.m_TailGuid = uint64_t(85);
timelineDecoder.CreateRelationship(relationship86);
- ITimelineDecoder::Relationship relationship87;
+ arm::pipe::ITimelineDecoder::Relationship relationship87;
relationship87.m_Guid = uint64_t(87);
- relationship87.m_RelationshipType = ITimelineDecoder::RelationshipType::DataLink;
+ relationship87.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
relationship87.m_HeadGuid = uint64_t(85);
relationship87.m_TailGuid = uint64_t(10812061579584851344U);
timelineDecoder.CreateRelationship(relationship87);
- ITimelineDecoder::Event event88;
+ arm::pipe::ITimelineDecoder::Event event88;
event88.m_Guid = uint64_t(88);
event88.m_TimeStamp = uint64_t(96557081243146);
event88.m_ThreadId = uint64_t(140522431862592);
timelineDecoder.CreateEvent(event88);
- ITimelineDecoder::Relationship relationship89;
+ arm::pipe::ITimelineDecoder::Relationship relationship89;
relationship89.m_Guid = uint64_t(89);
- relationship89.m_RelationshipType = ITimelineDecoder::RelationshipType::ExecutionLink;
+ relationship89.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
relationship89.m_HeadGuid = uint64_t(48);
relationship89.m_TailGuid = uint64_t(88);
timelineDecoder.CreateRelationship(relationship89);
- ITimelineDecoder::Relationship relationship90;
+ arm::pipe::ITimelineDecoder::Relationship relationship90;
relationship90.m_Guid = uint64_t(90);
- relationship90.m_RelationshipType = ITimelineDecoder::RelationshipType::DataLink;
+ relationship90.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
relationship90.m_HeadGuid = uint64_t(88);
relationship90.m_TailGuid = uint64_t(10812061579584851344U);
timelineDecoder.CreateRelationship(relationship90);
diff --git a/tests/profiling/gatordmock/CommandFileParser.cpp b/tests/profiling/gatordmock/CommandFileParser.cpp
index 503af8fc08..35a59ec537 100644
--- a/tests/profiling/gatordmock/CommandFileParser.cpp
+++ b/tests/profiling/gatordmock/CommandFileParser.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/tests/profiling/gatordmock/CommandFileParser.hpp b/tests/profiling/gatordmock/CommandFileParser.hpp
index fd4a4fdf38..cd2c8e6976 100644
--- a/tests/profiling/gatordmock/CommandFileParser.hpp
+++ b/tests/profiling/gatordmock/CommandFileParser.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/tests/profiling/gatordmock/CommandLineProcessor.cpp b/tests/profiling/gatordmock/CommandLineProcessor.cpp
index 55b51137bc..2903dbbfe3 100644
--- a/tests/profiling/gatordmock/CommandLineProcessor.cpp
+++ b/tests/profiling/gatordmock/CommandLineProcessor.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/tests/profiling/gatordmock/CommandLineProcessor.hpp b/tests/profiling/gatordmock/CommandLineProcessor.hpp
index 532948a5cf..1724470dbb 100644
--- a/tests/profiling/gatordmock/CommandLineProcessor.hpp
+++ b/tests/profiling/gatordmock/CommandLineProcessor.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
diff --git a/tests/profiling/gatordmock/CounterDirectory.hpp b/tests/profiling/gatordmock/CounterDirectory.hpp
index 31718dd817..14e7a94383 100644
--- a/tests/profiling/gatordmock/CounterDirectory.hpp
+++ b/tests/profiling/gatordmock/CounterDirectory.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -9,8 +9,9 @@
#include "GatordMockService.hpp"
#include "MockUtils.hpp"
-#include <Packet.hpp>
-#include "CommandHandlerFunctor.hpp"
+#include <common/include/Packet.hpp>
+#include <common/include/CommandHandlerFunctor.hpp>
+
#include "SendCounterPacket.hpp"
#include "IPeriodicCounterCapture.hpp"
diff --git a/tests/profiling/gatordmock/GatordMockMain.cpp b/tests/profiling/gatordmock/GatordMockMain.cpp
index 5d6e8869f6..cda1ff148f 100644
--- a/tests/profiling/gatordmock/GatordMockMain.cpp
+++ b/tests/profiling/gatordmock/GatordMockMain.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -7,7 +7,7 @@
#include "CommandLineProcessor.hpp"
#include "GatordMockService.hpp"
-#include <ConnectionHandler.hpp>
+#include <server/include/basePipeServer/ConnectionHandler.hpp>
#include <string>
#include <signal.h>
@@ -19,11 +19,11 @@ using namespace gatordmock;
static volatile bool run = true;
void exit_capture(int signum)
{
- IgnoreUnused(signum);
+ arm::pipe::IgnoreUnused(signum);
run = false;
}
-bool CreateMockService(std::unique_ptr<armnnProfiling::BasePipeServer> basePipeServer,
+bool CreateMockService(std::unique_ptr<arm::pipe::BasePipeServer> basePipeServer,
std::string commandFile,
bool isEchoEnabled)
{
@@ -65,7 +65,7 @@ int main(int argc, char* argv[])
std::string commandFile = cmdLine.GetCommandFile();
// make the socket non-blocking so we can exit the loop
- armnnProfiling::ConnectionHandler connectionHandler(cmdLine.GetUdsNamespace(), true);
+ arm::pipe::ConnectionHandler connectionHandler(cmdLine.GetUdsNamespace(), true);
while (run)
{
diff --git a/tests/profiling/gatordmock/GatordMockService.cpp b/tests/profiling/gatordmock/GatordMockService.cpp
index 13f688225b..8514091432 100644
--- a/tests/profiling/gatordmock/GatordMockService.cpp
+++ b/tests/profiling/gatordmock/GatordMockService.cpp
@@ -1,24 +1,20 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "GatordMockService.hpp"
-#include <CommandHandlerRegistry.hpp>
-#include <PacketVersionResolver.hpp>
-#include <ProfilingUtils.hpp>
-#include <NetworkSockets.hpp>
-
-#include <armnn/utility/Assert.hpp>
+#include <common/include/Assert.hpp>
+#include <common/include/CommandHandlerRegistry.hpp>
+#include <common/include/CommonProfilingUtils.hpp>
+#include <common/include/PacketVersionResolver.hpp>
+#include <common/include/NetworkSockets.hpp>
#include <cerrno>
-#include <iomanip>
#include <iostream>
#include <string>
-using namespace armnnUtils;
-
namespace armnn
{
@@ -125,11 +121,11 @@ void GatordMockService::SendPeriodicCounterSelectionList(uint32_t period, std::v
unsigned char* data = reinterpret_cast<unsigned char*>(uniqueData.get());
uint32_t offset = 0;
- profiling::WriteUint32(data, offset, period);
+ arm::pipe::WriteUint32(data, offset, period);
offset += 4;
for (std::vector<uint16_t>::iterator it = counters.begin(); it != counters.end(); ++it)
{
- profiling::WriteUint16(data, offset, *it);
+ arm::pipe::WriteUint16(data, offset, *it);
offset += 2;
}
@@ -164,33 +160,33 @@ void GatordMockService::ReceiveLoop()
{
try
{
- profiling::Packet packet = m_BasePipeServer.get()->WaitForPacket(500);
+ arm::pipe::Packet packet = m_BasePipeServer.get()->WaitForPacket(500);
- profiling::PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
- profiling::Version version =
+ arm::pipe::Version version =
packetVersionResolver.ResolvePacketVersion(packet.GetPacketFamily(), packet.GetPacketId());
- profiling::CommandHandlerFunctor* commandHandlerFunctor = m_HandlerRegistry.GetFunctor(
+ arm::pipe::CommandHandlerFunctor* commandHandlerFunctor = m_HandlerRegistry.GetFunctor(
packet.GetPacketFamily(),
packet.GetPacketId(),
version.GetEncodedValue());
- ARMNN_ASSERT(commandHandlerFunctor);
+ ARM_PIPE_ASSERT(commandHandlerFunctor);
commandHandlerFunctor->operator()(packet);
}
- catch (const armnn::TimeoutException&)
+ catch (const arm::pipe::TimeoutException&)
{
// In this case we ignore timeouts and and keep trying to receive.
}
- catch (const armnn::InvalidArgumentException& e)
+ catch (const arm::pipe::InvalidArgumentException& e)
{
// We couldn't find a functor to handle the packet?
std::cerr << "Packet received that could not be processed: " << e.what() << std::endl;
}
- catch (const armnn::RuntimeException& e)
+ catch (const arm::pipe::ProfilingException& e)
{
// A runtime exception occurred which means we must exit the loop.
std::cerr << "Receive thread closing: " << e.what() << std::endl;
diff --git a/tests/profiling/gatordmock/GatordMockService.hpp b/tests/profiling/gatordmock/GatordMockService.hpp
index 8bad41cdfb..1c45d4ea98 100644
--- a/tests/profiling/gatordmock/GatordMockService.hpp
+++ b/tests/profiling/gatordmock/GatordMockService.hpp
@@ -1,28 +1,31 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include <CommandHandlerRegistry.hpp>
-#include <Packet.hpp>
-
-#include <atomic>
-#include <string>
-#include <thread>
-
-#include <TimelineDecoder.hpp>
-#include <DirectoryCaptureCommandHandler.hpp>
-#include <TimelineCaptureCommandHandler.hpp>
-#include <TimelineDirectoryCaptureCommandHandler.hpp>
+// local includes
#include "PeriodicCounterCaptureCommandHandler.hpp"
#include "StreamMetadataCommandHandler.hpp"
+#include "StubCommandHandler.hpp"
-#include <BasePipeServer.hpp>
+#include <common/include/CommandHandlerRegistry.hpp>
+#include <common/include/Packet.hpp>
+#include <common/include/PacketVersionResolver.hpp>
-#include "PacketVersionResolver.hpp"
-#include "StubCommandHandler.hpp"
+#include <server/include/basePipeServer/BasePipeServer.hpp>
+
+#include <server/include/timelineDecoder/TimelineDecoder.hpp>
+#include <server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp>
+#include <server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp>
+
+// src/profiling
+#include <DirectoryCaptureCommandHandler.hpp>
+
+#include <atomic>
+#include <string>
+#include <thread>
namespace armnn
{
@@ -37,7 +40,7 @@ class GatordMockService
public:
/// @param registry reference to a command handler registry.
/// @param echoPackets if true the raw packets will be printed to stdout.
- GatordMockService(std::unique_ptr<armnnProfiling::BasePipeServer> clientConnection, bool echoPackets)
+ GatordMockService(std::unique_ptr<arm::pipe::BasePipeServer> clientConnection, bool echoPackets)
: m_BasePipeServer(std::move(clientConnection))
, m_EchoPackets(echoPackets)
, m_CloseReceivingThread(false)
@@ -122,12 +125,12 @@ public:
return m_DirectoryCaptureCommandHandler;
}
- timelinedecoder::TimelineDecoder& GetTimelineDecoder()
+ arm::pipe::TimelineDecoder& GetTimelineDecoder()
{
return m_TimelineDecoder;
}
- timelinedecoder::TimelineDirectoryCaptureCommandHandler& GetTimelineDirectoryCaptureCommandHandler()
+ arm::pipe::TimelineDirectoryCaptureCommandHandler& GetTimelineDirectoryCaptureCommandHandler()
{
return m_TimelineDirectoryCaptureCommandHandler;
}
@@ -135,7 +138,7 @@ public:
private:
void ReceiveLoop();
- std::unique_ptr<armnnProfiling::BasePipeServer> m_BasePipeServer;
+ std::unique_ptr<arm::pipe::BasePipeServer> m_BasePipeServer;
std::atomic<uint32_t> m_PacketsReceivedCount;
@@ -143,10 +146,10 @@ private:
std::thread m_ListeningThread;
std::atomic<bool> m_CloseReceivingThread;
- profiling::PacketVersionResolver m_PacketVersionResolver;
- profiling::CommandHandlerRegistry m_HandlerRegistry;
+ arm::pipe::PacketVersionResolver m_PacketVersionResolver;
+ arm::pipe::CommandHandlerRegistry m_HandlerRegistry;
- timelinedecoder::TimelineDecoder m_TimelineDecoder;
+ arm::pipe::TimelineDecoder m_TimelineDecoder;
gatordmock::PeriodicCounterCaptureCommandHandler m_CounterCaptureCommandHandler;
gatordmock::StreamMetadataCommandHandler m_StreamMetadataCommandHandler;
@@ -154,8 +157,8 @@ private:
profiling::DirectoryCaptureCommandHandler m_DirectoryCaptureCommandHandler;
- timelinedecoder::TimelineCaptureCommandHandler m_TimelineCaptureCommandHandler;
- timelinedecoder::TimelineDirectoryCaptureCommandHandler m_TimelineDirectoryCaptureCommandHandler;
+ arm::pipe::TimelineCaptureCommandHandler m_TimelineCaptureCommandHandler;
+ arm::pipe::TimelineDirectoryCaptureCommandHandler m_TimelineDirectoryCaptureCommandHandler;
};
} // namespace gatordmock
diff --git a/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp b/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp
index 9dd7064c90..fac813979d 100644
--- a/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp
+++ b/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp
@@ -1,13 +1,13 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "PeriodicCounterCaptureCommandHandler.hpp"
-#include <ProfilingUtils.hpp>
+#include <common/include/CommonProfilingUtils.hpp>
-#include <boost/numeric/conversion/cast.hpp>
+#include <armnn/utility/NumericCast.hpp>
#include <iostream>
@@ -17,16 +17,14 @@ namespace armnn
namespace gatordmock
{
-using boost::numeric_cast;
-
-void PeriodicCounterCaptureCommandHandler::ParseData(const armnn::profiling::Packet& packet)
+void PeriodicCounterCaptureCommandHandler::ParseData(const arm::pipe::Packet& packet)
{
std::vector<uint16_t> counterIds;
std::vector<uint32_t> counterValues;
- uint32_t sizeOfUint64 = numeric_cast<uint32_t>(sizeof(uint64_t));
- uint32_t sizeOfUint32 = numeric_cast<uint32_t>(sizeof(uint32_t));
- uint32_t sizeOfUint16 = numeric_cast<uint32_t>(sizeof(uint16_t));
+ uint32_t sizeOfUint64 = armnn::numeric_cast<uint32_t>(sizeof(uint64_t));
+ uint32_t sizeOfUint32 = armnn::numeric_cast<uint32_t>(sizeof(uint32_t));
+ uint32_t sizeOfUint16 = armnn::numeric_cast<uint32_t>(sizeof(uint16_t));
uint32_t offset = 0;
@@ -34,7 +32,7 @@ void PeriodicCounterCaptureCommandHandler::ParseData(const armnn::profiling::Pac
{
offset = 0;
- uint64_t timestamp = profiling::ReadUint64(reinterpret_cast<const unsigned char*>(packet.GetData()), offset);
+ uint64_t timestamp = arm::pipe::ReadUint64(reinterpret_cast<const unsigned char*>(packet.GetData()), offset);
if (m_FirstTimestamp == 0) // detect the first timestamp we receive.
{
@@ -59,11 +57,11 @@ void PeriodicCounterCaptureCommandHandler::ParseData(const armnn::profiling::Pac
for (unsigned int pos = 0; pos < counters; ++pos)
{
counterIds.emplace_back(
- profiling::ReadUint16(reinterpret_cast<const unsigned char*>(packet.GetData()), offset));
+ arm::pipe::ReadUint16(reinterpret_cast<const unsigned char*>(packet.GetData()), offset));
offset += sizeOfUint16;
counterValues.emplace_back(
- profiling::ReadUint32(reinterpret_cast<const unsigned char*>(packet.GetData()), offset));
+ arm::pipe::ReadUint32(reinterpret_cast<const unsigned char*>(packet.GetData()), offset));
offset += sizeOfUint32;
}
}
@@ -74,7 +72,7 @@ void PeriodicCounterCaptureCommandHandler::ParseData(const armnn::profiling::Pac
}
}
-void PeriodicCounterCaptureCommandHandler::operator()(const profiling::Packet& packet)
+void PeriodicCounterCaptureCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ParseData(packet);
if (!m_QuietOperation) // Are we supposed to print to stdout?
@@ -93,24 +91,24 @@ void PeriodicCounterCaptureCommandHandler::operator()(const profiling::Packet& p
valueString.append(", ");
}
- body.append(profiling::CentreAlignFormatting(std::to_string(m_CounterCaptureValues.m_Timestamp), 10));
+ body.append(arm::pipe::CentreAlignFormatting(std::to_string(m_CounterCaptureValues.m_Timestamp), 10));
body.append(" | ");
- body.append(profiling::CentreAlignFormatting(std::to_string(m_CurrentPeriodValue), 13));
+ body.append(arm::pipe::CentreAlignFormatting(std::to_string(m_CurrentPeriodValue), 13));
body.append(" | ");
- body.append(profiling::CentreAlignFormatting(uidString, 10));
+ body.append(arm::pipe::CentreAlignFormatting(uidString, 10));
body.append(" | ");
- body.append(profiling::CentreAlignFormatting(valueString, 10));
+ body.append(arm::pipe::CentreAlignFormatting(valueString, 10));
body.append("\n");
if (!m_HeaderPrinted)
{
- header.append(profiling::CentreAlignFormatting(" Timestamp", 11));
+ header.append(arm::pipe::CentreAlignFormatting(" Timestamp", 11));
header.append(" | ");
- header.append(profiling::CentreAlignFormatting("Period (us)", 13));
+ header.append(arm::pipe::CentreAlignFormatting("Period (us)", 13));
header.append(" | ");
- header.append(profiling::CentreAlignFormatting("UID's", static_cast<int>(uidString.size())));
+ header.append(arm::pipe::CentreAlignFormatting("UID's", static_cast<int>(uidString.size())));
header.append(" | ");
- header.append(profiling::CentreAlignFormatting("Values", 10));
+ header.append(arm::pipe::CentreAlignFormatting("Values", 10));
header.append("\n");
std::cout << header;
diff --git a/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp b/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp
index 478d0a6ca9..60a448c8ef 100644
--- a/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp
+++ b/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp
@@ -1,12 +1,12 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include <Packet.hpp>
-#include <CommandHandlerFunctor.hpp>
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
#include <vector>
@@ -23,7 +23,7 @@ struct CounterCaptureValues
std::vector<uint32_t> m_Values;
};
-class PeriodicCounterCaptureCommandHandler : public profiling::CommandHandlerFunctor
+class PeriodicCounterCaptureCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
@@ -41,14 +41,14 @@ public:
, m_QuietOperation(quietOperation)
{}
- void operator()(const armnn::profiling::Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
CounterCaptureValues m_CounterCaptureValues;
uint64_t m_CurrentPeriodValue = 0;
private:
- void ParseData(const armnn::profiling::Packet& packet);
+ void ParseData(const arm::pipe::Packet& packet);
uint64_t m_FirstTimestamp = 0, m_SecondTimestamp = 0;
diff --git a/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.cpp b/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.cpp
index 2c2e71170a..43d686c73f 100644
--- a/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.cpp
+++ b/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.cpp
@@ -1,11 +1,11 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "PeriodicCounterSelectionResponseHandler.hpp"
-#include <ProfilingUtils.hpp>
+#include <common/include/CommonProfilingUtils.hpp>
#include <iostream>
@@ -15,11 +15,11 @@ namespace armnn
namespace gatordmock
{
-void PeriodicCounterSelectionResponseHandler::operator()(const profiling::Packet& packet)
+void PeriodicCounterSelectionResponseHandler::operator()(const arm::pipe::Packet& packet)
{
if (!m_QuietOperation) // Are we supposed to print to stdout?
{
- uint32_t period = profiling::ReadUint32(reinterpret_cast<const unsigned char*>(packet.GetData()), 0);
+ uint32_t period = arm::pipe::ReadUint32(reinterpret_cast<const unsigned char*>(packet.GetData()), 0);
uint32_t numCounters = 0;
// First check if there are any counters mentioned.
if(packet.GetLength() > 4)
diff --git a/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp b/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp
index c075857816..46da688ae1 100644
--- a/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp
+++ b/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp
@@ -1,11 +1,11 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include <CommandHandlerFunctor.hpp>
-#include <Packet.hpp>
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
#include <vector>
@@ -15,7 +15,7 @@ namespace armnn
namespace gatordmock
{
-class PeriodicCounterSelectionResponseHandler : public profiling::CommandHandlerFunctor
+class PeriodicCounterSelectionResponseHandler : public arm::pipe::CommandHandlerFunctor
{
public:
@@ -33,7 +33,7 @@ public:
, m_QuietOperation(quietOperation)
{}
- void operator()(const armnn::profiling::Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
private:
bool m_QuietOperation;
diff --git a/tests/profiling/gatordmock/StreamMetadataCommandHandler.cpp b/tests/profiling/gatordmock/StreamMetadataCommandHandler.cpp
index d97925cc15..e547e90798 100644
--- a/tests/profiling/gatordmock/StreamMetadataCommandHandler.cpp
+++ b/tests/profiling/gatordmock/StreamMetadataCommandHandler.cpp
@@ -1,15 +1,14 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "StreamMetadataCommandHandler.hpp"
-#include <ProfilingUtils.hpp>
+#include <common/include/CommonProfilingUtils.hpp>
#include <iostream>
-
-using namespace armnn::profiling;
+#include <sstream>
namespace armnn
{
@@ -17,7 +16,7 @@ namespace armnn
namespace gatordmock
{
-void StreamMetadataCommandHandler::operator()(const Packet& packet)
+void StreamMetadataCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ParseData(packet);
@@ -57,7 +56,7 @@ std::string ReadString(const unsigned char* buffer, unsigned int &offset)
return stringPtr != nullptr ? std::string(stringPtr) : "";
}
-void StreamMetadataCommandHandler::ParseData(const Packet &packet)
+void StreamMetadataCommandHandler::ParseData(const arm::pipe::Packet &packet)
{
// Check that at least the packet contains the fixed-length fields
if (packet.GetLength() < 80)
@@ -73,23 +72,23 @@ void StreamMetadataCommandHandler::ParseData(const Packet &packet)
unsigned int offset = 0;
// Get the fixed-length fields
- m_PipeMagic = ReadUint32(buffer, offset);
+ m_PipeMagic = arm::pipe::ReadUint32(buffer, offset);
offset += uint32_t_size;
- m_StreamMetadataVersion = ReadUint32(buffer, offset);
+ m_StreamMetadataVersion = arm::pipe::ReadUint32(buffer, offset);
offset += uint32_t_size;
- m_MaxDataLen = ReadUint32(buffer, offset);
+ m_MaxDataLen = arm::pipe::ReadUint32(buffer, offset);
offset += uint32_t_size;
- m_Pid = ReadUint32(buffer, offset);
+ m_Pid = arm::pipe::ReadUint32(buffer, offset);
offset += uint32_t_size;
- m_OffsetInfo = ReadUint32(buffer, offset);
+ m_OffsetInfo = arm::pipe::ReadUint32(buffer, offset);
offset += uint32_t_size;
- m_OffsetHwVersion = ReadUint32(buffer, offset);
+ m_OffsetHwVersion = arm::pipe::ReadUint32(buffer, offset);
offset += uint32_t_size;
- m_OffsetSwVersion = ReadUint32(buffer, offset);
+ m_OffsetSwVersion = arm::pipe::ReadUint32(buffer, offset);
offset += uint32_t_size;
- m_OffsetProcessName = ReadUint32(buffer, offset);
+ m_OffsetProcessName = arm::pipe::ReadUint32(buffer, offset);
offset += uint32_t_size;
- m_OffsetPacketVersionTable = ReadUint32(buffer, offset);
+ m_OffsetPacketVersionTable = arm::pipe::ReadUint32(buffer, offset);
offset += uint32_t_size * 2; // Also skipping the reserved word (all zeros)
// Get the string fields
@@ -103,15 +102,15 @@ void StreamMetadataCommandHandler::ParseData(const Packet &packet)
if (m_OffsetPacketVersionTable > 0)
{
offset = m_OffsetPacketVersionTable;
- uint16_t packetEntries = ReadUint16(buffer, offset + uint16_t_size);
+ uint16_t packetEntries = arm::pipe::ReadUint16(buffer, offset + uint16_t_size);
offset += uint32_t_size; // Also skipping the reserved bytes (all zeros)
for (uint16_t i = 0; i < packetEntries; i++)
{
- uint16_t packetFamilyAndId = ReadUint16(buffer, offset + uint16_t_size);
+ uint16_t packetFamilyAndId = arm::pipe::ReadUint16(buffer, offset + uint16_t_size);
uint16_t packetFamily = (packetFamilyAndId >> 10) & 0x003F;
uint16_t packetId = (packetFamilyAndId >> 0) & 0x03FF;
offset += uint32_t_size; // Also skipping the reserved bytes (all zeros)
- uint32_t packetVersion = ReadUint32(buffer, offset);
+ uint32_t packetVersion = arm::pipe::ReadUint32(buffer, offset);
offset += uint32_t_size;
m_PacketVersionTable.push_back({ packetFamily, packetId, packetVersion });
diff --git a/tests/profiling/gatordmock/StreamMetadataCommandHandler.hpp b/tests/profiling/gatordmock/StreamMetadataCommandHandler.hpp
index 4558345e67..ceb77d1b51 100644
--- a/tests/profiling/gatordmock/StreamMetadataCommandHandler.hpp
+++ b/tests/profiling/gatordmock/StreamMetadataCommandHandler.hpp
@@ -1,12 +1,12 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include <Packet.hpp>
-#include <CommandHandlerFunctor.hpp>
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
#include <vector>
@@ -23,7 +23,7 @@ struct PacketVersion
uint32_t m_PacketVersion;
};
-class StreamMetadataCommandHandler : public profiling::CommandHandlerFunctor
+class StreamMetadataCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
@@ -41,10 +41,10 @@ public:
, m_QuietOperation(quietOperation)
{}
- void operator()(const armnn::profiling::Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
private:
- void ParseData(const armnn::profiling::Packet& packet);
+ void ParseData(const arm::pipe::Packet& packet);
uint32_t m_PipeMagic;
uint32_t m_StreamMetadataVersion;
diff --git a/tests/profiling/gatordmock/StubCommandHandler.hpp b/tests/profiling/gatordmock/StubCommandHandler.hpp
index 450f90fd2b..50fb14b5de 100644
--- a/tests/profiling/gatordmock/StubCommandHandler.hpp
+++ b/tests/profiling/gatordmock/StubCommandHandler.hpp
@@ -1,11 +1,11 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include <CommandHandlerFunctor.hpp>
-#include <armnn/utility/IgnoreUnused.hpp>
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/IgnoreUnused.hpp>
#include <vector>
@@ -15,7 +15,7 @@ namespace armnn
namespace gatordmock
{
-class StubCommandHandler : public profiling::CommandHandlerFunctor
+class StubCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
@@ -30,10 +30,10 @@ public:
: CommandHandlerFunctor(familyId, packetId, version)
{}
- void operator()(const armnn::profiling::Packet& packet) override
+ void operator()(const arm::pipe::Packet& packet) override
{
//No op
- IgnoreUnused(packet);
+ arm::pipe::IgnoreUnused(packet);
}
};
diff --git a/tests/profiling/gatordmock/tests/GatordMockTests.cpp b/tests/profiling/gatordmock/tests/GatordMockTests.cpp
index e7eb0846c0..941e284928 100644
--- a/tests/profiling/gatordmock/tests/GatordMockTests.cpp
+++ b/tests/profiling/gatordmock/tests/GatordMockTests.cpp
@@ -3,16 +3,16 @@
// SPDX-License-Identifier: MIT
//
-#include <CommandHandlerRegistry.hpp>
-#include <ConnectionHandler.hpp>
+#include <common/include/CommandHandlerRegistry.hpp>
+#include <server/include/basePipeServer/ConnectionHandler.hpp>
#include <DirectoryCaptureCommandHandler.hpp>
#include <GatordMockService.hpp>
#include <LabelsAndEventClasses.hpp>
#include <ProfilingService.hpp>
#include <TimelinePacketWriterFactory.hpp>
-#include <TimelineDirectoryCaptureCommandHandler.hpp>
-#include <TimelineDecoder.hpp>
+#include <server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp>
+#include <server/include/timelineDecoder/TimelineDecoder.hpp>
#include <Runtime.hpp>
@@ -33,7 +33,7 @@ BOOST_AUTO_TEST_CASE(CounterCaptureHandlingTest)
{
using boost::numeric_cast;
- profiling::PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
// Data with timestamp, counter idx & counter values
std::vector<std::pair<uint16_t, uint32_t>> indexValuePairs;
@@ -91,8 +91,8 @@ BOOST_AUTO_TEST_CASE(CounterCaptureHandlingTest)
uint32_t headerWord1 = packetVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue();
// Create packet to send through to the command functor
- profiling::Packet packet1(headerWord1, dataLength, uniqueData1);
- profiling::Packet packet2(headerWord1, dataLength, uniqueData2);
+ arm::pipe::Packet packet1(headerWord1, dataLength, uniqueData1);
+ arm::pipe::Packet packet2(headerWord1, dataLength, uniqueData2);
gatordmock::PeriodicCounterCaptureCommandHandler commandHandler(0, 4, headerWord1, true);
@@ -122,7 +122,7 @@ void WaitFor(std::function<bool()> predicate, std::string errorMsg, uint32_t tim
}
}
-void CheckTimelineDirectory(timelinedecoder::TimelineDirectoryCaptureCommandHandler& commandHandler)
+void CheckTimelineDirectory(arm::pipe::TimelineDirectoryCaptureCommandHandler& commandHandler)
{
uint32_t uint8_t_size = sizeof(uint8_t);
uint32_t uint32_t_size = sizeof(uint32_t);
@@ -138,7 +138,7 @@ void CheckTimelineDirectory(timelinedecoder::TimelineDirectoryCaptureCommandHand
sendTimelinePacket->SendTimelineMessageDirectoryPackage();
sendTimelinePacket->Commit();
- std::vector<profiling::SwTraceMessage> swTraceBufferMessages;
+ std::vector<arm::pipe::SwTraceMessage> swTraceBufferMessages;
unsigned int offset = uint32_t_size * 2;
@@ -158,15 +158,15 @@ void CheckTimelineDirectory(timelinedecoder::TimelineDirectoryCaptureCommandHand
offset += uint32_t_size;
for(uint32_t i = 0; i < declarationSize; ++i)
{
- swTraceBufferMessages.push_back(profiling::ReadSwTraceMessage(packetBuffer->GetReadableData(),
+ swTraceBufferMessages.push_back(arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(),
offset,
packetBuffer->GetSize()));
}
for(uint32_t index = 0; index < declarationSize; ++index)
{
- profiling::SwTraceMessage& bufferMessage = swTraceBufferMessages[index];
- profiling::SwTraceMessage& handlerMessage = commandHandler.m_SwTraceMessages[index];
+ arm::pipe::SwTraceMessage& bufferMessage = swTraceBufferMessages[index];
+ arm::pipe::SwTraceMessage& handlerMessage = commandHandler.m_SwTraceMessages[index];
BOOST_CHECK(bufferMessage.m_Name == handlerMessage.m_Name);
BOOST_CHECK(bufferMessage.m_UiName == handlerMessage.m_UiName);
@@ -186,7 +186,7 @@ void CheckTimelineDirectory(timelinedecoder::TimelineDirectoryCaptureCommandHand
}
}
-void CheckTimelinePackets(timelinedecoder::TimelineDecoder& timelineDecoder)
+void CheckTimelinePackets(arm::pipe::TimelineDecoder& timelineDecoder)
{
unsigned int i = 0; // Use a postfix increment to avoid changing indexes each time the packet gets updated.
BOOST_CHECK(timelineDecoder.GetModel().m_Labels[i].m_Guid == profiling::LabelsAndEventClasses::NAME_GUID);
@@ -246,9 +246,9 @@ BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd)
// Setup the mock service to bind to the UDS.
std::string udsNamespace = "gatord_namespace";
- BOOST_CHECK_NO_THROW(armnnProfiling::ConnectionHandler connectionHandler(udsNamespace, false));
+ BOOST_CHECK_NO_THROW(arm::pipe::ConnectionHandler connectionHandler(udsNamespace, false));
- armnnProfiling::ConnectionHandler connectionHandler(udsNamespace, false);
+ arm::pipe::ConnectionHandler connectionHandler(udsNamespace, false);
// Enable the profiling service.
armnn::IRuntime::CreationOptions::ExternalProfilingOptions options;
@@ -270,7 +270,7 @@ BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd)
// Connect the profiling service to the mock Gatord.
gatordmock::GatordMockService mockService(std::move(basePipeServer), false);
- timelinedecoder::TimelineDecoder& timelineDecoder = mockService.GetTimelineDecoder();
+ arm::pipe::TimelineDecoder& timelineDecoder = mockService.GetTimelineDecoder();
profiling::DirectoryCaptureCommandHandler& directoryCaptureCommandHandler =
mockService.GetDirectoryCaptureCommandHandler();
@@ -401,7 +401,7 @@ BOOST_AUTO_TEST_CASE(GatorDMockTimeLineActivation)
// Setup the mock service to bind to the UDS.
std::string udsNamespace = "gatord_namespace";
- armnnProfiling::ConnectionHandler connectionHandler(udsNamespace, false);
+ arm::pipe::ConnectionHandler connectionHandler(udsNamespace, false);
armnn::IRuntime::CreationOptions options;
options.m_ProfilingOptions.m_EnableProfiling = true;
@@ -447,7 +447,7 @@ BOOST_AUTO_TEST_CASE(GatorDMockTimeLineActivation)
WaitFor([&](){return mockService.GetDirectoryCaptureCommandHandler().ParsedCounterDirectory();},
"MockGatord did not receive counter directory packet");
- timelinedecoder::TimelineDecoder& timelineDecoder = mockService.GetTimelineDecoder();
+ arm::pipe::TimelineDecoder& timelineDecoder = mockService.GetTimelineDecoder();
WaitFor([&](){return timelineDecoder.GetModel().m_EventClasses.size() >= 2;},
"MockGatord did not receive well known timeline labels");
diff --git a/third-party/fmt/src/format.cc b/third-party/fmt/src/format.cc
new file mode 100644
index 0000000000..a64a1f3893
--- /dev/null
+++ b/third-party/fmt/src/format.cc
@@ -0,0 +1,69 @@
+// Formatting library for C++
+//
+// Copyright (c) 2012 - 2016, Victor Zverovich
+// All rights reserved.
+//
+// For the license information refer to format.h.
+
+#include "fmt/format-inl.h"
+
+FMT_BEGIN_NAMESPACE
+namespace detail {
+
+template <typename T>
+int format_float(char* buf, std::size_t size, const char* format, int precision,
+ T value) {
+#ifdef FMT_FUZZ
+ if (precision > 100000)
+ throw std::runtime_error(
+ "fuzz mode - avoid large allocation inside snprintf");
+#endif
+ // Suppress the warning about nonliteral format string.
+ int (*snprintf_ptr)(char*, size_t, const char*, ...) = FMT_SNPRINTF;
+ return precision < 0 ? snprintf_ptr(buf, size, format, value)
+ : snprintf_ptr(buf, size, format, precision, value);
+}
+} // namespace detail
+
+template struct FMT_INSTANTIATION_DEF_API detail::basic_data<void>;
+
+// Workaround a bug in MSVC2013 that prevents instantiation of format_float.
+int (*instantiate_format_float)(double, int, detail::float_specs,
+ detail::buffer<char>&) = detail::format_float;
+
+#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
+template FMT_API detail::locale_ref::locale_ref(const std::locale& loc);
+template FMT_API std::locale detail::locale_ref::get<std::locale>() const;
+#endif
+
+// Explicit instantiations for char.
+
+template FMT_API std::string detail::grouping_impl<char>(locale_ref);
+template FMT_API char detail::thousands_sep_impl(locale_ref);
+template FMT_API char detail::decimal_point_impl(locale_ref);
+
+template FMT_API void detail::buffer<char>::append(const char*, const char*);
+
+template FMT_API FMT_BUFFER_CONTEXT(char)::iterator detail::vformat_to(
+ detail::buffer<char>&, string_view,
+ basic_format_args<FMT_BUFFER_CONTEXT(char)>);
+
+template FMT_API int detail::snprintf_float(double, int, detail::float_specs,
+ detail::buffer<char>&);
+template FMT_API int detail::snprintf_float(long double, int,
+ detail::float_specs,
+ detail::buffer<char>&);
+template FMT_API int detail::format_float(double, int, detail::float_specs,
+ detail::buffer<char>&);
+template FMT_API int detail::format_float(long double, int, detail::float_specs,
+ detail::buffer<char>&);
+
+// Explicit instantiations for wchar_t.
+
+template FMT_API std::string detail::grouping_impl<wchar_t>(locale_ref);
+template FMT_API wchar_t detail::thousands_sep_impl(locale_ref);
+template FMT_API wchar_t detail::decimal_point_impl(locale_ref);
+
+template FMT_API void detail::buffer<wchar_t>::append(const wchar_t*,
+ const wchar_t*);
+FMT_END_NAMESPACE