From 77b284e6988b9a131d6abb3140ec6663c2ae84ae Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Sun, 13 Mar 2022 20:53:35 +0000 Subject: IVGCVSW-6848 Move Process.[ch]pp from armnnUtils to profiling/common Change-Id: I13353f50293eae565a75ccfda37209350512bbc6 Signed-off-by: Jim Flynn --- profiling/common/include/Processes.hpp | 16 ++++++++++++ profiling/common/src/CMakeLists.txt | 1 + profiling/common/src/Processes.cpp | 29 ++++++++++++++++++++++ .../basePipeServer/tests/BasePipeServerTests.cpp | 4 +-- 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 profiling/common/include/Processes.hpp create mode 100644 profiling/common/src/Processes.cpp (limited to 'profiling') diff --git a/profiling/common/include/Processes.hpp b/profiling/common/include/Processes.hpp new file mode 100644 index 0000000000..cc59d8b2d4 --- /dev/null +++ b/profiling/common/include/Processes.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 GetCurrentId(); + +} // namespace arm +} // namespace pipe diff --git a/profiling/common/src/CMakeLists.txt b/profiling/common/src/CMakeLists.txt index 1b47b6cf73..3932186c51 100644 --- a/profiling/common/src/CMakeLists.txt +++ b/profiling/common/src/CMakeLists.txt @@ -13,6 +13,7 @@ if(BUILD_TIMELINE_DECODER) Logging.cpp NetworkSockets.cpp PacketVersionResolver.cpp + Processes.cpp SwTrace.cpp LabelsAndEventClasses.cpp) diff --git a/profiling/common/src/Processes.cpp b/profiling/common/src/Processes.cpp new file mode 100644 index 0000000000..d6d4ca4950 --- /dev/null +++ b/profiling/common/src/Processes.cpp @@ -0,0 +1,29 @@ +// +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "Processes.hpp" + +#if defined(__unix__) || defined(__APPLE__) +#include +#elif defined(_MSC_VER) +#include +#endif + +namespace arm +{ +namespace pipe +{ + +int GetCurrentId() +{ +#if defined(__unix__) || defined(__APPLE__) + return getpid(); +#elif defined(_MSC_VER) + return ::GetCurrentProcessId(); +#endif +} + +} // namespace pipe +} // namespace arm diff --git a/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp b/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp index a0af25fc65..9993fc7a75 100644 --- a/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp +++ b/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include @@ -57,7 +57,7 @@ TEST_CASE("BasePipeServerTest") bufferManager.MarkRead(packetBuffer); CHECK(basePipeServer.get()->WaitForStreamMetaData()); - CHECK(basePipeServer.get()->GetStreamMetadataPid() == armnnUtils::Processes::GetCurrentId()); + CHECK(basePipeServer.get()->GetStreamMetadataPid() == arm::pipe::GetCurrentId()); CHECK(basePipeServer.get()->GetStreamMetadataMaxDataLen() == MAX_METADATA_PACKET_LENGTH); // Now try a simple PeriodicCounterSelectionPacket -- cgit v1.2.1