blob: 4d0dd9b3c99e8e404fb98aa477fb6bd0cc77c036 [file] [log] [blame]
Nikhil Raj7dcc6972021-04-30 15:44:24 +01001//
2// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8#include <memory>
9#include <stdint.h>
10
11namespace armnn
12{
13
14namespace profiling
15{
16
17static constexpr uint64_t MIN_STATIC_GUID = 1llu << 63;
18
19class ProfilingGuid
20{
21public:
22 ProfilingGuid() : m_Guid(0) {}
23
24 ProfilingGuid(uint64_t guid) : m_Guid(guid) {}
25
26 operator uint64_t() const { return m_Guid; }
27
28 bool operator==(const ProfilingGuid& other) const
29 {
30 return m_Guid == other.m_Guid;
31 }
32
33 bool operator!=(const ProfilingGuid& other) const
34 {
35 return m_Guid != other.m_Guid;
36 }
37
38 bool operator<(const ProfilingGuid& other) const
39 {
40 return m_Guid < other.m_Guid;
41 }
42
43 bool operator<=(const ProfilingGuid& other) const
44 {
45 return m_Guid <= other.m_Guid;
46 }
47
48 bool operator>(const ProfilingGuid& other) const
49 {
50 return m_Guid > other.m_Guid;
51 }
52
53 bool operator>=(const ProfilingGuid& other) const
54 {
55 return m_Guid >= other.m_Guid;
56 }
57
58 protected:
59 uint64_t m_Guid;
60};
61
62/// Strongly typed guids to distinguish between those generated at runtime, and those that are statically defined.
63struct ProfilingDynamicGuid : public ProfilingGuid
64{
65 using ProfilingGuid::ProfilingGuid;
66};
67
68struct ProfilingStaticGuid : public ProfilingGuid
69{
70 using ProfilingGuid::ProfilingGuid;
71};
72
73} // namespace profiling
74
75
76
77} // namespace armnn
78
79
80
81namespace std
82{
83/// make ProfilingGuid hashable
84template <>
85struct hash<armnn::profiling::ProfilingGuid>
86{
87 std::size_t operator()(armnn::profiling::ProfilingGuid const& guid) const noexcept
88 {
89 return hash<uint64_t>()(uint64_t(guid));
90 }
91};
92
93/// make ProfilingDynamicGuid hashable
94template <>
95struct hash<armnn::profiling::ProfilingDynamicGuid>
96{
97 std::size_t operator()(armnn::profiling::ProfilingDynamicGuid const& guid) const noexcept
98 {
99 return hash<uint64_t>()(uint64_t(guid));
100 }
101};
102
103/// make ProfilingStaticGuid hashable
104template <>
105struct hash<armnn::profiling::ProfilingStaticGuid>
106{
107 std::size_t operator()(armnn::profiling::ProfilingStaticGuid const& guid) const noexcept
108 {
109 return hash<uint64_t>()(uint64_t(guid));
110 }
111};
112
113} // namespace std