aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNarumol Prangnawarat <narumol.prangnawarat@arm.com>2019-10-22 14:17:11 +0100
committerNarumol Prangnawarat <narumol.prangnawarat@arm.com>2019-10-22 14:23:50 +0100
commit15effd8806e77c226b55e546bb44110177383fab (patch)
treef55a1b6d57905849bdb442f65b555e2c7b973e93
parent6d2e6594cccde1dae2f52ab25e57d529c4c1d32e (diff)
downloadarmnn-15effd8806e77c226b55e546bb44110177383fab.tar.gz
IVGCVSW-3980 Add ProfilingGuid and ProfilingGuidGenerator API
* ProfilingGuid * ProfilingDynamicGuid * ProfilingStaticGuid * ProfilingGuidGenerator API * Unit tests Signed-off-by: Narumol Prangnawarat <narumol.prangnawarat@arm.com> Change-Id: If950415f059d07d34cf64e13a9b4663dd032ec34
-rw-r--r--CMakeLists.txt3
-rw-r--r--src/profiling/ProfilingGuid.hpp70
-rw-r--r--src/profiling/ProfilingGuidGenerator.hpp34
-rw-r--r--src/profiling/test/ProfilingGuidTest.cpp62
4 files changed, 169 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8fdfc95a76..d686d3f68e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -474,6 +474,8 @@ list(APPEND armnn_sources
src/profiling/ProfilingConnectionDumpToFileDecorator.hpp
src/profiling/ProfilingConnectionFactory.cpp
src/profiling/ProfilingConnectionFactory.hpp
+ src/profiling/ProfilingGuid.hpp
+ src/profiling/ProfilingGuidGenerator.hpp
src/profiling/ProfilingService.cpp
src/profiling/ProfilingService.hpp
src/profiling/ProfilingStateMachine.cpp
@@ -609,6 +611,7 @@ if(BUILD_UNIT_TESTS)
src/armnnUtils/test/TensorUtilsTest.cpp
src/profiling/test/BufferTests.cpp
src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
+ src/profiling/test/ProfilingGuidTest.cpp
src/profiling/test/ProfilingTests.cpp
src/profiling/test/ProfilingTests.hpp
src/profiling/test/SendCounterPacketTests.cpp
diff --git a/src/profiling/ProfilingGuid.hpp b/src/profiling/ProfilingGuid.hpp
new file mode 100644
index 0000000000..84d2db7363
--- /dev/null
+++ b/src/profiling/ProfilingGuid.hpp
@@ -0,0 +1,70 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <stdint.h>
+
+namespace armnn
+{
+
+namespace profiling
+{
+
+class ProfilingGuid
+{
+public:
+ 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 !(*this == other);
+ }
+
+ 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
diff --git a/src/profiling/ProfilingGuidGenerator.hpp b/src/profiling/ProfilingGuidGenerator.hpp
new file mode 100644
index 0000000000..7c43cab67b
--- /dev/null
+++ b/src/profiling/ProfilingGuidGenerator.hpp
@@ -0,0 +1,34 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "ProfilingGuid.hpp"
+
+namespace armnn
+{
+
+namespace profiling
+{
+
+class ProfilingGuidGenerator
+{
+public:
+ /// Construct a generator with the default address space static/dynamic partitioning
+ ProfilingGuidGenerator() : m_Sequence(0) {}
+
+ /// Return the next random Guid in the sequence
+ ProfilingDynamicGuid NextGuid();
+
+ /// Create a ProfilingStaticGuid based on a hash of the name
+ ProfilingStaticGuid GenerateStaticId(const char* name);
+
+private:
+ uint64_t m_Sequence;
+};
+
+} // namespace profiling
+
+} // namespace armnn
diff --git a/src/profiling/test/ProfilingGuidTest.cpp b/src/profiling/test/ProfilingGuidTest.cpp
new file mode 100644
index 0000000000..fa0143572b
--- /dev/null
+++ b/src/profiling/test/ProfilingGuidTest.cpp
@@ -0,0 +1,62 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "ProfilingGuid.hpp"
+
+#include <boost/test/unit_test.hpp>
+
+using namespace armnn::profiling;
+
+BOOST_AUTO_TEST_SUITE(ProfilingGuidTests)
+
+BOOST_AUTO_TEST_CASE(GuidTest)
+{
+ ProfilingGuid guid0(0);
+ ProfilingGuid guid1(1);
+ ProfilingGuid guid2(1);
+
+ BOOST_TEST(guid0 != guid1);
+ BOOST_TEST(guid1 == guid2);
+ BOOST_TEST(guid0 < guid1);
+ BOOST_TEST(guid0 <= guid1);
+ BOOST_TEST(guid1 <= guid2);
+ BOOST_TEST(guid1 > guid0);
+ BOOST_TEST(guid1 >= guid0);
+ BOOST_TEST(guid1 >= guid2);
+}
+
+BOOST_AUTO_TEST_CASE(StaticGuidTest)
+{
+ ProfilingStaticGuid guid0(0);
+ ProfilingStaticGuid guid1(1);
+ ProfilingStaticGuid guid2(1);
+
+ BOOST_TEST(guid0 != guid1);
+ BOOST_TEST(guid1 == guid2);
+ BOOST_TEST(guid0 < guid1);
+ BOOST_TEST(guid0 <= guid1);
+ BOOST_TEST(guid1 <= guid2);
+ BOOST_TEST(guid1 > guid0);
+ BOOST_TEST(guid1 >= guid0);
+ BOOST_TEST(guid1 >= guid2);
+}
+
+BOOST_AUTO_TEST_CASE(DynamicGuidTest)
+{
+ ProfilingDynamicGuid guid0(0);
+ ProfilingDynamicGuid guid1(1);
+ ProfilingDynamicGuid guid2(1);
+
+ BOOST_TEST(guid0 != guid1);
+ BOOST_TEST(guid1 == guid2);
+ BOOST_TEST(guid0 < guid1);
+ BOOST_TEST(guid0 <= guid1);
+ BOOST_TEST(guid1 <= guid2);
+ BOOST_TEST(guid1 > guid0);
+ BOOST_TEST(guid1 >= guid0);
+ BOOST_TEST(guid1 >= guid2);
+}
+
+BOOST_AUTO_TEST_SUITE_END()