ArmNN
 20.02
SwapProfilingConnectionFactoryHelper Class Reference

#include <ProfilingTests.hpp>

Inheritance diagram for SwapProfilingConnectionFactoryHelper:
ProfilingService IReadWriteCounterValues IProfilingService IReadCounterValues IWriteCounterValues IProfilingGuidGenerator

Public Types

using MockProfilingConnectionFactoryPtr = std::unique_ptr< MockProfilingConnectionFactory >
 
- Public Types inherited from ProfilingService
using ExternalProfilingOptions = IRuntime::CreationOptions::ExternalProfilingOptions
 
using IProfilingConnectionFactoryPtr = std::unique_ptr< IProfilingConnectionFactory >
 
using IProfilingConnectionPtr = std::unique_ptr< IProfilingConnection >
 
using CounterIndices = std::vector< std::atomic< uint32_t > * >
 
using CounterValues = std::list< std::atomic< uint32_t > >
 

Public Member Functions

 SwapProfilingConnectionFactoryHelper ()
 
 ~SwapProfilingConnectionFactoryHelper ()
 
MockProfilingConnectionGetMockProfilingConnection ()
 
void ForceTransitionToState (ProfilingState newState)
 
long WaitForPacketsSent (MockProfilingConnection *mockProfilingConnection, MockProfilingConnection::PacketType packetType, uint32_t length=0, uint32_t timeout=1000)
 
- Public Member Functions inherited from ProfilingService
void ResetExternalProfilingOptions (const ExternalProfilingOptions &options, bool resetProfilingService=false)
 
ProfilingState ConfigureProfilingService (const ExternalProfilingOptions &options, bool resetProfilingService=false)
 
void Update ()
 
void Disconnect ()
 
void AddBackendProfilingContext (const BackendId backendId, std::shared_ptr< armnn::profiling::IBackendProfilingContext > profilingContext)
 
const ICounterDirectoryGetCounterDirectory () const
 
ICounterRegistryGetCounterRegistry ()
 
ProfilingState GetCurrentState () const
 
bool IsCounterRegistered (uint16_t counterUid) const override
 
uint32_t GetCounterValue (uint16_t counterUid) const override
 
uint16_t GetCounterCount () const override
 
const ICounterMappingsGetCounterMappings () const override
 
IRegisterCounterMappingGetCounterMappingRegistry ()
 
bool IsProfilingEnabled () const override
 
CaptureData GetCaptureData () override
 
void SetCaptureData (uint32_t capturePeriod, const std::vector< uint16_t > &counterIds, const std::set< BackendId > &activeBackends)
 
void SetCounterValue (uint16_t counterUid, uint32_t value) override
 
uint32_t AddCounterValue (uint16_t counterUid, uint32_t value) override
 
uint32_t SubtractCounterValue (uint16_t counterUid, uint32_t value) override
 
uint32_t IncrementCounterValue (uint16_t counterUid) override
 
ProfilingDynamicGuid NextGuid () override
 Return the next random Guid in the sequence. More...
 
ProfilingStaticGuid GenerateStaticId (const std::string &str) override
 Create a ProfilingStaticGuid based on a hash of the string. More...
 
std::unique_ptr< ISendTimelinePacketGetSendTimelinePacket () const override
 
ISendCounterPacketGetSendCounterPacket () override
 
bool IsEnabled ()
 Check if the profiling is enabled. More...
 
- Public Member Functions inherited from IReadWriteCounterValues
virtual ~IReadWriteCounterValues ()
 
- Public Member Functions inherited from IReadCounterValues
virtual ~IReadCounterValues ()
 
- Public Member Functions inherited from IWriteCounterValues
virtual ~IWriteCounterValues ()
 
- Public Member Functions inherited from IProfilingService
virtual ~IProfilingService ()
 
- Public Member Functions inherited from IProfilingGuidGenerator
virtual ~IProfilingGuidGenerator ()
 

Additional Inherited Members

- Static Public Member Functions inherited from ProfilingService
static ProfilingServiceInstance ()
 
- Protected Member Functions inherited from ProfilingService
 ProfilingService ()
 
 ~ProfilingService ()
 
void SwapProfilingConnectionFactory (ProfilingService &instance, IProfilingConnectionFactory *other, IProfilingConnectionFactory *&backup)
 
IProfilingConnectionGetProfilingConnection (ProfilingService &instance)
 
void TransitionToState (ProfilingService &instance, ProfilingState newState)
 
bool WaitForPacketSent (ProfilingService &instance, uint32_t timeout=1000)
 
BufferManagerGetBufferManager (ProfilingService &instance)
 

Detailed Description

Definition at line 202 of file ProfilingTests.hpp.

Member Typedef Documentation

◆ MockProfilingConnectionFactoryPtr

Definition at line 205 of file ProfilingTests.hpp.

Constructor & Destructor Documentation

◆ SwapProfilingConnectionFactoryHelper()

Definition at line 207 of file ProfilingTests.hpp.

References BOOST_CHECK(), and ProfilingService::Instance().

208  : ProfilingService()
209  , m_MockProfilingConnectionFactory(new MockProfilingConnectionFactory())
210  , m_BackupProfilingConnectionFactory(nullptr)
211  {
212  BOOST_CHECK(m_MockProfilingConnectionFactory);
214  m_MockProfilingConnectionFactory.get(),
215  m_BackupProfilingConnectionFactory);
216  BOOST_CHECK(m_BackupProfilingConnectionFactory);
217  }
static ProfilingService & Instance()
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
void SwapProfilingConnectionFactory(ProfilingService &instance, IProfilingConnectionFactory *other, IProfilingConnectionFactory *&backup)

◆ ~SwapProfilingConnectionFactoryHelper()

Definition at line 218 of file ProfilingTests.hpp.

References BOOST_CHECK(), and ProfilingService::Instance().

219  {
220  BOOST_CHECK(m_BackupProfilingConnectionFactory);
221  IProfilingConnectionFactory* temp = nullptr;
223  m_BackupProfilingConnectionFactory,
224  temp);
225  }
static ProfilingService & Instance()
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
void SwapProfilingConnectionFactory(ProfilingService &instance, IProfilingConnectionFactory *other, IProfilingConnectionFactory *&backup)

Member Function Documentation

◆ ForceTransitionToState()

void ForceTransitionToState ( ProfilingState  newState)
inline

Definition at line 233 of file ProfilingTests.hpp.

References ProfilingService::Instance().

Referenced by BOOST_AUTO_TEST_CASE().

234  {
236  }
static ProfilingService & Instance()
void TransitionToState(ProfilingService &instance, ProfilingState newState)

◆ GetMockProfilingConnection()

MockProfilingConnection* GetMockProfilingConnection ( )
inline

Definition at line 227 of file ProfilingTests.hpp.

References ProfilingService::Instance().

Referenced by BOOST_AUTO_TEST_CASE().

228  {
229  IProfilingConnection* profilingConnection = GetProfilingConnection(ProfilingService::Instance());
230  return boost::polymorphic_downcast<MockProfilingConnection*>(profilingConnection);
231  }
static ProfilingService & Instance()
IProfilingConnection * GetProfilingConnection(ProfilingService &instance)

◆ WaitForPacketsSent()

long WaitForPacketsSent ( MockProfilingConnection mockProfilingConnection,
MockProfilingConnection::PacketType  packetType,
uint32_t  length = 0,
uint32_t  timeout = 1000 
)
inline

Definition at line 238 of file ProfilingTests.hpp.

References MockProfilingConnection::CheckForPacket(), ProfilingService::Instance(), packetCount, and ProfilingService::WaitForPacketSent().

Referenced by BOOST_AUTO_TEST_CASE().

242  {
243  long packetCount = mockProfilingConnection->CheckForPacket({packetType, length});
244  // The first packet we receive may not be the one we are looking for, so keep looping until till we find it,
245  // or until WaitForPacketsSent times out
246  while(packetCount == 0 && timeout != 0)
247  {
248  std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
249  // Wait for a notification from the send thread
251 
252  std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
253 
254  // We need to make sure the timeout does not reset each time we call WaitForPacketsSent
255  uint32_t elapsedTime = static_cast<uint32_t>(
256  std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count());
257 
258  packetCount = mockProfilingConnection->CheckForPacket({packetType, length});
259 
260  if (elapsedTime > timeout)
261  {
262  break;
263  }
264 
265  timeout -= elapsedTime;
266  }
267  return packetCount;
268  }
static ProfilingService & Instance()
bool WaitForPacketSent(ProfilingService &instance, uint32_t timeout=1000)

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