ArmNN
 21.02
SwapProfilingConnectionFactoryHelper Class Reference

#include <ProfilingTests.hpp>

Inheritance diagram for SwapProfilingConnectionFactoryHelper:
ProfilingService IReadWriteCounterValues IProfilingService INotifyBackends IReadCounterValues IWriteCounterValues IProfilingGuidGenerator IProfilingServiceStatus

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 > >
 
using BackendProfilingContext = std::unordered_map< BackendId, std::shared_ptr< armnn::profiling::IBackendProfilingContext > >
 

Public Member Functions

 SwapProfilingConnectionFactoryHelper (armnn::profiling::ProfilingService &profilingService)
 
 ~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
 ProfilingService (Optional< IReportStructure &> reportStructure=EmptyOptional())
 
 ~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)
 
void NotifyBackendsForTimelineReporting () override
 
const ICounterDirectoryGetCounterDirectory () const
 
ICounterRegistryGetCounterRegistry ()
 
ProfilingState GetCurrentState () const
 
bool IsCounterRegistered (uint16_t counterUid) const override
 
uint32_t GetAbsoluteCounterValue (uint16_t counterUid) const override
 
uint32_t GetDeltaCounterValue (uint16_t counterUid) 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
 
void ResetGuidGenerator ()
 
bool IsTimelineReportingEnabled ()
 
void AddLocalPacketHandler (ILocalPacketHandlerSharedPtr localPacketHandler)
 
void NotifyProfilingServiceActive () override
 
void WaitForProfilingServiceActivation (unsigned int timeout) override
 
- 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 ()
 
- Public Member Functions inherited from IProfilingServiceStatus
virtual ~IProfilingServiceStatus ()
 
- Public Member Functions inherited from INotifyBackends
virtual ~INotifyBackends ()
 

Additional Inherited Members

- Static Public Member Functions inherited from ProfilingService
static ProfilingDynamicGuid GetNextGuid ()
 
static ProfilingStaticGuid GetStaticId (const std::string &str)
 
- Protected Member Functions inherited from 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 204 of file ProfilingTests.hpp.

Member Typedef Documentation

◆ MockProfilingConnectionFactoryPtr

Definition at line 207 of file ProfilingTests.hpp.

Constructor & Destructor Documentation

◆ SwapProfilingConnectionFactoryHelper()

Definition at line 209 of file ProfilingTests.hpp.

210  : ProfilingService()
211  , m_ProfilingService(profilingService)
212  , m_MockProfilingConnectionFactory(new MockProfilingConnectionFactory())
213  , m_BackupProfilingConnectionFactory(nullptr)
214 
215  {
216  BOOST_CHECK(m_MockProfilingConnectionFactory);
217  SwapProfilingConnectionFactory(m_ProfilingService,
218  m_MockProfilingConnectionFactory.get(),
219  m_BackupProfilingConnectionFactory);
220  BOOST_CHECK(m_BackupProfilingConnectionFactory);
221  }
void SwapProfilingConnectionFactory(ProfilingService &instance, IProfilingConnectionFactory *other, IProfilingConnectionFactory *&backup)
ProfilingService(Optional< IReportStructure &> reportStructure=EmptyOptional())

◆ ~SwapProfilingConnectionFactoryHelper()

Definition at line 222 of file ProfilingTests.hpp.

223  {
224  BOOST_CHECK(m_BackupProfilingConnectionFactory);
225  IProfilingConnectionFactory* temp = nullptr;
226  SwapProfilingConnectionFactory(m_ProfilingService,
227  m_BackupProfilingConnectionFactory,
228  temp);
229  }
void SwapProfilingConnectionFactory(ProfilingService &instance, IProfilingConnectionFactory *other, IProfilingConnectionFactory *&backup)

Member Function Documentation

◆ ForceTransitionToState()

void ForceTransitionToState ( ProfilingState  newState)
inline

Definition at line 237 of file ProfilingTests.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

238  {
239  TransitionToState(m_ProfilingService, newState);
240  }
void TransitionToState(ProfilingService &instance, ProfilingState newState)

◆ GetMockProfilingConnection()

MockProfilingConnection* GetMockProfilingConnection ( )
inline

Definition at line 231 of file ProfilingTests.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

232  {
233  IProfilingConnection* profilingConnection = GetProfilingConnection(m_ProfilingService);
234  return PolymorphicDowncast<MockProfilingConnection*>(profilingConnection);
235  }
IProfilingConnection * GetProfilingConnection(ProfilingService &instance)

◆ WaitForPacketsSent()

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

Definition at line 242 of file ProfilingTests.hpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

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

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