ArmNN
 20.02
BackendProfiling Class Reference

#include <BackendProfiling.hpp>

Inheritance diagram for BackendProfiling:
IBackendProfiling

Public Member Functions

 BackendProfiling (const IRuntime::CreationOptions &options, IProfilingService &profilingService, const BackendId &backendId)
 
 ~BackendProfiling ()
 
std::unique_ptr< IRegisterBackendCountersGetCounterRegistrationInterface (uint16_t currentMaxGlobalCounterID) override
 
std::unique_ptr< ISendTimelinePacketGetSendTimelinePacket () override
 
IProfilingGuidGeneratorGetProfilingGuidGenerator () override
 
void ReportCounters (const std::vector< Timestamp > &) override
 
CounterStatus GetCounterStatus (uint16_t backendCounterId) override
 
std::vector< CounterStatusGetActiveCounters () override
 
bool IsProfilingEnabled () const override
 
- Public Member Functions inherited from IBackendProfiling
virtual ~IBackendProfiling ()
 

Detailed Description

Definition at line 17 of file BackendProfiling.hpp.

Constructor & Destructor Documentation

◆ BackendProfiling()

BackendProfiling ( const IRuntime::CreationOptions options,
IProfilingService profilingService,
const BackendId backendId 
)
inline

Definition at line 20 of file BackendProfiling.hpp.

23  : m_Options(options),
24  m_ProfilingService(profilingService),
25  m_BackendId(backendId) {}
ProfilingService & profilingService
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ ~BackendProfiling()

Member Function Documentation

◆ GetActiveCounters()

std::vector< CounterStatus > GetActiveCounters ( )
overridevirtual

Implements IBackendProfiling.

Definition at line 66 of file BackendProfiling.cpp.

References ICounterMappings::GetBackendId(), IProfilingService::GetCaptureData(), CaptureData::GetCapturePeriod(), CaptureData::GetCounterIds(), ProfilingService::GetCounterMappings(), and ProfilingService::Instance().

Referenced by BOOST_AUTO_TEST_CASE(), and BackendProfiling::~BackendProfiling().

67 {
68  CaptureData captureData = m_ProfilingService.GetCaptureData();
69 
70  const std::vector<uint16_t>& globalCounterIds = captureData.GetCounterIds();
71  std::vector<CounterStatus> activeCounterIds;
72 
73  for (auto globalCounterId : globalCounterIds) {
74  // Get pair of local counterId and backendId using globalCounterId
75  const std::pair<uint16_t, armnn::BackendId>& backendCounterIdPair =
77  if (backendCounterIdPair.second == m_BackendId)
78  {
79  activeCounterIds.emplace_back(backendCounterIdPair.first,
80  globalCounterId,
81  true,
82  captureData.GetCapturePeriod());
83  }
84  }
85 
86  return activeCounterIds;
87 }
static ProfilingService & Instance()
virtual CaptureData GetCaptureData()=0
const std::vector< uint16_t > & GetCounterIds() const
Definition: Holder.cpp:49
const ICounterMappings & GetCounterMappings() const override
virtual const std::pair< uint16_t, armnn::BackendId > & GetBackendId(uint16_t globalCounterId) const =0

◆ GetCounterRegistrationInterface()

std::unique_ptr< IRegisterBackendCounters > GetCounterRegistrationInterface ( uint16_t  currentMaxGlobalCounterID)
overridevirtual

Implements IBackendProfiling.

Definition at line 16 of file BackendProfiling.cpp.

Referenced by BackendProfiling::~BackendProfiling().

17 {
18  return std::make_unique<RegisterBackendCounters>(RegisterBackendCounters(currentMaxGlobalCounterID, m_BackendId));
19 }

◆ GetCounterStatus()

CounterStatus GetCounterStatus ( uint16_t  backendCounterId)
overridevirtual

Implements IBackendProfiling.

Definition at line 50 of file BackendProfiling.cpp.

References IProfilingService::GetCaptureData(), CaptureData::GetCapturePeriod(), IProfilingService::GetCounterMappings(), ICounterMappings::GetGlobalId(), CaptureData::IsCounterIdInCaptureData(), CounterStatus::m_Enabled, and CounterStatus::m_SamplingRateInMicroseconds.

Referenced by BOOST_AUTO_TEST_CASE(), and BackendProfiling::~BackendProfiling().

51 {
52  uint16_t globalCounterId = m_ProfilingService.GetCounterMappings().GetGlobalId(backendCounterId, m_BackendId);
53  CaptureData captureData = m_ProfilingService.GetCaptureData();
54 
55  CounterStatus counterStatus(backendCounterId, globalCounterId, false, 0);
56 
57  if (captureData.IsCounterIdInCaptureData(globalCounterId))
58  {
59  counterStatus.m_Enabled = true;
60  counterStatus.m_SamplingRateInMicroseconds = captureData.GetCapturePeriod();
61  }
62 
63  return counterStatus;
64 }
virtual CaptureData GetCaptureData()=0
virtual const ICounterMappings & GetCounterMappings() const =0
virtual uint16_t GetGlobalId(uint16_t backendCounterId, const armnn::BackendId &backendId) const =0

◆ GetProfilingGuidGenerator()

IProfilingGuidGenerator & GetProfilingGuidGenerator ( )
overridevirtual

Implements IBackendProfiling.

Definition at line 26 of file BackendProfiling.cpp.

Referenced by BackendProfiling::~BackendProfiling().

27 {
28  // The profiling service is our Guid Generator.
29  return m_ProfilingService;
30 }

◆ GetSendTimelinePacket()

std::unique_ptr< ISendTimelinePacket > GetSendTimelinePacket ( )
overridevirtual

Implements IBackendProfiling.

Definition at line 21 of file BackendProfiling.cpp.

References IProfilingService::GetSendTimelinePacket().

Referenced by BackendProfiling::~BackendProfiling().

22 {
23  return m_ProfilingService.GetSendTimelinePacket();
24 }
virtual std::unique_ptr< ISendTimelinePacket > GetSendTimelinePacket() const =0

◆ IsProfilingEnabled()

bool IsProfilingEnabled ( ) const
overridevirtual

Implements IBackendProfiling.

Definition at line 89 of file BackendProfiling.cpp.

References IProfilingService::IsProfilingEnabled().

Referenced by BackendProfiling::~BackendProfiling().

90 {
91  return m_ProfilingService.IsProfilingEnabled();
92 }
virtual bool IsProfilingEnabled() const =0

◆ ReportCounters()

void ReportCounters ( const std::vector< Timestamp > &  timestamps)
overridevirtual

Implements IBackendProfiling.

Definition at line 32 of file BackendProfiling.cpp.

References IProfilingService::GetCounterMappings(), ICounterMappings::GetGlobalId(), IProfilingService::GetSendCounterPacket(), and ISendCounterPacket::SendPeriodicCounterCapturePacket().

Referenced by BOOST_AUTO_TEST_CASE(), and BackendProfiling::~BackendProfiling().

33 {
34  for (const auto timestampInfo : timestamps)
35  {
36  std::vector<CounterValue> backendCounterValues = timestampInfo.counterValues;
37  for_each(backendCounterValues.begin(), backendCounterValues.end(), [&](CounterValue& backendCounterValue)
38  {
39  // translate the counterId to globalCounterId
40  backendCounterValue.counterId = m_ProfilingService.GetCounterMappings().GetGlobalId(
41  backendCounterValue.counterId, m_BackendId);
42  });
43 
44  // Send Periodic Counter Capture Packet for the Timestamp
46  timestampInfo.timestamp, backendCounterValues);
47  }
48 }
virtual const ICounterMappings & GetCounterMappings() const =0
virtual void SendPeriodicCounterCapturePacket(uint64_t timestamp, const IndexValuePairsVector &values)=0
Create and write a PeriodicCounterCapturePacket from the parameters to the buffer.
virtual ISendCounterPacket & GetSendCounterPacket()=0
virtual uint16_t GetGlobalId(uint16_t backendCounterId, const armnn::BackendId &backendId) const =0

The documentation for this class was generated from the following files: