aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/profiling/ProfilingService.cpp55
-rw-r--r--src/profiling/ProfilingService.hpp39
-rw-r--r--src/profiling/test/ProfilingTests.cpp36
4 files changed, 132 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6f2a41c4d7..e4ca1fcf08 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -439,6 +439,8 @@ list(APPEND armnn_sources
src/profiling/ProfilingUtils.cpp
src/profiling/ProfilingStateMachine.cpp
src/profiling/ProfilingStateMachine.hpp
+ src/profiling/ProfilingService.cpp
+ src/profiling/ProfilingService.hpp
third-party/half/half.hpp
)
diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp
new file mode 100644
index 0000000000..eaaded54d0
--- /dev/null
+++ b/src/profiling/ProfilingService.cpp
@@ -0,0 +1,55 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "ProfilingService.hpp"
+
+namespace armnn
+{
+
+namespace profiling
+{
+
+ProfilingService::ProfilingService(const Runtime::CreationOptions::ExternalProfilingOptions& options)
+ : m_Options(options)
+{
+ Initialise();
+}
+
+void ProfilingService::Initialise()
+{
+ if (m_Options.m_EnableProfiling == true)
+ {
+ // Setup Counter Directory - this should only be created if profiling is enabled
+ // Setup Counter meta
+
+ // For now until CounterDirectory setup is implemented, change m_State once everything initialised
+ m_State.TransitionToState(ProfilingState::NotConnected);
+ }
+}
+
+void ProfilingService::Run()
+{
+ if (m_State.GetCurrentState() == ProfilingState::NotConnected)
+ {
+ // Since GetProfilingConnection is not implemented, if !NULL,
+ // then change to WaitingForAck. This will need to change once there is implementation
+ // for the IProfilingConnection
+ if (!m_Factory.GetProfilingConnection(m_Options))
+ {
+ m_State.TransitionToState(ProfilingState::WaitingForAck);
+ }
+ } else if (m_State.GetCurrentState() == ProfilingState::Uninitialised && m_Options.m_EnableProfiling == true)
+ {
+ Initialise();
+ }
+}
+
+ProfilingState ProfilingService::GetCurrentState() const
+{
+ return m_State.GetCurrentState();
+}
+} // namespace profiling
+
+} // namespace armnn \ No newline at end of file
diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp
new file mode 100644
index 0000000000..33f1135b87
--- /dev/null
+++ b/src/profiling/ProfilingService.hpp
@@ -0,0 +1,39 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "ProfilingStateMachine.hpp"
+#include "ProfilingConnectionFactory.hpp"
+
+namespace armnn
+{
+
+namespace profiling
+{
+
+class ProfilingService
+{
+public:
+ ProfilingService(const Runtime::CreationOptions::ExternalProfilingOptions& options);
+ ~ProfilingService() = default;
+
+ void Run();
+
+ ProfilingState GetCurrentState() const;
+
+ // Options are public to allow profiling to be turned on at runtime
+ Runtime::CreationOptions::ExternalProfilingOptions m_Options;
+
+private:
+ void Initialise();
+
+ ProfilingStateMachine m_State;
+ ProfilingConnectionFactory m_Factory;
+};
+
+} // namespace profiling
+
+} // namespace armnn \ No newline at end of file
diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp
index 58609528e4..57d8dd1ace 100644
--- a/src/profiling/test/ProfilingTests.cpp
+++ b/src/profiling/test/ProfilingTests.cpp
@@ -12,6 +12,8 @@
#include "../PacketVersionResolver.hpp"
#include "../ProfilingStateMachine.hpp"
+#include "../ProfilingService.hpp"
+
#include <boost/test/unit_test.hpp>
#include <cstdint>
@@ -450,7 +452,41 @@ BOOST_AUTO_TEST_CASE(CheckCaptureDataHolder)
BOOST_CHECK(copyConstructedCaptureData.GetCapturePeriod() == 3);
BOOST_CHECK(copyConstructedCaptureData.GetCounterIds() == counterIds3);
+}
+
+BOOST_AUTO_TEST_CASE(CheckProfilingServiceDisabled)
+{
+ armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
+ ProfilingService service(options);
+ BOOST_CHECK(service.GetCurrentState() == ProfilingState::Uninitialised);
+ service.Run();
+ BOOST_CHECK(service.GetCurrentState() == ProfilingState::Uninitialised);
+}
+
+BOOST_AUTO_TEST_CASE(CheckProfilingServiceEnabled)
+{
+ armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
+ options.m_EnableProfiling = true;
+ ProfilingService service(options);
+ BOOST_CHECK(service.GetCurrentState() == ProfilingState::NotConnected);
+ service.Run();
+ BOOST_CHECK(service.GetCurrentState() == ProfilingState::WaitingForAck);
+}
+
+
+BOOST_AUTO_TEST_CASE(CheckProfilingServiceEnabledRuntime)
+{
+ armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
+ ProfilingService service(options);
+ BOOST_CHECK(service.GetCurrentState() == ProfilingState::Uninitialised);
+ service.Run();
+ BOOST_CHECK(service.GetCurrentState() == ProfilingState::Uninitialised);
+ service.m_Options.m_EnableProfiling = true;
+ service.Run();
+ BOOST_CHECK(service.GetCurrentState() == ProfilingState::NotConnected);
+ service.Run();
+ BOOST_CHECK(service.GetCurrentState() == ProfilingState::WaitingForAck);
}
BOOST_AUTO_TEST_SUITE_END()