From 6398a98ac273931cc0b3ab33222d255d1edf48b0 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Wed, 27 May 2020 17:05:21 +0100 Subject: IVGCVSW-4900 Update Timeline Directory Message with new fields Change-Id: I68097e176f7471a18498492b50339e68004dddd5 Signed-off-by: Jim Flynn --- src/profiling/ProfilingService.cpp | 44 +++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'src/profiling/ProfilingService.cpp') 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 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 lck(m_ServiceActiveMutex); + m_ServiceActive = true; + } + m_ServiceActiveConditionVariable.notify_one(); +} + +void ProfilingService::WaitForProfilingServiceActivation(unsigned int timeout) +{ + std::unique_lock 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 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(); -- cgit v1.2.1