ArmNN
 20.05
SwapProfilingConnectionFactoryHelper Class Reference

#include <ProfilingTests.hpp>

Inheritance diagram for SwapProfilingConnectionFactoryHelper:
ProfilingService IReadWriteCounterValues IProfilingService INotifyBackends 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 > >
 
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
 
bool IsTimelineReportingEnabled ()
 
void AddLocalPacketHandler (ILocalPacketHandlerSharedPtr localPacketHandler)
 
- 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 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 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().

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

◆ ~SwapProfilingConnectionFactoryHelper()

Definition at line 220 of file ProfilingTests.hpp.

References BOOST_CHECK().

221  {
222  BOOST_CHECK(m_BackupProfilingConnectionFactory);
223  IProfilingConnectionFactory* temp = nullptr;
224  SwapProfilingConnectionFactory(m_ProfilingService,
225  m_BackupProfilingConnectionFactory,
226  temp);
227  }
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 235 of file ProfilingTests.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

236  {
237  TransitionToState(m_ProfilingService, newState);
238  }
void TransitionToState(ProfilingService &instance, ProfilingState newState)

◆ GetMockProfilingConnection()

MockProfilingConnection* GetMockProfilingConnection ( )
inline

Definition at line 229 of file ProfilingTests.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

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

◆ WaitForPacketsSent()

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

Definition at line 240 of file ProfilingTests.hpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

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

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