diff options
author | Jim Flynn <jim.flynn@arm.com> | 2022-03-25 21:24:56 +0000 |
---|---|---|
committer | Jim Flynn <jim.flynn@arm.com> | 2022-04-11 14:24:34 +0100 |
commit | 870b96c643388ae88dd4245b9169f526d6a8d49e (patch) | |
tree | 44a675f1eecdbf0eff40dc4ee623e0a2f03b2f96 /profiling | |
parent | b99799bda8fe0fb0a755eebbe2d02dbb74507c9f (diff) | |
download | armnn-870b96c643388ae88dd4245b9169f526d6a8d49e.tar.gz |
IVGCVSW-6707 Enables a bare metal compile
Change-Id: Icc2f83c5f27f413758fee3e5c1445e9fc44f42c8
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
Diffstat (limited to 'profiling')
-rw-r--r-- | profiling/client/include/Holder.hpp | 2 | ||||
-rw-r--r-- | profiling/client/src/Holder.cpp | 6 | ||||
-rw-r--r-- | profiling/client/src/ProfilingService.cpp | 36 | ||||
-rw-r--r-- | profiling/common/include/ProfilingGuidGenerator.hpp | 6 | ||||
-rw-r--r-- | profiling/common/src/CMakeLists.txt | 1 |
5 files changed, 48 insertions, 3 deletions
diff --git a/profiling/client/include/Holder.hpp b/profiling/client/include/Holder.hpp index db5468feda..27d6789355 100644 --- a/profiling/client/include/Holder.hpp +++ b/profiling/client/include/Holder.hpp @@ -58,7 +58,9 @@ public: const std::set<std::string>& activeBackends); private: +#if !defined(ARMNN_DISABLE_THREADS) mutable std::mutex m_CaptureThreadMutex; +#endif CaptureData m_CaptureData; }; diff --git a/profiling/client/src/Holder.cpp b/profiling/client/src/Holder.cpp index d144e244d9..2fee6f994a 100644 --- a/profiling/client/src/Holder.cpp +++ b/profiling/client/src/Holder.cpp @@ -52,8 +52,9 @@ const std::vector<uint16_t>& CaptureData::GetCounterIds() const CaptureData Holder::GetCaptureData() const { +#if !defined(ARMNN_DISABLE_THREADS) std::lock_guard<std::mutex> lockGuard(m_CaptureThreadMutex); - +#endif return m_CaptureData; } @@ -74,8 +75,9 @@ void Holder::SetCaptureData(uint32_t capturePeriod, const std::vector<uint16_t>& counterIds, const std::set<std::string>& activeBackends) { +#if !defined(ARMNN_DISABLE_THREADS) std::lock_guard<std::mutex> lockGuard(m_CaptureThreadMutex); - +#endif m_CaptureData.SetCapturePeriod(capturePeriod); m_CaptureData.SetCounterIds(counterIds); m_CaptureData.SetActiveBackends(activeBackends); diff --git a/profiling/client/src/ProfilingService.cpp b/profiling/client/src/ProfilingService.cpp index 7acddf1129..3a5c74b6da 100644 --- a/profiling/client/src/ProfilingService.cpp +++ b/profiling/client/src/ProfilingService.cpp @@ -21,6 +21,7 @@ namespace pipe void ProfilingService::ResetExternalProfilingOptions(const arm::pipe::ProfilingOptions& options, bool resetProfilingService) { +#if !defined(ARMNN_BUILD_BARE_METAL) // Update the profiling options m_Options = options; m_TimelineReporting = options.m_TimelineEnabled; @@ -32,17 +33,23 @@ void ProfilingService::ResetExternalProfilingOptions(const arm::pipe::ProfilingO // Reset the profiling service Reset(); } +#endif // ARMNN_BUILD_BARE_METAL } bool ProfilingService::IsProfilingEnabled() const { +#if !defined(ARMNN_BUILD_BARE_METAL) return m_Options.m_EnableProfiling; +#else + return false; +#endif // ARMNN_BUILD_BARE_METAL } ProfilingState ProfilingService::ConfigureProfilingService( const ProfilingOptions& options, bool resetProfilingService) { +#if !defined(ARMNN_BUILD_BARE_METAL) ResetExternalProfilingOptions(options, resetProfilingService); ProfilingState currentState = m_StateMachine.GetCurrentState(); if (options.m_EnableProfiling) @@ -87,10 +94,12 @@ ProfilingState ProfilingService::ConfigureProfilingService( return m_StateMachine.GetCurrentState(); } } +#endif // ARMNN_BUILD_BARE_METAL } void ProfilingService::Update() { +#if !defined(ARMNN_BUILD_BARE_METAL) if (!m_Options.m_EnableProfiling) { // Don't run if profiling is disabled @@ -168,10 +177,12 @@ void ProfilingService::Update() throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", static_cast<int>(currentState))); } +#endif // ARMNN_BUILD_BARE_METAL } void ProfilingService::Disconnect() { +#if !defined(ARMNN_BUILD_BARE_METAL) ProfilingState currentState = m_StateMachine.GetCurrentState(); switch (currentState) { @@ -188,16 +199,20 @@ void ProfilingService::Disconnect() throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", static_cast<int>(currentState))); } +#endif // ARMNN_BUILD_BARE_METAL } // Store a profiling context returned from a backend that support profiling, and register its counters -void ProfilingService::AddBackendProfilingContext(const std::string& backendId, +void ProfilingService::AddBackendProfilingContext( + const std::string& backendId, std::shared_ptr<IBackendProfilingContext> profilingContext) { +#if !defined(ARMNN_BUILD_BARE_METAL) ARM_PIPE_ASSERT(profilingContext != nullptr); // Register the backend counters m_MaxGlobalCounterId = profilingContext->RegisterCounters(m_MaxGlobalCounterId); m_BackendProfilingContexts.emplace(backendId, std::move(profilingContext)); +#endif // ARMNN_BUILD_BARE_METAL } const ICounterDirectory& ProfilingService::GetCounterDirectory() const { @@ -313,11 +328,14 @@ std::unique_ptr<ISendTimelinePacket> ProfilingService::GetSendTimelinePacket() c void ProfilingService::Initialize() { +#if !defined(ARMNN_BUILD_BARE_METAL) m_Initialiser.InitialiseProfilingService(*this); +#endif // ARMNN_BUILD_BARE_METAL } void ProfilingService::InitializeCounterValue(uint16_t counterUid) { +#if !defined(ARMNN_BUILD_BARE_METAL) // Increase the size of the counter index if necessary if (counterUid >= m_CounterIndex.size()) { @@ -330,10 +348,12 @@ void ProfilingService::InitializeCounterValue(uint16_t counterUid) // Register the new counter to the counter index for quick access std::atomic<uint32_t>* counterValuePtr = &(m_CounterValues.back()); m_CounterIndex.at(counterUid) = counterValuePtr; +#endif // ARMNN_BUILD_BARE_METAL } void ProfilingService::Reset() { +#if !defined(ARMNN_BUILD_BARE_METAL) // Stop the profiling service... Stop(); @@ -347,10 +367,12 @@ void ProfilingService::Reset() // ...finally reset the profiling state machine m_StateMachine.Reset(); m_BackendProfilingContexts.clear(); +#endif // ARMNN_BUILD_BARE_METAL } void ProfilingService::Stop() { +#if !defined(ARMNN_BUILD_BARE_METAL) { // only lock when we are updating the inference completed variable std::unique_lock<std::mutex> lck(m_ServiceActiveMutex); m_ServiceActive = false; @@ -372,18 +394,22 @@ void ProfilingService::Stop() // ...then move to the "NotConnected" state m_StateMachine.TransitionToState(ProfilingState::NotConnected); +#endif // ARMNN_BUILD_BARE_METAL } inline void ProfilingService::CheckCounterUid(uint16_t counterUid) const { +#if !defined(ARMNN_BUILD_BARE_METAL) if (!IsCounterRegistered(counterUid)) { throw arm::pipe::InvalidArgumentException(fmt::format("Counter UID {} is not registered", counterUid)); } +#endif // ARMNN_BUILD_BARE_METAL } void ProfilingService::NotifyBackendsForTimelineReporting() { +#if !defined(ARMNN_BUILD_BARE_METAL) BackendProfilingContext::iterator it = m_BackendProfilingContexts.begin(); while (it != m_BackendProfilingContexts.end()) { @@ -392,19 +418,23 @@ void ProfilingService::NotifyBackendsForTimelineReporting() // Increment the Iterator to point to next entry it++; } +#endif // ARMNN_BUILD_BARE_METAL } void ProfilingService::NotifyProfilingServiceActive() { +#if !defined(ARMNN_BUILD_BARE_METAL) { // 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(); +#endif // ARMNN_BUILD_BARE_METAL } void ProfilingService::WaitForProfilingServiceActivation(unsigned int timeout) { +#if !defined(ARMNN_BUILD_BARE_METAL) std::unique_lock<std::mutex> lck(m_ServiceActiveMutex); auto start = std::chrono::high_resolution_clock::now(); @@ -425,12 +455,16 @@ void ProfilingService::WaitForProfilingServiceActivation(unsigned int timeout) ARM_PIPE_LOG(warning) << ss.str(); } return; +#endif // ARMNN_BUILD_BARE_METAL } ProfilingService::~ProfilingService() { +#if !defined(ARMNN_BUILD_BARE_METAL) Stop(); +#endif // ARMNN_BUILD_BARE_METAL } + } // namespace pipe } // namespace arm diff --git a/profiling/common/include/ProfilingGuidGenerator.hpp b/profiling/common/include/ProfilingGuidGenerator.hpp index bfee7642e9..22a488df93 100644 --- a/profiling/common/include/ProfilingGuidGenerator.hpp +++ b/profiling/common/include/ProfilingGuidGenerator.hpp @@ -26,7 +26,9 @@ public: /// Return the next random Guid in the sequence inline ProfilingDynamicGuid NextGuid() override { +#if !defined(ARMNN_DISABLE_THREADS) std::lock_guard<std::mutex> sequencelock(m_SequenceMutex); +#endif ProfilingDynamicGuid guid(m_Sequence); m_Sequence++; if (m_Sequence >= MIN_STATIC_GUID) @@ -47,14 +49,18 @@ public: /// Reset the generator back to zero. Used mainly for test. inline void Reset() { +#if !defined(ARMNN_DISABLE_THREADS) std::lock_guard<std::mutex> sequencelock(m_SequenceMutex); +#endif m_Sequence = 0; } private: std::hash<std::string> m_Hash; uint64_t m_Sequence; +#if !defined(ARMNN_DISABLE_THREADS) std::mutex m_SequenceMutex; +#endif }; } // namespace pipe diff --git a/profiling/common/src/CMakeLists.txt b/profiling/common/src/CMakeLists.txt index 94aec874f8..08d77c2b0f 100644 --- a/profiling/common/src/CMakeLists.txt +++ b/profiling/common/src/CMakeLists.txt @@ -30,6 +30,7 @@ # will only build a static version of this common code # to simplify the build. No extra .so file to deploy to boards etc. add_library_ex(pipeCommon STATIC ${pipeCommon_sources}) + target_link_libraries(pipeCommon fmt) target_compile_definitions(pipeCommon PRIVATE "ARMNN_COMPILING_DLL") |