aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Flynn <jim.flynn@arm.com>2019-10-24 11:58:06 +0100
committerJim Flynn <jim.flynn@arm.com>2019-10-25 11:27:29 +0100
commit00f3aaf282c53b47f4cebfa4b29d7039da883bc1 (patch)
tree6ac1bf62f5c0cc442ddc77800ef44346185df16e
parentc975f9295e076febd4ecd45c9174d54f7327b3cc (diff)
downloadarmnn-00f3aaf282c53b47f4cebfa4b29d7039da883bc1.tar.gz
IVGCVSW-4027 Add the IProfilingGuidGenerator interface
Change-Id: Idfb80d73171aa2b57d4dcf01dc137817cf19d2bd Signed-off-by: Jim Flynn <jim.flynn@arm.com>
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/profiling/IProfilingGuidGenerator.hpp30
-rw-r--r--src/profiling/ProfilingGuidGenerator.hpp15
-rw-r--r--src/profiling/ProfilingService.cpp10
-rw-r--r--src/profiling/ProfilingService.hpp10
-rw-r--r--src/profiling/test/SendTimelinePacketTests.cpp19
6 files changed, 77 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b451d9c06a..6edc57f196 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -460,6 +460,7 @@ list(APPEND armnn_sources
src/profiling/IPeriodicCounterCapture.hpp
src/profiling/IProfilingConnection.hpp
src/profiling/IProfilingConnectionFactory.hpp
+ src/profiling/IProfilingGuidGenerator.hpp
src/profiling/Packet.hpp
src/profiling/PacketBuffer.cpp
src/profiling/PacketBuffer.hpp
diff --git a/src/profiling/IProfilingGuidGenerator.hpp b/src/profiling/IProfilingGuidGenerator.hpp
new file mode 100644
index 0000000000..96e1792146
--- /dev/null
+++ b/src/profiling/IProfilingGuidGenerator.hpp
@@ -0,0 +1,30 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "ProfilingGuid.hpp"
+
+namespace armnn
+{
+
+namespace profiling
+{
+
+class IProfilingGuidGenerator
+{
+public:
+ /// Return the next random Guid in the sequence
+ virtual ProfilingDynamicGuid NextGuid() = 0;
+
+ /// Create a ProfilingStaticGuid based on a hash of the string
+ virtual ProfilingStaticGuid GenerateStaticId(const std::string& str) = 0;
+
+ virtual ~IProfilingGuidGenerator() {}
+};
+
+} // namespace profiling
+
+} // namespace armnn
diff --git a/src/profiling/ProfilingGuidGenerator.hpp b/src/profiling/ProfilingGuidGenerator.hpp
index 7c43cab67b..ff27c8ebe7 100644
--- a/src/profiling/ProfilingGuidGenerator.hpp
+++ b/src/profiling/ProfilingGuidGenerator.hpp
@@ -5,7 +5,7 @@
#pragma once
-#include "ProfilingGuid.hpp"
+#include "IProfilingGuidGenerator.hpp"
namespace armnn
{
@@ -13,20 +13,21 @@ namespace armnn
namespace profiling
{
-class ProfilingGuidGenerator
+class ProfilingGuidGenerator : public IProfilingGuidGenerator
{
public:
/// Construct a generator with the default address space static/dynamic partitioning
- ProfilingGuidGenerator() : m_Sequence(0) {}
+ ProfilingGuidGenerator() {}
/// Return the next random Guid in the sequence
- ProfilingDynamicGuid NextGuid();
+ // NOTE: dummy implementation for the moment
+ inline ProfilingDynamicGuid NextGuid() override { return ProfilingDynamicGuid(0); }
- /// Create a ProfilingStaticGuid based on a hash of the name
- ProfilingStaticGuid GenerateStaticId(const char* name);
+ /// Create a ProfilingStaticGuid based on a hash of the string
+ // NOTE: dummy implementation for the moment
+ inline ProfilingStaticGuid GenerateStaticId(const std::string& str) override { return ProfilingStaticGuid(0); }
private:
- uint64_t m_Sequence;
};
} // namespace profiling
diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp
index 1cc9262420..6122ed99c2 100644
--- a/src/profiling/ProfilingService.cpp
+++ b/src/profiling/ProfilingService.cpp
@@ -241,6 +241,16 @@ uint32_t ProfilingService::DecrementCounterValue(uint16_t counterUid)
return counterValuePtr->operator--(std::memory_order::memory_order_relaxed);
}
+ProfilingDynamicGuid ProfilingService::NextGuid()
+{
+ return m_GuidGenerator.NextGuid();
+}
+
+ProfilingStaticGuid ProfilingService::GenerateStaticId(const std::string& str)
+{
+ return m_GuidGenerator.GenerateStaticId(str);
+}
+
void ProfilingService::Initialize()
{
// Register a category for the basic runtime counters
diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp
index f2c1783a11..c70c670a87 100644
--- a/src/profiling/ProfilingService.hpp
+++ b/src/profiling/ProfilingService.hpp
@@ -17,6 +17,7 @@
#include "RequestCounterDirectoryCommandHandler.hpp"
#include "PeriodicCounterSelectionCommandHandler.hpp"
#include "PerJobCounterSelectionCommandHandler.hpp"
+#include "ProfilingGuidGenerator.hpp"
namespace armnn
{
@@ -24,7 +25,7 @@ namespace armnn
namespace profiling
{
-class ProfilingService : public IReadWriteCounterValues
+class ProfilingService : public IReadWriteCounterValues, public IProfilingGuidGenerator
{
public:
using ExternalProfilingOptions = Runtime::CreationOptions::ExternalProfilingOptions;
@@ -66,6 +67,12 @@ public:
uint32_t IncrementCounterValue(uint16_t counterUid) override;
uint32_t DecrementCounterValue(uint16_t counterUid) override;
+ // IProfilingGuidGenerator functions
+ /// Return the next random Guid in the sequence
+ ProfilingDynamicGuid NextGuid() override;
+ /// Create a ProfilingStaticGuid based on a hash of the string
+ ProfilingStaticGuid GenerateStaticId(const std::string& str) override;
+
private:
// Copy/move constructors/destructors and copy/move assignment operators are deleted
ProfilingService(const ProfilingService&) = delete;
@@ -101,6 +108,7 @@ private:
RequestCounterDirectoryCommandHandler m_RequestCounterDirectoryCommandHandler;
PeriodicCounterSelectionCommandHandler m_PeriodicCounterSelectionCommandHandler;
PerJobCounterSelectionCommandHandler m_PerJobCounterSelectionCommandHandler;
+ ProfilingGuidGenerator m_GuidGenerator;
protected:
// Default constructor/destructor kept protected for testing
diff --git a/src/profiling/test/SendTimelinePacketTests.cpp b/src/profiling/test/SendTimelinePacketTests.cpp
index 6f90106cbe..4045d263fa 100644
--- a/src/profiling/test/SendTimelinePacketTests.cpp
+++ b/src/profiling/test/SendTimelinePacketTests.cpp
@@ -6,6 +6,7 @@
#include "SendCounterPacketTests.hpp"
#include <BufferManager.hpp>
+#include <ProfilingService.hpp>
#include <ProfilingUtils.hpp>
#include <SendTimelinePacket.hpp>
#include <TimelinePacketWriterFactory.hpp>
@@ -384,4 +385,22 @@ BOOST_AUTO_TEST_CASE(SendTimelinePacketTests3)
armnn::RuntimeException);
}
+BOOST_AUTO_TEST_CASE(GetGuidsFromProfilingService)
+{
+ armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
+ options.m_EnableProfiling = true;
+ ProfilingService& profilingService = ProfilingService::Instance();
+ profilingService.ResetExternalProfilingOptions(options, true);
+ ProfilingStaticGuid staticGuid = profilingService.GenerateStaticId("dummy");
+ // TODO when actual value gets generated verify its correctness
+ ProfilingStaticGuid expectedStaticValue(0);
+ BOOST_CHECK(staticGuid == expectedStaticValue);
+ ProfilingDynamicGuid dynamicGuid = profilingService.NextGuid();
+ // TODO when actual value gets generated verify its correctness by verifying
+ // it is in the correct range i.e. > x and that if NextGuid is invoked
+ // again it is equal to the previous + 1
+ ProfilingDynamicGuid expectedDynamicValue(0);
+ BOOST_CHECK(dynamicGuid == expectedDynamicValue);
+}
+
BOOST_AUTO_TEST_SUITE_END()