From 7dcc6971722fe3780ca81c51695905e864a6637d Mon Sep 17 00:00:00 2001 From: Nikhil Raj Date: Fri, 30 Apr 2021 15:44:24 +0100 Subject: IVGCVSW-5833 Move the ProfilingGuid out of Types.hpp to its own header in profiling common !android-nn-driver:5691 Signed-off-by: Nikhil Raj Change-Id: Ib71af0831e324ac6bd27b1a36f4a6ec1a703b14a --- profiling/common/include/CommandHandlerFunctor.hpp | 2 +- profiling/common/include/ProfilingGuid.hpp | 113 +++++++++++++++++++++ 2 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 profiling/common/include/ProfilingGuid.hpp (limited to 'profiling') diff --git a/profiling/common/include/CommandHandlerFunctor.hpp b/profiling/common/include/CommandHandlerFunctor.hpp index 9827aa05ba..7e31a709a6 100644 --- a/profiling/common/include/CommandHandlerFunctor.hpp +++ b/profiling/common/include/CommandHandlerFunctor.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include "Packet.hpp" #include namespace arm diff --git a/profiling/common/include/ProfilingGuid.hpp b/profiling/common/include/ProfilingGuid.hpp new file mode 100644 index 0000000000..4d0dd9b3c9 --- /dev/null +++ b/profiling/common/include/ProfilingGuid.hpp @@ -0,0 +1,113 @@ +// +// Copyright © 2021 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include +#include + +namespace armnn +{ + +namespace profiling +{ + +static constexpr uint64_t MIN_STATIC_GUID = 1llu << 63; + +class ProfilingGuid +{ +public: + ProfilingGuid() : m_Guid(0) {} + + ProfilingGuid(uint64_t guid) : m_Guid(guid) {} + + operator uint64_t() const { return m_Guid; } + + bool operator==(const ProfilingGuid& other) const + { + return m_Guid == other.m_Guid; + } + + bool operator!=(const ProfilingGuid& other) const + { + return m_Guid != other.m_Guid; + } + + bool operator<(const ProfilingGuid& other) const + { + return m_Guid < other.m_Guid; + } + + bool operator<=(const ProfilingGuid& other) const + { + return m_Guid <= other.m_Guid; + } + + bool operator>(const ProfilingGuid& other) const + { + return m_Guid > other.m_Guid; + } + + bool operator>=(const ProfilingGuid& other) const + { + return m_Guid >= other.m_Guid; + } + + protected: + uint64_t m_Guid; +}; + +/// Strongly typed guids to distinguish between those generated at runtime, and those that are statically defined. +struct ProfilingDynamicGuid : public ProfilingGuid +{ + using ProfilingGuid::ProfilingGuid; +}; + +struct ProfilingStaticGuid : public ProfilingGuid +{ + using ProfilingGuid::ProfilingGuid; +}; + +} // namespace profiling + + + +} // namespace armnn + + + +namespace std +{ +/// make ProfilingGuid hashable +template <> +struct hash +{ + std::size_t operator()(armnn::profiling::ProfilingGuid const& guid) const noexcept + { + return hash()(uint64_t(guid)); + } +}; + +/// make ProfilingDynamicGuid hashable +template <> +struct hash +{ + std::size_t operator()(armnn::profiling::ProfilingDynamicGuid const& guid) const noexcept + { + return hash()(uint64_t(guid)); + } +}; + +/// make ProfilingStaticGuid hashable +template <> +struct hash +{ + std::size_t operator()(armnn::profiling::ProfilingStaticGuid const& guid) const noexcept + { + return hash()(uint64_t(guid)); + } +}; + +} // namespace std \ No newline at end of file -- cgit v1.2.1