aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/ProfilingService.cpp
diff options
context:
space:
mode:
authorJim Flynn <jim.flynn@arm.com>2020-05-27 17:05:21 +0100
committerfinn.williams <finn.williams@arm.com>2020-06-17 12:16:36 +0000
commit6398a98ac273931cc0b3ab33222d255d1edf48b0 (patch)
tree39998f4ed9af5d4fcdb3aa7ed11ca101b917f07d /src/profiling/ProfilingService.cpp
parent96becb7e4f5f510344c3850278a706d63a564fc4 (diff)
downloadarmnn-6398a98ac273931cc0b3ab33222d255d1edf48b0.tar.gz
IVGCVSW-4900 Update Timeline Directory Message with new fields
Change-Id: I68097e176f7471a18498492b50339e68004dddd5 Signed-off-by: Jim Flynn <jim.flynn@arm.com>
Diffstat (limited to 'src/profiling/ProfilingService.cpp')
-rw-r--r--src/profiling/ProfilingService.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp
index 21972b4c7f..8532c3efad 100644
--- a/src/profiling/ProfilingService.cpp
+++ b/src/profiling/ProfilingService.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -29,6 +29,11 @@ ProfilingStaticGuid ProfilingService::GetStaticId(const std::string& str)
return m_GuidGenerator.GenerateStaticId(str);
}
+void ProfilingService::ResetGuidGenerator()
+{
+ m_GuidGenerator.Reset();
+}
+
void ProfilingService::ResetExternalProfilingOptions(const ExternalProfilingOptions& options,
bool resetProfilingService)
{
@@ -452,6 +457,10 @@ void ProfilingService::Reset()
void ProfilingService::Stop()
{
+ { // only lock when we are updating the inference completed variable
+ std::unique_lock<std::mutex> lck(m_ServiceActiveMutex);
+ m_ServiceActive = false;
+ }
// The order in which we reset/stop the components is not trivial!
// First stop the producing threads
// Command Handler first as it is responsible for launching then Periodic Counter capture thread
@@ -491,6 +500,39 @@ void ProfilingService::NotifyBackendsForTimelineReporting()
}
}
+void ProfilingService::NotifyProfilingServiceActive()
+{
+ { // only lock when we are updating the inference completed variable
+ std::unique_lock<std::mutex> lck(m_ServiceActiveMutex);
+ m_ServiceActive = true;
+ }
+ m_ServiceActiveConditionVariable.notify_one();
+}
+
+void ProfilingService::WaitForProfilingServiceActivation(unsigned int timeout)
+{
+ std::unique_lock<std::mutex> lck(m_ServiceActiveMutex);
+
+ auto start = std::chrono::high_resolution_clock::now();
+ // Here we we will go back to sleep after a spurious wake up if
+ // m_InferenceCompleted is not yet true.
+ if (!m_ServiceActiveConditionVariable.wait_for(lck,
+ std::chrono::milliseconds(timeout),
+ [&]{return m_ServiceActive == true;}))
+ {
+ if (m_ServiceActive == true)
+ {
+ return;
+ }
+ auto finish = std::chrono::high_resolution_clock::now();
+ std::chrono::duration<double, std::milli> elapsed = finish - start;
+ std::stringstream ss;
+ ss << "Timed out waiting on profiling service activation for " << elapsed.count() << " ms";
+ ARMNN_LOG(warning) << ss.str();
+ }
+ return;
+}
+
ProfilingService::~ProfilingService()
{
Stop();