src/armnnUtils/VerificationHelpers.cpp \
src/armnnUtils/Filesystem.cpp \
src/armnnUtils/Processes.cpp \
+ src/armnnUtils/Threads.cpp \
src/armnnUtils/Transpose.cpp \
src/armnn/layers/ActivationLayer.cpp \
src/armnn/layers/AdditionLayer.cpp \
src/armnnUtils/BFloat16.hpp
src/armnnUtils/Filesystem.hpp
src/armnnUtils/Filesystem.cpp
- src/armnnUtils/Processes.hpp
- src/armnnUtils/Processes.cpp
src/armnnUtils/GraphTopologicalSort.hpp
src/armnnUtils/Half.hpp
src/armnnUtils/Permute.cpp
src/armnnUtils/ParserHelper.hpp
src/armnnUtils/ParserHelper.cpp
src/armnnUtils/ParserPrototxtFixture.hpp
+ src/armnnUtils/Processes.hpp
+ src/armnnUtils/Processes.cpp
src/armnnUtils/PrototxtConversions.hpp
src/armnnUtils/PrototxtConversions.cpp
src/armnnUtils/QuantizeHelper.hpp
src/armnnUtils/TensorIOUtils.hpp
src/armnnUtils/TensorUtils.cpp
+ src/armnnUtils/Threads.hpp
+ src/armnnUtils/Threads.cpp
src/armnnUtils/Transpose.cpp
src/armnnUtils/WindowsWrapper.hpp
)
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include <algorithm>
#include <string>
-#include <thread>
#include <vector>
namespace armnn
/// Create and write a TimelineEventBinaryPacket from the parameters to the buffer.
virtual void
- SendTimelineEventBinaryPacket(uint64_t timestamp, std::thread::id threadId, uint64_t profilingGuid) = 0;
+ SendTimelineEventBinaryPacket(uint64_t timestamp, int threadId, uint64_t profilingGuid) = 0;
/// Create and write a TimelineEventClassBinaryPacket from the parameters to the buffer.
virtual void SendTimelineEventClassBinaryPacket(uint64_t profilingGuid, uint64_t nameGuid) = 0;
--- /dev/null
+//
+// 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 "WindowsWrapper.hpp"
+#endif
+
+namespace armnnUtils
+{
+namespace Threads
+{
+
+int GetCurrentThreadId()
+{
+#if defined(__linux__)
+ return static_cast<int>(gettid());
+#elif defined(_MSC_VER)
+ return ::GetCurrentThreadId();
+#endif
+}
+
+}
+}
--- /dev/null
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+namespace armnnUtils
+{
+namespace Threads
+{
+
+int GetCurrentThreadId();
+
+}
+}
}
TimelinePacketStatus WriteTimelineEventBinary(uint64_t timestamp,
- std::thread::id threadId,
+ int threadId,
uint64_t profilingGuid,
unsigned char* buffer,
unsigned int remainingBufferSize,
namespace std
{
-bool operator==(const std::vector<uint8_t>& left, std::thread::id right)
+bool operator==(const std::vector<uint8_t>& left, int right)
{
return std::memcmp(left.data(), &right, left.size()) == 0;
}
namespace profiling
{
-constexpr unsigned int ThreadIdSize = sizeof(std::thread::id); // Is platform dependent
+constexpr unsigned int ThreadIdSize = sizeof(int); // Is platform dependent
struct SwTraceHeader
{
unsigned int& numberOfBytesWritten);
TimelinePacketStatus WriteTimelineEventBinary(uint64_t timestamp,
- std::thread::id threadId,
+ int threadId,
uint64_t profilingGuid,
unsigned char* buffer,
unsigned int bufferSize,
namespace std
{
-bool operator==(const std::vector<uint8_t>& left, std::thread::id right);
+bool operator==(const std::vector<uint8_t>& left, int right);
} // namespace std
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
}
void SendTimelinePacket::SendTimelineEventBinaryPacket(uint64_t timestamp,
- std::thread::id threadId,
+ int threadId,
uint64_t profilingGuid)
{
ForwardWriteBinaryFunction(WriteTimelineEventBinary,
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
void SendTimelineEntityBinaryPacket(uint64_t profilingGuid) override;
/// Create and write a TimelineEventBinaryPacket from the parameters to the buffer.
- void SendTimelineEventBinaryPacket(uint64_t timestamp, std::thread::id threadId, uint64_t profilingGuid) override;
+ void SendTimelineEventBinaryPacket(uint64_t timestamp, int threadId, uint64_t profilingGuid) override;
/// Create and write a TimelineEventClassBinaryPacket from the parameters to the buffer.
void SendTimelineEventClassBinaryPacket(uint64_t profilingGuid, uint64_t nameGuid) override;
// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
-
-#include "TimelineUtilityMethods.hpp"
#include "LabelsAndEventClasses.hpp"
+#include <Threads.hpp>
+#include "TimelineUtilityMethods.hpp"
namespace armnn
{
uint64_t timestamp = GetTimestamp();
// Get the thread id
- std::thread::id threadId = std::this_thread::get_id();
+ int threadId = armnnUtils::Threads::GetCurrentThreadId();
// Generate a GUID for the event
ProfilingDynamicGuid eventGuid = profiling::ProfilingService::GetNextGuid();
#include <armnn/Descriptors.hpp>
#include <LabelsAndEventClasses.hpp>
+#include <Threads.hpp>
#include <ProfilingService.hpp>
#include <test/TestUtils.hpp>
}
ProfilingGuid VerifyTimelineEventBinaryPacket(Optional<uint64_t> timestamp,
- Optional<std::thread::id> threadId,
+ Optional<int> threadId,
Optional<ProfilingGuid> eventGuid,
const unsigned char* readableData,
unsigned int& offset)
}
else
{
- BOOST_CHECK(readThreadId == std::this_thread::get_id());
+ BOOST_CHECK(readThreadId == armnnUtils::Threads::GetCurrentThreadId());
}
// Check the event GUID
unsigned int& offset);
ProfilingGuid VerifyTimelineEventBinaryPacket(Optional<uint64_t> timestamp,
- Optional<std::thread::id> threadId,
+ Optional<int> threadId,
Optional<ProfilingGuid> eventGuid,
const unsigned char* readableData,
unsigned int& offset);
#include "ProfilingMocks.hpp"
#include <BufferManager.hpp>
+#include <Threads.hpp>
#include <ProfilingService.hpp>
#include <ProfilingUtils.hpp>
#include <SendTimelinePacket.hpp>
// Send TimelineEventBinaryPacket
const uint64_t timestamp = 456789u;
- const std::thread::id threadId = std::this_thread::get_id();
+ const int threadId = armnnUtils::Threads::GetCurrentThreadId();
const uint64_t eventProfilingGuid = 123456u;
sendTimelinePacket->SendTimelineEventBinaryPacket(timestamp, threadId, eventProfilingGuid);
// SPDX-License-Identifier: MIT
//
+#include <Threads.hpp>
#include <ProfilingUtils.hpp>
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE(TimelineEventPacketTestNoBuffer)
{
const uint64_t timestamp = 456789u;
- const std::thread::id threadId = std::this_thread::get_id();
+ const int threadId = armnnUtils::Threads::GetCurrentThreadId();
const uint64_t profilingGuid = 123456u;
unsigned int numberOfBytesWritten = 789u;
TimelinePacketStatus result = WriteTimelineEventBinary(timestamp,
std::vector<unsigned char> buffer(512, 0);
const uint64_t timestamp = 456789u;
- const std::thread::id threadId = std::this_thread::get_id();
+ const int threadId = armnnUtils::Threads::GetCurrentThreadId();
const uint64_t profilingGuid = 123456u;
unsigned int numberOfBytesWritten = 789u;
TimelinePacketStatus result = WriteTimelineEventBinary(timestamp,
std::vector<unsigned char> buffer(10, 0);
const uint64_t timestamp = 456789u;
- const std::thread::id threadId = std::this_thread::get_id();
+ const int threadId = armnnUtils::Threads::GetCurrentThreadId();
const uint64_t profilingGuid = 123456u;
unsigned int numberOfBytesWritten = 789u;
TimelinePacketStatus result = WriteTimelineEventBinary(timestamp,
std::vector<unsigned char> buffer(512, 0);
const uint64_t timestamp = 456789u;
- const std::thread::id threadId = std::this_thread::get_id();
+ const int threadId = armnnUtils::Threads::GetCurrentThreadId();
const uint64_t profilingGuid = 123456u;
unsigned int numberOfBytesWritten = 789u;
TimelinePacketStatus result = WriteTimelineEventBinary(timestamp,
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include <TimelineDecoder.hpp>
#include <CommandHandlerFunctor.hpp>
+#include <Threads.hpp>
#include <ProfilingService.hpp>
#include <PacketBuffer.hpp>
#include <TimelinePacketWriterFactory.hpp>
const uint64_t timestamp = 33333u;
const uint64_t eventGuid = 44444u;
- const std::thread::id threadId = std::this_thread::get_id();
+ const int threadId = armnnUtils::Threads::GetCurrentThreadId();
// need to do a bit of work here to extract the value from threadId
unsigned char* uCharThreadId = new unsigned char[armnn::profiling::ThreadIdSize]();;
const uint64_t timestamp = 33333u;
const uint64_t eventGuid = 44444u;
- const std::thread::id threadId = std::this_thread::get_id();
+ const int threadId = armnnUtils::Threads::GetCurrentThreadId();
// need to do a bit of work here to extract the value from threadId
unsigned char* uCharThreadId = new unsigned char[armnn::profiling::ThreadIdSize]();
uint32_t uint8_t_size = sizeof(uint8_t);
uint32_t uint32_t_size = sizeof(uint32_t);
uint32_t uint64_t_size = sizeof(uint64_t);
- uint32_t threadId_size = sizeof(std::thread::id);
+ uint32_t threadId_size = sizeof(int);
profiling::BufferManager bufferManager(5);
profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);