ArmNN
 21.11
PeriodicCounterCapture Class Referencefinal

#include <PeriodicCounterCapture.hpp>

Inheritance diagram for PeriodicCounterCapture:
IPeriodicCounterCapture

Public Member Functions

 PeriodicCounterCapture (const Holder &data, ISendCounterPacket &packet, IReadCounterValues &readCounterValue, const ICounterMappings &counterIdMap, const std::unordered_map< armnn::BackendId, std::shared_ptr< armnn::profiling::IBackendProfilingContext >> &backendProfilingContexts)
 
 ~PeriodicCounterCapture ()
 
void Start () override
 
void Stop () override
 
bool IsRunning () const
 
- Public Member Functions inherited from IPeriodicCounterCapture
virtual ~IPeriodicCounterCapture ()
 

Detailed Description

Definition at line 28 of file PeriodicCounterCapture.hpp.

Constructor & Destructor Documentation

◆ PeriodicCounterCapture()

PeriodicCounterCapture ( const Holder data,
ISendCounterPacket packet,
IReadCounterValues readCounterValue,
const ICounterMappings counterIdMap,
const std::unordered_map< armnn::BackendId, std::shared_ptr< armnn::profiling::IBackendProfilingContext >> &  backendProfilingContexts 
)
inline

Definition at line 31 of file PeriodicCounterCapture.hpp.

38  : m_CaptureDataHolder(data)
39  , m_IsRunning(false)
40  , m_KeepRunning(false)
41  , m_ReadCounterValues(readCounterValue)
42  , m_SendCounterPacket(packet)
43  , m_CounterIdMap(counterIdMap)
44  , m_BackendProfilingContexts(backendProfilingContexts)
45  {}

◆ ~PeriodicCounterCapture()

Member Function Documentation

◆ IsRunning()

bool IsRunning ( ) const
inline

Definition at line 50 of file PeriodicCounterCapture.hpp.

50 { return m_IsRunning; }

◆ Start()

void Start ( )
overridevirtual

Implements IPeriodicCounterCapture.

Definition at line 18 of file PeriodicCounterCapture.cpp.

Referenced by TEST_SUITE(), and PeriodicCounterCapture::~PeriodicCounterCapture().

19 {
20  // Check if the capture thread is already running
21  if (m_IsRunning)
22  {
23  // The capture thread is already running
24  return;
25  }
26 
27  // Mark the capture thread as running
28  m_IsRunning = true;
29 
30  // Keep the capture procedure going until the capture thread is signalled to stop
31  m_KeepRunning.store(true);
32 
33  // Start the new capture thread.
34  m_PeriodCaptureThread = std::thread(&PeriodicCounterCapture::Capture, this, std::ref(m_ReadCounterValues));
35 }

◆ Stop()

void Stop ( )
overridevirtual

Implements IPeriodicCounterCapture.

Definition at line 37 of file PeriodicCounterCapture.cpp.

References ARMNN_LOG, Holder::GetCaptureData(), IReadCounterValues::GetDeltaCounterValue(), ICounterMappings::GetGlobalId(), armnn::profiling::GetTimestamp(), ISendCounterPacket::SendPeriodicCounterCapturePacket(), armnn::warning, and Exception::what().

Referenced by ProfilingService::GetSendTimelinePacket(), TEST_SUITE(), ProfilingService::Update(), and PeriodicCounterCapture::~PeriodicCounterCapture().

38 {
39  // Signal the capture thread to stop
40  m_KeepRunning.store(false);
41 
42  // Check that the capture thread is running
43  if (m_PeriodCaptureThread.joinable())
44  {
45  // Wait for the capture thread to complete operations
46  m_PeriodCaptureThread.join();
47  }
48 
49  // Mark the capture thread as not running
50  m_IsRunning = false;
51 }

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