ArmNN
 21.02
BackendProfiling Class Reference

#include <BackendProfiling.hpp>

Inheritance diagram for BackendProfiling:
IBackendProfiling

Public Member Functions

 BackendProfiling (const IRuntime::CreationOptions &options, ProfilingService &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,
ProfilingService 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) {}

◆ ~BackendProfiling()

Member Function Documentation

◆ GetActiveCounters()

std::vector< CounterStatus > GetActiveCounters ( )
overridevirtual

Implements IBackendProfiling.

Definition at line 67 of file BackendProfiling.cpp.

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

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

68 {
69  CaptureData captureData = m_ProfilingService.GetCaptureData();
70 
71  const std::vector<uint16_t>& globalCounterIds = captureData.GetCounterIds();
72  std::vector<CounterStatus> activeCounterIds;
73 
74  for (auto globalCounterId : globalCounterIds) {
75  // Get pair of local counterId and backendId using globalCounterId
76  const std::pair<uint16_t, armnn::BackendId>& backendCounterIdPair =
77  m_ProfilingService.GetCounterMappings().GetBackendId(globalCounterId);
78  if (backendCounterIdPair.second == m_BackendId)
79  {
80  activeCounterIds.emplace_back(backendCounterIdPair.first,
81  globalCounterId,
82  true,
83  captureData.GetCapturePeriod());
84  }
85  }
86 
87  return activeCounterIds;
88 }
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>(
19  RegisterBackendCounters(currentMaxGlobalCounterID, m_BackendId, m_ProfilingService));
20 }

◆ GetCounterStatus()

CounterStatus GetCounterStatus ( uint16_t  backendCounterId)
overridevirtual

Implements IBackendProfiling.

Definition at line 51 of file BackendProfiling.cpp.

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

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

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

◆ GetProfilingGuidGenerator()

IProfilingGuidGenerator & GetProfilingGuidGenerator ( )
overridevirtual

Implements IBackendProfiling.

Definition at line 27 of file BackendProfiling.cpp.

Referenced by BackendProfiling::~BackendProfiling().

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

◆ GetSendTimelinePacket()

std::unique_ptr< ISendTimelinePacket > GetSendTimelinePacket ( )
overridevirtual

Implements IBackendProfiling.

Definition at line 22 of file BackendProfiling.cpp.

References ProfilingService::GetSendTimelinePacket().

Referenced by BackendProfiling::~BackendProfiling().

23 {
24  return m_ProfilingService.GetSendTimelinePacket();
25 }
std::unique_ptr< ISendTimelinePacket > GetSendTimelinePacket() const override

◆ IsProfilingEnabled()

bool IsProfilingEnabled ( ) const
overridevirtual

Implements IBackendProfiling.

Definition at line 90 of file BackendProfiling.cpp.

References ProfilingService::IsProfilingEnabled().

Referenced by BackendProfiling::~BackendProfiling().

91 {
92  return m_ProfilingService.IsProfilingEnabled();
93 }
bool IsProfilingEnabled() const override

◆ ReportCounters()

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

Implements IBackendProfiling.

Definition at line 33 of file BackendProfiling.cpp.

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

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

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

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