Skip to content

Commit

Permalink
IVGCVSW-6811 replace ProfilingService includes with IProfilingService
Browse files Browse the repository at this point in the history
Change-Id: I00521756c8a19d10bfdc98c6ef4204c7f84901c6
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
  • Loading branch information
jimfly01 committed Mar 3, 2022
1 parent 2b679db commit af94772
Show file tree
Hide file tree
Showing 26 changed files with 228 additions and 149 deletions.
1 change: 1 addition & 0 deletions Android.mk
Expand Up @@ -243,6 +243,7 @@ LOCAL_SRC_FILES := \
src/profiling/DirectoryCaptureCommandHandler.cpp \
src/profiling/FileOnlyProfilingConnection.cpp \
src/profiling/Holder.cpp \
src/profiling/IProfilingService.cpp \
src/profiling/PacketBuffer.cpp \
src/profiling/PeriodicCounterCapture.cpp \
src/profiling/PeriodicCounterSelectionCommandHandler.cpp \
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Expand Up @@ -448,6 +448,8 @@ list(APPEND armnn_sources
src/profiling/IPacketBuffer.hpp
src/profiling/IPeriodicCounterCapture.hpp
src/profiling/IProfilingConnection.hpp
src/profiling/IProfilingService.cpp
src/profiling/IProfilingService.hpp
src/profiling/IProfilingConnectionFactory.hpp
src/profiling/NullProfilingConnection.hpp
src/profiling/PacketBuffer.cpp
Expand All @@ -464,6 +466,7 @@ list(APPEND armnn_sources
src/profiling/ProfilingConnectionFactory.hpp
src/profiling/ProfilingService.cpp
src/profiling/ProfilingService.hpp
src/profiling/ProfilingState.hpp
src/profiling/ProfilingStateMachine.cpp
src/profiling/ProfilingStateMachine.hpp
src/profiling/ProfilingUtils.cpp
Expand Down
6 changes: 3 additions & 3 deletions include/armnn/BackendRegistry.hpp
Expand Up @@ -20,7 +20,7 @@ namespace arm
namespace pipe
{

class ProfilingService;
class IProfilingService;

} // namespace arm
} // namespace pipe
Expand All @@ -44,7 +44,7 @@ class BackendRegistry
size_t Size() const;
BackendIdSet GetBackendIds() const;
std::string GetBackendIdsAsString() const;
void SetProfilingService(armnn::Optional<arm::pipe::ProfilingService&> profilingService);
void SetProfilingService(armnn::Optional<arm::pipe::IProfilingService&> profilingService);
void RegisterAllocator(const BackendId& id, std::shared_ptr<ICustomAllocator> alloc);
std::unordered_map<BackendId, std::shared_ptr<ICustomAllocator>> GetAllocators();
void RegisterMemoryOptimizerStrategy(const BackendId& id, std::shared_ptr<IMemoryOptimizerStrategy> strategy);
Expand Down Expand Up @@ -78,7 +78,7 @@ class BackendRegistry
BackendRegistry& operator=(const BackendRegistry&) = delete;

FactoryStorage m_Factories;
armnn::Optional<arm::pipe::ProfilingService&> m_ProfilingService;
armnn::Optional<arm::pipe::IProfilingService&> m_ProfilingService;
std::unordered_map<BackendId, std::shared_ptr<ICustomAllocator>> m_CustomMemoryAllocatorMap;
std::unordered_map<BackendId, std::shared_ptr<IMemoryOptimizerStrategy>> m_MemoryOptimizerStrategyMap;
};
Expand Down
4 changes: 2 additions & 2 deletions include/armnn/backends/Workload.hpp
Expand Up @@ -10,7 +10,7 @@
#include "WorkingMemDescriptor.hpp"

#include <Profiling.hpp>
#include <ProfilingService.hpp>
#include <IProfilingService.hpp>

#include <algorithm>

Expand All @@ -32,7 +32,7 @@ class BaseWorkload : public IWorkload

BaseWorkload(const QueueDescriptor& descriptor, const WorkloadInfo& info)
: m_Data(descriptor),
m_Guid(arm::pipe::ProfilingService::GetNextGuid())
m_Guid(arm::pipe::IProfilingService::GetNextGuid())
{
m_Data.Validate(info);
}
Expand Down
22 changes: 22 additions & 0 deletions include/armnn/profiling/ArmNNProfiling.hpp
@@ -0,0 +1,22 @@
//
// Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//

#pragma once

namespace arm
{

namespace pipe
{
// Static constants describing ArmNN's counter UID's
static const uint16_t NETWORK_LOADS = 0;
static const uint16_t NETWORK_UNLOADS = 1;
static const uint16_t REGISTERED_BACKENDS = 2;
static const uint16_t UNREGISTERED_BACKENDS = 3;
static const uint16_t INFERENCES_RUN = 4;
static const uint16_t MAX_ARMNN_COUNTER = INFERENCES_RUN;
} // namespace pipe

} // namespace arm
Expand Up @@ -5,6 +5,8 @@

#include <server/include/basePipeServer/ConnectionHandler.hpp>

#include <BufferManager.hpp>
#include <SendCounterPacket.hpp>
#include <SocketProfilingConnection.hpp>
#include <Processes.hpp>

Expand Down Expand Up @@ -94,4 +96,4 @@ TEST_CASE("BasePipeServerTest")
socketProfilingConnection.Close();
}

}
}
5 changes: 3 additions & 2 deletions src/armnn/BackendRegistry.cpp
Expand Up @@ -5,7 +5,8 @@

#include <armnn/BackendRegistry.hpp>
#include <armnn/Exceptions.hpp>
#include <ProfilingService.hpp>
#include <armnn/profiling/ArmNNProfiling.hpp>
#include <IProfilingService.hpp>

namespace armnn
{
Expand Down Expand Up @@ -102,7 +103,7 @@ void BackendRegistry::Swap(BackendRegistry& instance, BackendRegistry::FactorySt
std::swap(instance.m_Factories, other);
}

void BackendRegistry::SetProfilingService(armnn::Optional<arm::pipe::ProfilingService&> profilingService)
void BackendRegistry::SetProfilingService(armnn::Optional<arm::pipe::IProfilingService&> profilingService)
{
m_ProfilingService = profilingService;
}
Expand Down
4 changes: 2 additions & 2 deletions src/armnn/Layer.cpp
Expand Up @@ -5,7 +5,7 @@
#include "Layer.hpp"

#include "Graph.hpp"
#include <ProfilingService.hpp>
#include <IProfilingService.hpp>
#include <armnn/utility/NumericCast.hpp>
#include <armnn/backends/TensorHandle.hpp>
#include <armnn/backends/WorkloadData.hpp>
Expand Down Expand Up @@ -202,7 +202,7 @@ Layer::Layer(unsigned int numInputSlots,
, m_Type(type)
, m_BackendId()
, m_BackendHint(EmptyOptional())
, m_Guid(arm::pipe::ProfilingService::GetNextGuid())
, m_Guid(arm::pipe::IProfilingService::GetNextGuid())
{
IgnoreUnused(layout);
m_InputSlots.reserve(numInputSlots);
Expand Down
25 changes: 13 additions & 12 deletions src/armnn/LoadedNetwork.cpp
Expand Up @@ -20,6 +20,7 @@
#include <armnn/backends/MemCopyWorkload.hpp>
#include <backendsCommon/MemSyncWorkload.hpp>
#include <armnn/BackendHelper.hpp>
#include <armnn/profiling/ArmNNProfiling.hpp>

#include <fmt/format.h>

Expand Down Expand Up @@ -82,7 +83,7 @@ void AddWorkloadStructure(std::unique_ptr<TimelineUtilityMethods>& timelineUtils
std::unique_ptr<LoadedNetwork> LoadedNetwork::MakeLoadedNetwork(std::unique_ptr<IOptimizedNetwork> net,
std::string& errorMessage,
const INetworkProperties& networkProperties,
ProfilingService& profilingService)
arm::pipe::IProfilingService* profilingService)
{
std::unique_ptr<LoadedNetwork> loadedNetwork;

Expand Down Expand Up @@ -116,7 +117,7 @@ std::unique_ptr<LoadedNetwork> LoadedNetwork::MakeLoadedNetwork(std::unique_ptr<

LoadedNetwork::LoadedNetwork(std::unique_ptr<IOptimizedNetwork> net,
const INetworkProperties& networkProperties,
ProfilingService& profilingService) :
arm::pipe::IProfilingService* profilingService) :
m_OptimizedNetwork(std::move(net)),
m_NetworkProperties(networkProperties),
m_TensorHandleFactoryRegistry(),
Expand Down Expand Up @@ -254,7 +255,7 @@ LoadedNetwork::LoadedNetwork(std::unique_ptr<IOptimizedNetwork> net,

ProfilingGuid networkGuid = m_OptimizedNetwork->GetGuid();
std::unique_ptr<TimelineUtilityMethods> timelineUtils =
TimelineUtilityMethods::GetTimelineUtils(m_ProfilingService);
TimelineUtilityMethods::GetTimelineUtils(*m_ProfilingService);
if (timelineUtils)
{
timelineUtils->CreateTypedEntity(networkGuid, LabelsAndEventClasses::NETWORK_GUID);
Expand Down Expand Up @@ -549,7 +550,7 @@ void LoadedNetwork::SendNetworkStructure()
ProfilingGuid networkGuid = m_OptimizedNetwork->GetGuid();

std::unique_ptr<TimelineUtilityMethods> timelineUtils =
TimelineUtilityMethods::GetTimelineUtils(m_ProfilingService);
TimelineUtilityMethods::GetTimelineUtils(*m_ProfilingService);

timelineUtils->CreateTypedEntity(networkGuid, LabelsAndEventClasses::NETWORK_GUID);

Expand Down Expand Up @@ -893,8 +894,8 @@ Status LoadedNetwork::EnqueueWorkload(const InputTensors& inputTensors,
}

std::unique_ptr<TimelineUtilityMethods> timelineUtils =
TimelineUtilityMethods::GetTimelineUtils(m_ProfilingService);
ProfilingGuid inferenceGuid = m_ProfilingService.GetNextGuid();
TimelineUtilityMethods::GetTimelineUtils(*m_ProfilingService);
ProfilingGuid inferenceGuid = m_ProfilingService->GetNextGuid();
if (timelineUtils)
{
// Add inference timeline trace if profiling is enabled.
Expand All @@ -910,9 +911,9 @@ Status LoadedNetwork::EnqueueWorkload(const InputTensors& inputTensors,
bool executionSucceeded = true;

{
if (m_ProfilingService.IsProfilingEnabled())
if (m_ProfilingService->IsProfilingEnabled())
{
m_ProfilingService.IncrementCounterValue(INFERENCES_RUN);
m_ProfilingService->IncrementCounterValue(INFERENCES_RUN);
}
ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Execute");
ARMNN_SCOPED_HEAP_PROFILING("Executing");
Expand Down Expand Up @@ -982,7 +983,7 @@ void LoadedNetwork::EnqueueInput(const BindableLayer& layer, ITensorHandle* tens
ARMNN_ASSERT_MSG(inputWorkload, "No input workload created");

std::unique_ptr<TimelineUtilityMethods> timelineUtils =
TimelineUtilityMethods::GetTimelineUtils(m_ProfilingService);
TimelineUtilityMethods::GetTimelineUtils(*m_ProfilingService);
if (timelineUtils)
{
// Add Input Workload to the post-optimisation network structure
Expand Down Expand Up @@ -1070,7 +1071,7 @@ void LoadedNetwork::EnqueueOutput(const BindableLayer& layer, ITensorHandle* ten
ARMNN_ASSERT_MSG(outputWorkload, "No output workload created");

std::unique_ptr<TimelineUtilityMethods> timelineUtils =
TimelineUtilityMethods::GetTimelineUtils(m_ProfilingService);
TimelineUtilityMethods::GetTimelineUtils(*m_ProfilingService);
if (timelineUtils)
{
// Add Output Workload to the post-optimisation network structure
Expand Down Expand Up @@ -1683,8 +1684,8 @@ Status LoadedNetwork::Execute(const InputTensors& inputTensors,
};

std::unique_ptr<TimelineUtilityMethods> timelineUtils =
TimelineUtilityMethods::GetTimelineUtils(m_ProfilingService);
ProfilingGuid inferenceGuid = m_ProfilingService.GetNextGuid();
TimelineUtilityMethods::GetTimelineUtils(*m_ProfilingService);
ProfilingGuid inferenceGuid = m_ProfilingService->GetNextGuid();
if (timelineUtils)
{
// Add inference timeline trace if profiling is enabled.
Expand Down
9 changes: 5 additions & 4 deletions src/armnn/LoadedNetwork.hpp
Expand Up @@ -19,7 +19,7 @@
#include <backendsCommon/memoryOptimizerStrategyLibrary/strategies/SingleAxisPriorityList.hpp>


#include <ProfilingService.hpp>
#include <IProfilingService.hpp>
#include <TimelineUtilityMethods.hpp>

#include <common/include/LabelsAndEventClasses.hpp>
Expand Down Expand Up @@ -78,7 +78,7 @@ class LoadedNetwork
static std::unique_ptr<LoadedNetwork> MakeLoadedNetwork(std::unique_ptr<IOptimizedNetwork> net,
std::string& errorMessage,
const INetworkProperties& networkProperties,
arm::pipe::ProfilingService& profilingService);
arm::pipe::IProfilingService* profilingService);

// NOTE we return by reference as the purpose of this method is only to provide
// access to the private m_Profiler and in theory we should not need to increment
Expand Down Expand Up @@ -112,7 +112,7 @@ class LoadedNetwork

LoadedNetwork(std::unique_ptr<IOptimizedNetwork> net,
const INetworkProperties& networkProperties,
arm::pipe::ProfilingService& profilingService);
arm::pipe::IProfilingService* profilingService);

void EnqueueInput(const BindableLayer& layer, ITensorHandle* tensorHandle, const TensorInfo& tensorInfo);

Expand Down Expand Up @@ -158,7 +158,8 @@ class LoadedNetwork

TensorHandleFactoryRegistry m_TensorHandleFactoryRegistry;

arm::pipe::ProfilingService& m_ProfilingService;
// NOTE: raw pointer because the profiling service is controlled by the Runtime
arm::pipe::IProfilingService* m_ProfilingService;

struct ImportedTensorHandlePin
{
Expand Down
8 changes: 4 additions & 4 deletions src/armnn/Network.cpp
Expand Up @@ -26,7 +26,7 @@
#include <armnn/utility/IgnoreUnused.hpp>
#include <armnn/utility/PolymorphicDowncast.hpp>

#include <ProfilingService.hpp>
#include <IProfilingService.hpp>

#include <common/include/ProfilingGuid.hpp>

Expand Down Expand Up @@ -2866,18 +2866,18 @@ void NetworkImpl::ExecuteStrategy(IStrategy& strategy) const

OptimizedNetworkImpl::OptimizedNetworkImpl(const OptimizedNetworkImpl& other, const ModelOptions& modelOptions)
: m_Graph(new Graph(*other.m_Graph.get()))
, m_Guid(arm::pipe::ProfilingService::GetNextGuid())
, m_Guid(arm::pipe::IProfilingService::GetNextGuid())
, m_ModelOptions(modelOptions)
{
}

OptimizedNetworkImpl::OptimizedNetworkImpl(std::unique_ptr<Graph> graph)
: m_Graph(std::move(graph)), m_Guid(arm::pipe::ProfilingService::GetNextGuid())
: m_Graph(std::move(graph)), m_Guid(arm::pipe::IProfilingService::GetNextGuid())
{
}

OptimizedNetworkImpl::OptimizedNetworkImpl(std::unique_ptr<Graph> graph, const ModelOptions& modelOptions)
: m_Graph(std::move(graph)), m_Guid(arm::pipe::ProfilingService::GetNextGuid()), m_ModelOptions(modelOptions)
: m_Graph(std::move(graph)), m_Guid(arm::pipe::IProfilingService::GetNextGuid()), m_ModelOptions(modelOptions)
{
}

Expand Down

0 comments on commit af94772

Please sign in to comment.