From a3dc95ec2b0ac9e7f87dd32d03679a4b2a9b5d2a Mon Sep 17 00:00:00 2001 From: Ryan OShea Date: Mon, 20 Mar 2023 11:10:40 +0000 Subject: Improve reusability of code that is defined out by cmake build paths * Added new ARMNN_STUB_PROFILING and ARMNN_DISABLE_DYNAMIC_BACKEND defines to replace BUILD_BARE_METAL and BUILD_EXECUTE_NETWORK_STATIC * Add new CMake variables to disable sample apps and dynamic backends * Improve BUILD_SHARED_LIBS CMake variable * Add new archive output location to various libraries so that the static libraries appear in the same location as the shared libraries * Fixes for bare metal build * Add ARMNN_DISABLE_FILE_SYSTEM defines to missing locations Signed-off-by: Ryan OShea Change-Id: I1db9a8f483e7134bd261294b35240cf21b150d45 --- profiling/client/src/ProfilingService.cpp | 62 +++++++++++----------- profiling/server/src/basePipeServer/CMakeLists.txt | 2 + .../server/src/timelineDecoder/CMakeLists.txt | 2 + 3 files changed, 35 insertions(+), 31 deletions(-) (limited to 'profiling') diff --git a/profiling/client/src/ProfilingService.cpp b/profiling/client/src/ProfilingService.cpp index 37f0de9f6f..8dbe12ce69 100644 --- a/profiling/client/src/ProfilingService.cpp +++ b/profiling/client/src/ProfilingService.cpp @@ -10,7 +10,7 @@ #include #include -#if defined(ARMNN_BUILD_BARE_METAL) || defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if defined(ARMNN_STUB_PROFILING) #include #endif @@ -26,7 +26,7 @@ namespace pipe void ProfilingService::ResetExternalProfilingOptions(const arm::pipe::ProfilingOptions& options, bool resetProfilingService) { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) // Update the profiling options m_Options = options; m_TimelineReporting = options.m_TimelineEnabled; @@ -41,23 +41,23 @@ void ProfilingService::ResetExternalProfilingOptions(const arm::pipe::ProfilingO #else IgnoreUnused(options); IgnoreUnused(resetProfilingService); -#endif // ARMNN_BUILD_BARE_METAL || ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } bool ProfilingService::IsProfilingEnabled() const { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) return m_Options.m_EnableProfiling; #else return false; -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } ProfilingState ProfilingService::ConfigureProfilingService( const ProfilingOptions& options, bool resetProfilingService) { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) ResetExternalProfilingOptions(options, resetProfilingService); ProfilingState currentState = m_StateMachine.GetCurrentState(); if (options.m_EnableProfiling) @@ -106,12 +106,12 @@ ProfilingState ProfilingService::ConfigureProfilingService( IgnoreUnused(options); IgnoreUnused(resetProfilingService); return ProfilingState::Uninitialised; -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::Update() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) if (!m_Options.m_EnableProfiling) { // Don't run if profiling is disabled @@ -189,12 +189,12 @@ void ProfilingService::Update() throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", static_cast(currentState))); } -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::Disconnect() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) ProfilingState currentState = m_StateMachine.GetCurrentState(); switch (currentState) { @@ -211,7 +211,7 @@ void ProfilingService::Disconnect() throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", static_cast(currentState))); } -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } // Store a profiling context returned from a backend that support profiling, and register its counters @@ -219,7 +219,7 @@ void ProfilingService::AddBackendProfilingContext( const std::string& backendId, std::shared_ptr profilingContext) { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) ARM_PIPE_ASSERT(profilingContext != nullptr); // Register the backend counters m_MaxGlobalCounterId = profilingContext->RegisterCounters(m_MaxGlobalCounterId); @@ -227,7 +227,7 @@ void ProfilingService::AddBackendProfilingContext( #else IgnoreUnused(backendId); IgnoreUnused(profilingContext); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } const ICounterDirectory& ProfilingService::GetCounterDirectory() const { @@ -343,14 +343,14 @@ std::unique_ptr ProfilingService::GetSendTimelinePacket() c void ProfilingService::Initialize() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) m_Initialiser.InitialiseProfilingService(*this); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::InitializeCounterValue(uint16_t counterUid) { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) // Increase the size of the counter index if necessary if (counterUid >= m_CounterIndex.size()) { @@ -365,12 +365,12 @@ void ProfilingService::InitializeCounterValue(uint16_t counterUid) m_CounterIndex.at(counterUid) = counterValuePtr; #else IgnoreUnused(counterUid); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::Reset() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) // Stop the profiling service... Stop(); @@ -384,12 +384,12 @@ void ProfilingService::Reset() // ...finally reset the profiling state machine m_StateMachine.Reset(); m_BackendProfilingContexts.clear(); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::Stop() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) { // only lock when we are updating the inference completed variable std::unique_lock lck(m_ServiceActiveMutex); m_ServiceActive = false; @@ -411,24 +411,24 @@ void ProfilingService::Stop() // ...then move to the "NotConnected" state m_StateMachine.TransitionToState(ProfilingState::NotConnected); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } inline void ProfilingService::CheckCounterUid(uint16_t counterUid) const { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) if (!IsCounterRegistered(counterUid)) { throw arm::pipe::InvalidArgumentException(fmt::format("Counter UID {} is not registered", counterUid)); } #else IgnoreUnused(counterUid); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::NotifyBackendsForTimelineReporting() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) BackendProfilingContext::iterator it = m_BackendProfilingContexts.begin(); while (it != m_BackendProfilingContexts.end()) { @@ -437,23 +437,23 @@ void ProfilingService::NotifyBackendsForTimelineReporting() // Increment the Iterator to point to next entry it++; } -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::NotifyProfilingServiceActive() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) { // only lock when we are updating the inference completed variable std::unique_lock lck(m_ServiceActiveMutex); m_ServiceActive = true; } m_ServiceActiveConditionVariable.notify_one(); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::WaitForProfilingServiceActivation(unsigned int timeout) { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) std::unique_lock lck(m_ServiceActiveMutex); auto start = std::chrono::high_resolution_clock::now(); @@ -475,14 +475,14 @@ void ProfilingService::WaitForProfilingServiceActivation(unsigned int timeout) } #else IgnoreUnused(timeout); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } ProfilingService::~ProfilingService() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) Stop(); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } } // namespace pipe diff --git a/profiling/server/src/basePipeServer/CMakeLists.txt b/profiling/server/src/basePipeServer/CMakeLists.txt index b5dc68c2c4..ce957f6a5f 100644 --- a/profiling/server/src/basePipeServer/CMakeLists.txt +++ b/profiling/server/src/basePipeServer/CMakeLists.txt @@ -37,6 +37,8 @@ if(BUILD_BASE_PIPE_SERVER) endif() set_target_properties(armnnBasePipeServer PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + set_target_properties(armnnBasePipeServer PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + set_target_properties(armnnBasePipeServer PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION}) diff --git a/profiling/server/src/timelineDecoder/CMakeLists.txt b/profiling/server/src/timelineDecoder/CMakeLists.txt index 4ac68a52af..93513deef2 100644 --- a/profiling/server/src/timelineDecoder/CMakeLists.txt +++ b/profiling/server/src/timelineDecoder/CMakeLists.txt @@ -36,6 +36,8 @@ if(BUILD_TIMELINE_DECODER) endif() set_target_properties(timelineDecoder PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + set_target_properties(timelineDecoder PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + set_target_properties(timelineDecoder PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) install(TARGETS timelineDecoder -- cgit v1.2.1