diff options
author | Jim Flynn <jim.flynn@arm.com> | 2022-03-16 00:27:43 +0000 |
---|---|---|
committer | Jim Flynn <jim.flynn@arm.com> | 2022-03-16 14:42:34 +0000 |
commit | 9c85b41a9fcb3c64d7a686373e7dde75630ccd49 (patch) | |
tree | 49ec983ec1ba499d5a5a9240b69f8f4bb9ca2082 /profiling | |
parent | 06ccd713391cca68dc8ab53b84bf058723ae55ab (diff) | |
download | armnn-9c85b41a9fcb3c64d7a686373e7dde75630ccd49.tar.gz |
IVGCVSW-6852 Break the remaining dependencies on Arm NN in the profiling code
Change-Id: I18b8ca22896567904768170350ee5eb22edd4a22
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
Diffstat (limited to 'profiling')
-rw-r--r-- | profiling/common/include/Processes.hpp | 2 | ||||
-rw-r--r-- | profiling/common/include/Threads.hpp | 16 | ||||
-rw-r--r-- | profiling/common/src/CMakeLists.txt | 3 | ||||
-rw-r--r-- | profiling/common/src/Processes.cpp | 2 | ||||
-rw-r--r-- | profiling/common/src/Threads.cpp | 45 | ||||
-rw-r--r-- | profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp | 4 | ||||
-rw-r--r-- | profiling/server/src/timelineDecoder/tests/TimelineTests.cpp | 6 |
7 files changed, 70 insertions, 8 deletions
diff --git a/profiling/common/include/Processes.hpp b/profiling/common/include/Processes.hpp index cc59d8b2d4..0a15368169 100644 --- a/profiling/common/include/Processes.hpp +++ b/profiling/common/include/Processes.hpp @@ -10,7 +10,7 @@ namespace arm namespace pipe { -int GetCurrentId(); +int GetCurrentProcessId(); } // namespace arm } // namespace pipe diff --git a/profiling/common/include/Threads.hpp b/profiling/common/include/Threads.hpp new file mode 100644 index 0000000000..1c24a3087b --- /dev/null +++ b/profiling/common/include/Threads.hpp @@ -0,0 +1,16 @@ +// +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +namespace arm +{ +namespace pipe +{ + +int GetCurrentThreadId(); + +} // namespace pipe +} // namespace arm diff --git a/profiling/common/src/CMakeLists.txt b/profiling/common/src/CMakeLists.txt index 3932186c51..e02c785581 100644 --- a/profiling/common/src/CMakeLists.txt +++ b/profiling/common/src/CMakeLists.txt @@ -10,12 +10,13 @@ if(BUILD_TIMELINE_DECODER) CommandHandlerKey.cpp CommandHandlerRegistry.cpp CommonProfilingUtils.cpp + LabelsAndEventClasses.cpp Logging.cpp NetworkSockets.cpp PacketVersionResolver.cpp Processes.cpp SwTrace.cpp - LabelsAndEventClasses.cpp) + Threads.cpp) include_directories(${PROJECT_SOURCE_DIR}/profiling/common/include) include_directories(${PROJECT_SOURCE_DIR}/common/include) diff --git a/profiling/common/src/Processes.cpp b/profiling/common/src/Processes.cpp index d6d4ca4950..94e809529a 100644 --- a/profiling/common/src/Processes.cpp +++ b/profiling/common/src/Processes.cpp @@ -16,7 +16,7 @@ namespace arm namespace pipe { -int GetCurrentId() +int GetCurrentProcessId() { #if defined(__unix__) || defined(__APPLE__) return getpid(); diff --git a/profiling/common/src/Threads.cpp b/profiling/common/src/Threads.cpp new file mode 100644 index 0000000000..10533b77b9 --- /dev/null +++ b/profiling/common/src/Threads.cpp @@ -0,0 +1,45 @@ +// +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "Threads.hpp" + +#if defined(__linux__) +#include <unistd.h> +#include <sys/syscall.h> +#define gettid() syscall(SYS_gettid) +#elif defined(_MSC_VER) +#include <common/include/WindowsWrapper.hpp> +#elif defined(__APPLE__) +#include "AvailabilityMacros.h" +#include <pthread.h> +#include <sys/syscall.h> +#include <sys/time.h> +#include <unistd.h> +#endif + +namespace arm +{ +namespace pipe +{ + +int GetCurrentThreadId() +{ +#if defined(__linux__) + return static_cast<int>(gettid()); +#elif defined(_MSC_VER) + return ::GetCurrentThreadId(); +#elif defined(__APPLE__) + uint64_t threadId; + int iRet = pthread_threadid_np(NULL, &threadId); + if (iRet != 0) + { + return 0; + } + return static_cast<int>(threadId); +#endif +} + +} // namespace pipe +} // namespace arm diff --git a/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp b/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp index 9993fc7a75..516e648ce4 100644 --- a/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp +++ b/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp @@ -41,7 +41,7 @@ TEST_CASE("BasePipeServerTest") CHECK(basePipeServer.get()); arm::pipe::BufferManager bufferManager; - arm::pipe::SendCounterPacket sendCounterPacket(bufferManager); + arm::pipe::SendCounterPacket sendCounterPacket(bufferManager, "ArmNN", "Armnn 25.0", ""); // Check that we can receive a StreamMetaDataPacket sendCounterPacket.SendStreamMetaDataPacket(); @@ -57,7 +57,7 @@ TEST_CASE("BasePipeServerTest") bufferManager.MarkRead(packetBuffer); CHECK(basePipeServer.get()->WaitForStreamMetaData()); - CHECK(basePipeServer.get()->GetStreamMetadataPid() == arm::pipe::GetCurrentId()); + CHECK(basePipeServer.get()->GetStreamMetadataPid() == arm::pipe::GetCurrentProcessId()); CHECK(basePipeServer.get()->GetStreamMetadataMaxDataLen() == MAX_METADATA_PACKET_LENGTH); // Now try a simple PeriodicCounterSelectionPacket diff --git a/profiling/server/src/timelineDecoder/tests/TimelineTests.cpp b/profiling/server/src/timelineDecoder/tests/TimelineTests.cpp index 15c5c7e56d..e865c79edc 100644 --- a/profiling/server/src/timelineDecoder/tests/TimelineTests.cpp +++ b/profiling/server/src/timelineDecoder/tests/TimelineTests.cpp @@ -5,12 +5,12 @@ #include <common/include/CommandHandlerFunctor.hpp> #include <common/include/CommonProfilingUtils.hpp> +#include <common/include/Threads.hpp> #include <server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp> #include <server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp> #include <server/include/timelineDecoder/TimelineDecoder.hpp> #include <BufferManager.hpp> -#include <armnnUtils/Threads.hpp> #include <ProfilingService.hpp> #include <PacketBuffer.hpp> #include <TimelinePacketWriterFactory.hpp> @@ -172,7 +172,7 @@ TEST_CASE("TimelineCaptureTest") const uint64_t timestamp = 33333u; const uint64_t eventGuid = 44444u; - const int threadId = armnnUtils::Threads::GetCurrentThreadId(); + const int threadId = arm::pipe::GetCurrentThreadId(); // need to do a bit of work here to extract the value from threadId unsigned char* uCharThreadId = new unsigned char[arm::pipe::ThreadIdSize]();; @@ -288,7 +288,7 @@ TEST_CASE("TimelineCaptureTestMultipleStringsInBuffer") const uint64_t timestamp = 33333u; const uint64_t eventGuid = 44444u; - const int threadId = armnnUtils::Threads::GetCurrentThreadId(); + const int threadId = arm::pipe::GetCurrentThreadId(); // need to do a bit of work here to extract the value from threadId unsigned char* uCharThreadId = new unsigned char[arm::pipe::ThreadIdSize](); |