ArmNN
 20.05
armnn::profiling Namespace Reference

Classes

class  ActivateTimelineReportingCommandHandler
 
class  BackendProfiling
 
class  BufferExhaustion
 
class  BufferManager
 
class  CaptureData
 
class  Category
 
class  CommandHandler
 
class  CommandHandlerFunctor
 
struct  CommandHandlerHash
 
class  CommandHandlerKey
 
class  CommandHandlerRegistry
 
class  ConnectionAcknowledgedCommandHandler
 
class  Counter
 
class  CounterDirectory
 
struct  CounterDirectoryEventRecord
 
class  CounterIdMap
 
class  CounterSet
 
struct  CounterStatus
 
struct  CounterValue
 
class  DeactivateTimelineReportingCommandHandler
 
class  Device
 
class  DirectoryCaptureCommandHandler
 
class  Entity
 
class  FileOnlyProfilingConnection
 
class  Holder
 
class  IBackendProfiling
 
class  IBackendProfilingContext
 
class  IBufferManager
 
class  IConsumer
 
class  ICounterDirectory
 
class  ICounterMappings
 
class  ICounterRegistry
 
class  ILocalPacketHandler
 
class  INotifyBackends
 
class  IPacketBuffer
 
class  IPeriodicCounterCapture
 
class  IProfilingConnection
 
class  IProfilingConnectionFactory
 
class  IProfilingGuidGenerator
 
class  IProfilingService
 
class  IReadCounterValues
 
class  IReadOnlyPacketBuffer
 
class  IReadWriteCounterValues
 
class  IRegisterBackendCounters
 
class  IRegisterCounterMapping
 
class  IReportStructure
 
class  ISendCounterPacket
 
class  ISendThread
 
class  ISendTimelinePacket
 
class  IWriteCounterValues
 
class  LabelsAndEventClasses
 
struct  LogLevelSwapper
 
class  MockBufferManager
 
class  MockCounterDirectory
 
class  MockPacketBuffer
 
class  MockProfilingConnection
 
class  MockProfilingConnectionFactory
 
class  MockProfilingService
 
class  MockSendCounterPacket
 
class  MockStreamCounterBuffer
 
struct  ModelRelationship
 
class  NullProfilingConnection
 
class  PacketBuffer
 
class  PacketKey
 
class  PacketVersionResolver
 
class  PeriodicCounterCapture
 
class  PeriodicCounterSelectionCommandHandler
 
class  PerJobCounterSelectionCommandHandler
 
class  PrintPacketHeaderHandler
 
class  ProfilingConnectionDumpToFileDecorator
 
class  ProfilingConnectionFactory
 
struct  ProfilingDynamicGuid
 Strongly typed guids to distinguish between those generated at runtime, and those that are statically defined. More...
 
class  ProfilingGuid
 
class  ProfilingGuidGenerator
 
class  ProfilingService
 
class  ProfilingServiceRuntimeHelper
 
class  ProfilingStateMachine
 
struct  ProfilingStaticGuid
 
class  RegisterBackendCounters
 
class  RequestCounterDirectoryCommandHandler
 
class  SendCounterPacket
 
class  SendCounterPacketTest
 
class  SendThread
 
class  SendTimelinePacket
 
class  SocketProfilingConnection
 
struct  StreamRedirector
 
class  SwapProfilingConnectionFactoryHelper
 
struct  SwTraceCharPolicy
 
struct  SwTraceHeader
 
struct  SwTraceMessage
 
struct  SwTraceNameCharPolicy
 
struct  SwTraceTypeCharPolicy
 
class  TestFunctorA
 
class  TestFunctorB
 
class  TestFunctorC
 
class  TestProfilingConnectionArmnnError
 
class  TestProfilingConnectionBadAckPacket
 
class  TestProfilingConnectionBase
 
class  TestProfilingConnectionTimeoutError
 
class  TestTimelinePacketHandler
 
class  TimelineMessageDecoder
 
class  TimelineModel
 
class  TimelinePacketWriterFactory
 
class  TimelineUtilityMethods
 
struct  Timestamp
 
class  Version
 

Typedefs

using IBackendProfilingContextUniquePtr = std::unique_ptr< IBackendProfilingContext >
 
using ILocalPacketHandlerPtr = std::unique_ptr< ILocalPacketHandler >
 
using ILocalPacketHandlerSharedPtr = std::shared_ptr< ILocalPacketHandler >
 
using CategoryPtr = std::unique_ptr< Category >
 
using DevicePtr = std::unique_ptr< Device >
 
using CounterSetPtr = std::unique_ptr< CounterSet >
 
using CounterPtr = std::shared_ptr< Counter >
 
using Categories = std::unordered_set< CategoryPtr >
 
using Devices = std::unordered_map< uint16_t, DevicePtr >
 
using CounterSets = std::unordered_map< uint16_t, CounterSetPtr >
 
using Counters = std::unordered_map< uint16_t, CounterPtr >
 
using CategoriesIt = Categories::const_iterator
 
using DevicesIt = Devices::const_iterator
 
using CounterSetsIt = CounterSets::const_iterator
 
using CountersIt = Counters::const_iterator
 
using IPacketBufferPtr = std::unique_ptr< IPacketBuffer >
 
using LabelMap = std::map< uint64_t, ITimelineDecoder::Label >
 
using Attribute = std::pair< std::string, std::string >
 
using Attributes = std::map< std::string, Attribute >
 
using Entities = std::map< uint64_t, Entity >
 
using Relationships = std::map< uint64_t, ModelRelationship >
 

Enumerations

enum  ProfilingRelationshipType { RetentionLink, ExecutionLink, DataLink, LabelLink }
 
enum  TargetEndianness { BeWire, LeWire }
 
enum  PackageActivity { StreamMetaData, CounterDirectory, Unknown }
 
enum  ProfilingState { Uninitialised, NotConnected, WaitingForAck, Active }
 
enum  TimelinePacketStatus { Ok, Error, BufferExhaustion }
 

Functions

constexpr uint32_t EncodeVersion (uint32_t major, uint32_t minor, uint32_t patch)
 
std::ostream & operator<< (std::ostream &os, const Version &version)
 
constexpr char const * GetProfilingStateName (ProfilingState state)
 
uint16_t GetNextUid (bool peekOnly)
 
std::vector< uint16_t > GetNextCounterUids (uint16_t firstUid, uint16_t cores)
 
void WriteBytes (const IPacketBufferPtr &packetBuffer, unsigned int offset, const void *value, unsigned int valueSize)
 
uint32_t ConstructHeader (uint32_t packetFamily, uint32_t packetId)
 
void WriteUint64 (const std::unique_ptr< IPacketBuffer > &packetBuffer, unsigned int offset, uint64_t value)
 
void WriteUint32 (const IPacketBufferPtr &packetBuffer, unsigned int offset, uint32_t value)
 
void WriteUint16 (const IPacketBufferPtr &packetBuffer, unsigned int offset, uint16_t value)
 
void WriteUint8 (const IPacketBufferPtr &packetBuffer, unsigned int offset, uint8_t value)
 
void WriteBytes (unsigned char *buffer, unsigned int offset, const void *value, unsigned int valueSize)
 
void WriteUint64 (unsigned char *buffer, unsigned int offset, uint64_t value)
 
void WriteUint32 (unsigned char *buffer, unsigned int offset, uint32_t value)
 
void WriteUint16 (unsigned char *buffer, unsigned int offset, uint16_t value)
 
void WriteUint8 (unsigned char *buffer, unsigned int offset, uint8_t value)
 
void ReadBytes (const IPacketBufferPtr &packetBuffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
 
uint64_t ReadUint64 (const IPacketBufferPtr &packetBuffer, unsigned int offset)
 
uint32_t ReadUint32 (const IPacketBufferPtr &packetBuffer, unsigned int offset)
 
uint16_t ReadUint16 (const IPacketBufferPtr &packetBuffer, unsigned int offset)
 
uint8_t ReadUint8 (const IPacketBufferPtr &packetBuffer, unsigned int offset)
 
void ReadBytes (const unsigned char *buffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
 
uint64_t ReadUint64 (const unsigned char *buffer, unsigned int offset)
 
uint32_t ReadUint32 (const unsigned char *buffer, unsigned int offset)
 
uint16_t ReadUint16 (const unsigned char *buffer, unsigned int offset)
 
uint8_t ReadUint8 (const unsigned char *buffer, unsigned int offset)
 
std::string GetSoftwareInfo ()
 
std::string GetHardwareVersion ()
 
std::string GetSoftwareVersion ()
 
std::string GetProcessName ()
 
uint32_t CalculateSizeOfPaddedSwString (const std::string &str)
 
SwTraceMessage ReadSwTraceMessage (const unsigned char *packetBuffer, unsigned int &offset)
 
std::pair< uint32_t, uint32_t > CreateTimelinePacketHeader (uint32_t packetFamily, uint32_t packetClass, uint32_t packetType, uint32_t streamId, uint32_t sequenceNumbered, uint32_t dataLength)
 Creates a timeline packet header. More...
 
std::pair< uint32_t, uint32_t > CreateTimelineMessagePacketHeader (unsigned int dataLength)
 Creates a packet header for the timeline messages: More...
 
TimelinePacketStatus WriteTimelineLabelBinaryPacket (uint64_t profilingGuid, const std::string &label, unsigned char *buffer, unsigned int remainingBufferSize, unsigned int &numberOfBytesWritten)
 
TimelinePacketStatus WriteTimelineEntityBinary (uint64_t profilingGuid, unsigned char *buffer, unsigned int remainingBufferSize, unsigned int &numberOfBytesWritten)
 
TimelinePacketStatus WriteTimelineRelationshipBinary (ProfilingRelationshipType relationshipType, uint64_t relationshipGuid, uint64_t headGuid, uint64_t tailGuid, unsigned char *buffer, unsigned int remainingBufferSize, unsigned int &numberOfBytesWritten)
 
TimelinePacketStatus WriteTimelineMessageDirectoryPackage (unsigned char *buffer, unsigned int remainingBufferSize, unsigned int &numberOfBytesWritten)
 
TimelinePacketStatus WriteTimelineEventClassBinary (uint64_t profilingGuid, unsigned char *buffer, unsigned int remainingBufferSize, unsigned int &numberOfBytesWritten)
 
TimelinePacketStatus WriteTimelineEventBinary (uint64_t timestamp, std::thread::id threadId, uint64_t profilingGuid, unsigned char *buffer, unsigned int remainingBufferSize, unsigned int &numberOfBytesWritten)
 
std::string CentreAlignFormatting (const std::string &stringToPass, const int spacingWidth)
 
void PrintDeviceDetails (const std::pair< const unsigned short, std::unique_ptr< Device >> &devicePair)
 
void PrintCounterSetDetails (const std::pair< const unsigned short, std::unique_ptr< CounterSet >> &counterSetPair)
 
void PrintCounterDetails (std::shared_ptr< Counter > &counter)
 
void PrintCategoryDetails (const std::unique_ptr< Category > &category, std::unordered_map< unsigned short, std::shared_ptr< Counter >> counterMap)
 
void PrintCounterDirectory (ICounterDirectory &counterDirectory)
 
uint64_t GetTimestamp ()
 
Packet ReceivePacket (const unsigned char *buffer, uint32_t length)
 
template<typename SwTracePolicy >
bool IsValidSwTraceString (const std::string &s)
 
template<typename SwTracePolicy >
bool StringToSwTraceString (const std::string &s, std::vector< uint32_t > &outputBuffer)
 
template<typename SwTracePolicy , typename SwTraceBuffer = std::vector<uint32_t>>
bool ConvertDirectoryComponent (const std::string &directoryComponent, SwTraceBuffer &swTraceBuffer)
 
void WriteBytes (const IPacketBuffer &packetBuffer, unsigned int offset, const void *value, unsigned int valueSize)
 
void WriteUint64 (const IPacketBufferPtr &packetBuffer, unsigned int offset, uint64_t value)
 

Variables

uint32_t uint16_t_size = sizeof(uint16_t)
 
uint32_t uint32_t_size = sizeof(uint32_t)
 
constexpr unsigned int ThreadIdSize = sizeof(std::thread::id)
 

Typedef Documentation

◆ Attribute

using Attribute = std::pair<std::string, std::string>

Definition at line 19 of file TimelineModel.hpp.

◆ Attributes

using Attributes = std::map<std::string, Attribute>

Definition at line 20 of file TimelineModel.hpp.

◆ Categories

using Categories = std::unordered_set<CategoryPtr>

Definition at line 37 of file ICounterDirectory.hpp.

◆ CategoriesIt

using CategoriesIt = Categories::const_iterator

Definition at line 43 of file ICounterDirectory.hpp.

◆ CategoryPtr

using CategoryPtr = std::unique_ptr<Category>

Definition at line 31 of file ICounterDirectory.hpp.

◆ CounterPtr

using CounterPtr = std::shared_ptr<Counter>

Definition at line 34 of file ICounterDirectory.hpp.

◆ Counters

using Counters = std::unordered_map<uint16_t, CounterPtr>

Definition at line 40 of file ICounterDirectory.hpp.

◆ CounterSetPtr

using CounterSetPtr = std::unique_ptr<CounterSet>

Definition at line 33 of file ICounterDirectory.hpp.

◆ CounterSets

using CounterSets = std::unordered_map<uint16_t, CounterSetPtr>

Definition at line 39 of file ICounterDirectory.hpp.

◆ CounterSetsIt

using CounterSetsIt = CounterSets::const_iterator

Definition at line 45 of file ICounterDirectory.hpp.

◆ CountersIt

using CountersIt = Counters::const_iterator

Definition at line 46 of file ICounterDirectory.hpp.

◆ DevicePtr

using DevicePtr = std::unique_ptr<Device>

Definition at line 32 of file ICounterDirectory.hpp.

◆ Devices

using Devices = std::unordered_map<uint16_t, DevicePtr>

Definition at line 38 of file ICounterDirectory.hpp.

◆ DevicesIt

using DevicesIt = Devices::const_iterator

Definition at line 44 of file ICounterDirectory.hpp.

◆ Entities

using Entities = std::map<uint64_t, Entity>

Definition at line 43 of file TimelineModel.hpp.

◆ IBackendProfilingContextUniquePtr

Definition at line 28 of file IBackendProfilingContext.hpp.

◆ ILocalPacketHandlerPtr

using ILocalPacketHandlerPtr = std::unique_ptr<ILocalPacketHandler>

Definition at line 43 of file ILocalPacketHandler.hpp.

◆ ILocalPacketHandlerSharedPtr

Definition at line 44 of file ILocalPacketHandler.hpp.

◆ IPacketBufferPtr

using IPacketBufferPtr = std::unique_ptr<IPacketBuffer>

Definition at line 40 of file IPacketBuffer.hpp.

◆ LabelMap

using LabelMap = std::map<uint64_t, ITimelineDecoder::Label>

Definition at line 18 of file TimelineModel.hpp.

◆ Relationships

using Relationships = std::map<uint64_t, ModelRelationship>

Definition at line 50 of file TimelineModel.hpp.

Enumeration Type Documentation

◆ PackageActivity

◆ ProfilingRelationshipType

Enumerator
RetentionLink 
ExecutionLink 

Head retains(parents) Tail.

DataLink 

Head execution start depends on Tail execution completion.

LabelLink 

Head uses data of Tail.

Head uses label Tail (Tail MUST be a guid of a label).

Definition at line 19 of file ISendTimelinePacket.hpp.

20 {
21  RetentionLink, /// Head retains(parents) Tail
22  ExecutionLink, /// Head execution start depends on Tail execution completion
23  DataLink, /// Head uses data of Tail
24  LabelLink /// Head uses label Tail (Tail MUST be a guid of a label).
25 };
Head execution start depends on Tail execution completion.

◆ ProfilingState

◆ TargetEndianness

enum TargetEndianness
strong
Enumerator
BeWire 
LeWire 

Definition at line 28 of file FileOnlyProfilingConnection.hpp.

◆ TimelinePacketStatus

enum TimelinePacketStatus
strong
Enumerator
Ok 
Error 
BufferExhaustion 

Definition at line 206 of file ProfilingUtils.hpp.

Function Documentation

◆ CalculateSizeOfPaddedSwString()

uint32_t CalculateSizeOfPaddedSwString ( const std::string &  str)

Definition at line 302 of file ProfilingUtils.cpp.

References armnn::numeric_cast(), and uint32_t_size.

Referenced by ReadSwTraceMessage().

303 {
304  std::vector<uint32_t> swTraceString;
305  StringToSwTraceString<SwTraceCharPolicy>(str, swTraceString);
306  unsigned int uint32_t_size = sizeof(uint32_t);
307  uint32_t size = (boost::numeric_cast<uint32_t>(swTraceString.size()) - 1) * uint32_t_size;
308  return size;
309 }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33

◆ CentreAlignFormatting()

std::string CentreAlignFormatting ( const std::string &  stringToPass,
const int  spacingWidth 
)

Definition at line 848 of file ProfilingUtils.cpp.

Referenced by PeriodicCounterCaptureCommandHandler::operator()(), TimelineDecoder::print(), CategoryRecord::print(), PrintCategoryDetails(), EventRecord::printContents(), CounterSetRecord::printContents(), DeviceRecord::printContents(), PrintCounterDetails(), PrintCounterDirectory(), PrintCounterSetDetails(), PrintDeviceDetails(), EventRecord::printHeader(), CounterSetRecord::printHeader(), and DeviceRecord::printHeader().

849 {
850  std::stringstream outputStream, centrePadding;
851  int padding = spacingWidth - static_cast<int>(stringToPass.size());
852 
853  for (int i = 0; i < padding / 2; ++i)
854  {
855  centrePadding << " ";
856  }
857 
858  outputStream << centrePadding.str() << stringToPass << centrePadding.str();
859 
860  if (padding > 0 && padding %2 != 0)
861  {
862  outputStream << " ";
863  }
864 
865  return outputStream.str();
866 }

◆ ConstructHeader()

uint32_t ConstructHeader ( uint32_t  packetFamily,
uint32_t  packetId 
)

Definition at line 98 of file ProfilingUtils.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and ConvertDirectoryComponent().

100 {
101  return (( packetFamily & 0x0000003F ) << 26 )|
102  (( packetId & 0x000003FF ) << 16 );
103 }

◆ ConvertDirectoryComponent()

bool armnn::profiling::ConvertDirectoryComponent ( const std::string &  directoryComponent,
SwTraceBuffer &  swTraceBuffer 
)

Definition at line 130 of file ProfilingUtils.hpp.

References ConstructHeader(), CreateTimelinePacketHeader(), GetHardwareVersion(), GetNextCounterUids(), GetNextUid(), GetProcessName(), GetSoftwareInfo(), GetSoftwareVersion(), ReadBytes(), ReadUint16(), ReadUint32(), ReadUint64(), ReadUint8(), WriteBytes(), WriteUint16(), WriteUint32(), WriteUint64(), and WriteUint8().

131 {
132  // Convert the directory component using the given policy
133  SwTraceBuffer tempSwTraceBuffer;
134  bool result = StringToSwTraceString<SwTracePolicy>(directoryComponent, tempSwTraceBuffer);
135  if (!result)
136  {
137  return false;
138  }
139 
140  swTraceBuffer.insert(swTraceBuffer.end(), tempSwTraceBuffer.begin(), tempSwTraceBuffer.end());
141 
142  return true;
143 }

◆ CreateTimelineMessagePacketHeader()

std::pair<uint32_t, uint32_t> armnn::profiling::CreateTimelineMessagePacketHeader ( unsigned int  dataLength)

Creates a packet header for the timeline messages:

  • declareLabel
  • declareEntity
  • declareEventClass
  • declareRelationship
  • declareEvent
Parameters
dataLengthThe length of the message body in bytes
Returns
Pair of uint32_t containing word0 and word1 of the header

Definition at line 436 of file ProfilingUtils.cpp.

References CreateTimelinePacketHeader().

437 {
438  return CreateTimelinePacketHeader(1, // Packet family
439  0, // Packet class
440  1, // Packet type
441  0, // Stream id
442  0, // Sequence number
443  dataLength); // Data length
444 }
std::pair< uint32_t, uint32_t > CreateTimelinePacketHeader(uint32_t packetFamily, uint32_t packetClass, uint32_t packetType, uint32_t streamId, uint32_t sequenceNumbered, uint32_t dataLength)
Creates a timeline packet header.

◆ CreateTimelinePacketHeader()

std::pair< uint32_t, uint32_t > CreateTimelinePacketHeader ( uint32_t  packetFamily,
uint32_t  packetClass,
uint32_t  packetType,
uint32_t  streamId,
uint32_t  sequenceNumbered,
uint32_t  dataLength 
)

Creates a timeline packet header.

packetFamiliy Timeline Packet Family packetClass Timeline Packet Class packetType Timeline Packet Type streamId Stream identifier seqeunceNumbered When non-zero the 4 bytes following the header is a u32 sequence number dataLength Unsigned 24-bit integer. Length of data, in bytes. Zero is permitted

Returns
Pair of uint32_t containing word0 and word1 of the header

Definition at line 396 of file ProfilingUtils.cpp.

Referenced by SendTimelinePacket::Commit(), ConvertDirectoryComponent(), CreateTimelineMessagePacketHeader(), and WriteTimelineMessageDirectoryPackage().

402 {
403  // Packet header word 0:
404  // 26:31 [6] packet_family: timeline Packet Family, value 0b000001
405  // 19:25 [7] packet_class: packet class
406  // 16:18 [3] packet_type: packet type
407  // 8:15 [8] reserved: all zeros
408  // 0:7 [8] stream_id: stream identifier
409  uint32_t packetHeaderWord0 = ((packetFamily & 0x0000003F) << 26) |
410  ((packetClass & 0x0000007F) << 19) |
411  ((packetType & 0x00000007) << 16) |
412  ((streamId & 0x00000007) << 0);
413 
414  // Packet header word 1:
415  // 25:31 [7] reserved: all zeros
416  // 24 [1] sequence_numbered: when non-zero the 4 bytes following the header is a u32 sequence number
417  // 0:23 [24] data_length: unsigned 24-bit integer. Length of data, in bytes. Zero is permitted
418  uint32_t packetHeaderWord1 = ((sequenceNumbered & 0x00000001) << 24) |
419  ((dataLength & 0x00FFFFFF) << 0);
420 
421  return std::make_pair(packetHeaderWord0, packetHeaderWord1);
422 }

◆ EncodeVersion()

constexpr uint32_t armnn::profiling::EncodeVersion ( uint32_t  major,
uint32_t  minor,
uint32_t  patch 
)
inline

Definition at line 18 of file EncodeVersion.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), Version::GetEncodedValue(), and SendCounterPacket::SendStreamMetaDataPacket().

19 {
20  return (major << 22) | (minor << 12) | patch;
21 }

◆ GetHardwareVersion()

std::string GetHardwareVersion ( )

Definition at line 280 of file ProfilingUtils.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), ConvertDirectoryComponent(), GetStreamMetaDataPacketSize(), and SendCounterPacket::SendStreamMetaDataPacket().

281 {
282  return std::string();
283 }

◆ GetNextCounterUids()

std::vector< uint16_t > GetNextCounterUids ( uint16_t  firstUid,
uint16_t  cores 
)

Definition at line 76 of file ProfilingUtils.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), ConvertDirectoryComponent(), CounterDirectory::RegisterCounter(), and MockCounterDirectory::RegisterCounter().

77 {
78  // Check that it is possible to generate the next counter UID without causing an overflow (throws in case of error)
79  ThrowIfCantGenerateNextUid(firstUid, cores);
80 
81  // Get the next counter UIDs
82  size_t counterUidsSize = cores == 0 ? 1 : cores;
83  std::vector<uint16_t> counterUids(counterUidsSize, 0);
84  for (size_t i = 0; i < counterUidsSize; i++)
85  {
86  counterUids[i] = firstUid++;
87  }
88  return counterUids;
89 }

◆ GetNextUid()

uint16_t GetNextUid ( bool  peekOnly)

Definition at line 56 of file ProfilingUtils.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), ConvertDirectoryComponent(), CounterDirectory::RegisterCounterSet(), MockCounterDirectory::RegisterCounterSet(), CounterDirectory::RegisterDevice(), and MockCounterDirectory::RegisterDevice().

57 {
58  // The UID used for profiling objects and events. The first valid UID is 1, as 0 is a reserved value
59  static uint16_t uid = 1;
60 
61  // Check that it is possible to generate the next UID without causing an overflow (throws in case of error)
62  ThrowIfCantGenerateNextUid(uid);
63 
64  if (peekOnly)
65  {
66  // Peek only
67  return uid;
68  }
69  else
70  {
71  // Get the next UID
72  return uid++;
73  }
74 }

◆ GetProcessName()

std::string GetProcessName ( )

Definition at line 291 of file ProfilingUtils.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), ConvertDirectoryComponent(), GetStreamMetaDataPacketSize(), and SendCounterPacket::SendStreamMetaDataPacket().

292 {
293  std::ifstream comm("/proc/self/comm");
294  std::string name;
295  getline(comm, name);
296  return name;
297 }

◆ GetProfilingStateName()

constexpr char const* armnn::profiling::GetProfilingStateName ( ProfilingState  state)

Definition at line 59 of file ProfilingStateMachine.hpp.

References Active, NotConnected, Uninitialised, and WaitingForAck.

Referenced by PerJobCounterSelectionCommandHandler::operator()(), DeactivateTimelineReportingCommandHandler::operator()(), RequestCounterDirectoryCommandHandler::operator()(), ActivateTimelineReportingCommandHandler::operator()(), ConnectionAcknowledgedCommandHandler::operator()(), and PeriodicCounterSelectionCommandHandler::operator()().

60 {
61  switch (state)
62  {
63  case ProfilingState::Uninitialised: return "Uninitialised";
64  case ProfilingState::NotConnected: return "NotConnected";
65  case ProfilingState::WaitingForAck: return "WaitingForAck";
66  case ProfilingState::Active: return "Active";
67  default: return "Unknown";
68  }
69 }

◆ GetSoftwareInfo()

std::string GetSoftwareInfo ( )

Definition at line 275 of file ProfilingUtils.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), ConvertDirectoryComponent(), GetStreamMetaDataPacketSize(), and SendCounterPacket::SendStreamMetaDataPacket().

276 {
277  return std::string("ArmNN");
278 }

◆ GetSoftwareVersion()

std::string GetSoftwareVersion ( )

Definition at line 285 of file ProfilingUtils.cpp.

References ARMNN_MAJOR_VERSION, and ARMNN_MINOR_VERSION.

Referenced by BOOST_AUTO_TEST_CASE(), ConvertDirectoryComponent(), GetStreamMetaDataPacketSize(), and SendCounterPacket::SendStreamMetaDataPacket().

286 {
287  std::string result = "Armnn " + std::to_string(ARMNN_MAJOR_VERSION) + "." + std::to_string(ARMNN_MINOR_VERSION);
288  return result;
289 }
#define ARMNN_MAJOR_VERSION
Definition: Version.hpp:13
#define ARMNN_MINOR_VERSION
Definition: Version.hpp:14

◆ GetTimestamp()

uint64_t GetTimestamp ( )

Definition at line 1040 of file ProfilingUtils.cpp.

Referenced by TimelineUtilityMethods::RecordEvent(), and PeriodicCounterCapture::Stop().

1041 {
1042 #if USE_CLOCK_MONOTONIC_RAW
1043  using clock = MonotonicClockRaw;
1044 #else
1045  using clock = std::chrono::steady_clock;
1046 #endif
1047 
1048  // Take a timestamp
1049  auto timestamp = std::chrono::duration_cast<std::chrono::nanoseconds>(clock::now().time_since_epoch());
1050 
1051  return static_cast<uint64_t>(timestamp.count());
1052 }

◆ IsValidSwTraceString()

bool armnn::profiling::IsValidSwTraceString ( const std::string &  s)

Definition at line 91 of file ProfilingUtils.hpp.

92 {
93  // Check that all the characters in the given string conform to the given policy
94  return std::all_of(s.begin(), s.end(), [](unsigned char c) { return SwTracePolicy::IsValidChar(c); });
95 }

◆ operator<<()

std::ostream& armnn::profiling::operator<< ( std::ostream &  os,
const Version version 
)
inline

Definition at line 75 of file EncodeVersion.hpp.

References Version::ToString().

76 {
77  os << version.ToString();
78  return os;
79 }

◆ PrintCategoryDetails()

void armnn::profiling::PrintCategoryDetails ( const std::unique_ptr< Category > &  category,
std::unordered_map< unsigned short, std::shared_ptr< Counter >>  counterMap 
)

Definition at line 930 of file ProfilingUtils.cpp.

References CentreAlignFormatting(), and PrintCounterDetails().

Referenced by PrintCounterDirectory().

932 {
933  std::string categoryBody;
934  std::string categoryHeader;
935 
936  categoryHeader.append(CentreAlignFormatting("Name", 20));
937  categoryHeader.append(" | ");
938  categoryHeader.append(CentreAlignFormatting("Event Count", 14));
939  categoryHeader.append("\n");
940 
941  categoryBody.append(CentreAlignFormatting(category->m_Name, 20));
942  categoryBody.append(" | ");
943  categoryBody.append(CentreAlignFormatting(std::to_string(category->m_Counters.size()), 14));
944 
945  std::cout << "\n" << "\n";
946  std::cout << CentreAlignFormatting("CATEGORY", static_cast<int>(categoryHeader.size()));
947  std::cout << "\n";
948  std::cout << std::string(categoryHeader.size(), '=') << "\n";
949 
950  std::cout << categoryHeader;
951 
952  std::cout << std::string(categoryBody.size(), '-') << "\n";
953 
954  std::cout << categoryBody;
955 
956  std::string counterHeader;
957 
958  counterHeader.append(CentreAlignFormatting("Counter Name", 20));
959  counterHeader.append(" | ");
960  counterHeader.append(CentreAlignFormatting("Description", 50));
961  counterHeader.append(" | ");
962  counterHeader.append(CentreAlignFormatting("Units", 14));
963  counterHeader.append(" | ");
964  counterHeader.append(CentreAlignFormatting("UID", 6));
965  counterHeader.append(" | ");
966  counterHeader.append(CentreAlignFormatting("Max UID", 10));
967  counterHeader.append(" | ");
968  counterHeader.append(CentreAlignFormatting("Class", 8));
969  counterHeader.append(" | ");
970  counterHeader.append(CentreAlignFormatting("Interpolation", 14));
971  counterHeader.append(" | ");
972  counterHeader.append(CentreAlignFormatting("Multiplier", 20));
973  counterHeader.append(" | ");
974  counterHeader.append(CentreAlignFormatting("Counter set UID", 16));
975  counterHeader.append(" | ");
976  counterHeader.append(CentreAlignFormatting("Device UID", 14));
977  counterHeader.append("\n");
978 
979  std::cout << "\n" << "\n";
980  std::cout << CentreAlignFormatting("EVENTS IN CATEGORY: " + category->m_Name,
981  static_cast<int>(counterHeader.size()));
982  std::cout << "\n";
983  std::cout << std::string(counterHeader.size(), '=') << "\n";
984  std::cout << counterHeader;
985  for (auto& it: category->m_Counters) {
986  auto search = counterMap.find(it);
987  if(search != counterMap.end()) {
988  PrintCounterDetails(search->second);
989  }
990  }
991 }
void PrintCounterDetails(std::shared_ptr< Counter > &counter)
std::string CentreAlignFormatting(const std::string &stringToPass, const int spacingWidth)

◆ PrintCounterDetails()

void armnn::profiling::PrintCounterDetails ( std::shared_ptr< Counter > &  counter)

Definition at line 899 of file ProfilingUtils.cpp.

References CentreAlignFormatting().

Referenced by PrintCategoryDetails().

900 {
901  std::string body;
902 
903  body.append(CentreAlignFormatting(counter->m_Name, 20));
904  body.append(" | ");
905  body.append(CentreAlignFormatting(counter->m_Description, 50));
906  body.append(" | ");
907  body.append(CentreAlignFormatting(counter->m_Units, 14));
908  body.append(" | ");
909  body.append(CentreAlignFormatting(std::to_string(counter->m_Uid), 6));
910  body.append(" | ");
911  body.append(CentreAlignFormatting(std::to_string(counter->m_MaxCounterUid), 10));
912  body.append(" | ");
913  body.append(CentreAlignFormatting(std::to_string(counter->m_Class), 8));
914  body.append(" | ");
915  body.append(CentreAlignFormatting(std::to_string(counter->m_Interpolation), 14));
916  body.append(" | ");
917  body.append(CentreAlignFormatting(std::to_string(counter->m_Multiplier), 20));
918  body.append(" | ");
919  body.append(CentreAlignFormatting(std::to_string(counter->m_CounterSetUid), 16));
920  body.append(" | ");
921  body.append(CentreAlignFormatting(std::to_string(counter->m_DeviceUid), 14));
922 
923  body.append("\n");
924 
925  std::cout << std::string(body.size(), '-') << "\n";
926 
927  std::cout << body;
928 }
std::string CentreAlignFormatting(const std::string &stringToPass, const int spacingWidth)

◆ PrintCounterDirectory()

void PrintCounterDirectory ( ICounterDirectory counterDirectory)

Definition at line 993 of file ProfilingUtils.cpp.

References CentreAlignFormatting(), ICounterDirectory::GetCategories(), ICounterDirectory::GetCounters(), ICounterDirectory::GetCounterSets(), ICounterDirectory::GetDevices(), PrintCategoryDetails(), PrintCounterSetDetails(), and PrintDeviceDetails().

Referenced by DirectoryCaptureCommandHandler::operator()().

994 {
995  std::string devicesHeader;
996 
997  devicesHeader.append(CentreAlignFormatting("Device name", 20));
998  devicesHeader.append(" | ");
999  devicesHeader.append(CentreAlignFormatting("UID", 13));
1000  devicesHeader.append(" | ");
1001  devicesHeader.append(CentreAlignFormatting("Cores", 10));
1002  devicesHeader.append("\n");
1003 
1004  std::cout << "\n" << "\n";
1005  std::cout << CentreAlignFormatting("DEVICES", static_cast<int>(devicesHeader.size()));
1006  std::cout << "\n";
1007  std::cout << std::string(devicesHeader.size(), '=') << "\n";
1008  std::cout << devicesHeader;
1009  for (auto& it: counterDirectory.GetDevices()) {
1010  PrintDeviceDetails(it);
1011  }
1012 
1013  std::string counterSetHeader;
1014 
1015  counterSetHeader.append(CentreAlignFormatting("Counter set name", 20));
1016  counterSetHeader.append(" | ");
1017  counterSetHeader.append(CentreAlignFormatting("UID", 13));
1018  counterSetHeader.append(" | ");
1019  counterSetHeader.append(CentreAlignFormatting("Count", 10));
1020  counterSetHeader.append("\n");
1021 
1022  std::cout << "\n" << "\n";
1023  std::cout << CentreAlignFormatting("COUNTER SETS", static_cast<int>(counterSetHeader.size()));
1024  std::cout << "\n";
1025  std::cout << std::string(counterSetHeader.size(), '=') << "\n";
1026 
1027  std::cout << counterSetHeader;
1028 
1029  for (auto& it: counterDirectory.GetCounterSets()) {
1031  }
1032 
1033  auto counters = counterDirectory.GetCounters();
1034  for (auto& it: counterDirectory.GetCategories()) {
1035  PrintCategoryDetails(it, counters);
1036  }
1037  std::cout << "\n";
1038 }
void PrintDeviceDetails(const std::pair< const unsigned short, std::unique_ptr< Device >> &devicePair)
void PrintCategoryDetails(const std::unique_ptr< Category > &category, std::unordered_map< unsigned short, std::shared_ptr< Counter >> counterMap)
void PrintCounterSetDetails(const std::pair< const unsigned short, std::unique_ptr< CounterSet >> &counterSetPair)
std::string CentreAlignFormatting(const std::string &stringToPass, const int spacingWidth)

◆ PrintCounterSetDetails()

void armnn::profiling::PrintCounterSetDetails ( const std::pair< const unsigned short, std::unique_ptr< CounterSet >> &  counterSetPair)

Definition at line 883 of file ProfilingUtils.cpp.

References CentreAlignFormatting().

Referenced by PrintCounterDirectory().

884 {
885  std::string body;
886 
887  body.append(CentreAlignFormatting(counterSetPair.second->m_Name, 20));
888  body.append(" | ");
889  body.append(CentreAlignFormatting(std::to_string(counterSetPair.first), 13));
890  body.append(" | ");
891  body.append(CentreAlignFormatting(std::to_string(counterSetPair.second->m_Count), 10));
892  body.append("\n");
893 
894  std::cout << std::string(body.size(), '-') << "\n";
895 
896  std::cout<< body;
897 }
std::string CentreAlignFormatting(const std::string &stringToPass, const int spacingWidth)

◆ PrintDeviceDetails()

void armnn::profiling::PrintDeviceDetails ( const std::pair< const unsigned short, std::unique_ptr< Device >> &  devicePair)

Definition at line 868 of file ProfilingUtils.cpp.

References CentreAlignFormatting().

Referenced by PrintCounterDirectory().

869 {
870  std::string body;
871 
872  body.append(CentreAlignFormatting(devicePair.second->m_Name, 20));
873  body.append(" | ");
874  body.append(CentreAlignFormatting(std::to_string(devicePair.first), 13));
875  body.append(" | ");
876  body.append(CentreAlignFormatting(std::to_string(devicePair.second->m_Cores), 10));
877  body.append("\n");
878 
879  std::cout << std::string(body.size(), '-') << "\n";
880  std::cout<< body;
881 }
std::string CentreAlignFormatting(const std::string &stringToPass, const int spacingWidth)

◆ ReadBytes() [1/2]

void ReadBytes ( const IPacketBufferPtr packetBuffer,
unsigned int  offset,
unsigned int  valueSize,
uint8_t  outValue[] 
)

Definition at line 183 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

Referenced by BOOST_AUTO_TEST_CASE(), ConvertDirectoryComponent(), and VerifyTimelineEventBinaryPacket().

184 {
185  ARMNN_ASSERT(packetBuffer);
186 
187  ReadBytes(packetBuffer->GetReadableData(), offset, valueSize, outValue);
188 }
void ReadBytes(const unsigned char *buffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ ReadBytes() [2/2]

void ReadBytes ( const unsigned char *  buffer,
unsigned int  offset,
unsigned int  valueSize,
uint8_t  outValue[] 
)

Definition at line 218 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

219 {
220  ARMNN_ASSERT(buffer);
221  ARMNN_ASSERT(outValue);
222 
223  for (unsigned int i = 0; i < valueSize; i++, offset++)
224  {
225  outValue[i] = static_cast<uint8_t>(buffer[offset]);
226  }
227 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ ReadSwTraceMessage()

SwTraceMessage ReadSwTraceMessage ( const unsigned char *  packetBuffer,
unsigned int &  offset 
)

Definition at line 312 of file ProfilingUtils.cpp.

References ARMNN_ASSERT, CalculateSizeOfPaddedSwString(), SwTraceMessage::m_ArgNames, SwTraceMessage::m_ArgTypes, SwTraceMessage::m_Id, SwTraceMessage::m_Name, SwTraceMessage::m_UiName, ReadUint32(), and uint32_t_size.

Referenced by BOOST_AUTO_TEST_CASE(), and CheckTimelineDirectory().

313 {
314  ARMNN_ASSERT(packetBuffer);
315 
316  unsigned int uint32_t_size = sizeof(uint32_t);
317 
318  SwTraceMessage swTraceMessage;
319 
320  // Read the decl_id
321  uint32_t readDeclId = ReadUint32(packetBuffer, offset);
322  swTraceMessage.m_Id = readDeclId;
323 
324  // SWTrace "namestring" format
325  // length of the string (first 4 bytes) + string + null terminator
326 
327  // Check the decl_name
328  offset += uint32_t_size;
329  uint32_t swTraceDeclNameLength = ReadUint32(packetBuffer, offset);
330 
331  offset += uint32_t_size;
332  std::vector<unsigned char> swTraceStringBuffer(swTraceDeclNameLength - 1);
333  std::memcpy(swTraceStringBuffer.data(),
334  packetBuffer + offset, swTraceStringBuffer.size());
335 
336  swTraceMessage.m_Name.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end()); // name
337 
338  // Check the ui_name
339  offset += CalculateSizeOfPaddedSwString(swTraceMessage.m_Name);
340  uint32_t swTraceUINameLength = ReadUint32(packetBuffer, offset);
341 
342  offset += uint32_t_size;
343  swTraceStringBuffer.resize(swTraceUINameLength - 1);
344  std::memcpy(swTraceStringBuffer.data(),
345  packetBuffer + offset, swTraceStringBuffer.size());
346 
347  swTraceMessage.m_UiName.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end()); // ui_name
348 
349  // Check arg_types
350  offset += CalculateSizeOfPaddedSwString(swTraceMessage.m_UiName);
351  uint32_t swTraceArgTypesLength = ReadUint32(packetBuffer, offset);
352 
353  offset += uint32_t_size;
354  swTraceStringBuffer.resize(swTraceArgTypesLength - 1);
355  std::memcpy(swTraceStringBuffer.data(),
356  packetBuffer + offset, swTraceStringBuffer.size());
357 
358  swTraceMessage.m_ArgTypes.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end()); // arg_types
359 
360  std::string swTraceString(swTraceStringBuffer.begin(), swTraceStringBuffer.end());
361 
362  // Check arg_names
363  offset += CalculateSizeOfPaddedSwString(swTraceString);
364  uint32_t swTraceArgNamesLength = ReadUint32(packetBuffer, offset);
365 
366  offset += uint32_t_size;
367  swTraceStringBuffer.resize(swTraceArgNamesLength - 1);
368  std::memcpy(swTraceStringBuffer.data(),
369  packetBuffer + offset, swTraceStringBuffer.size());
370 
371  swTraceString.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end());
372  std::stringstream stringStream(swTraceString);
373  std::string argName;
374  while (std::getline(stringStream, argName, ','))
375  {
376  swTraceMessage.m_ArgNames.push_back(argName);
377  }
378 
379  offset += CalculateSizeOfPaddedSwString(swTraceString);
380 
381  return swTraceMessage;
382 }
uint32_t ReadUint32(const unsigned char *buffer, unsigned int offset)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
uint32_t CalculateSizeOfPaddedSwString(const std::string &str)

◆ ReadUint16() [1/2]

uint16_t ReadUint16 ( const IPacketBufferPtr packetBuffer,
unsigned int  offset 
)

Definition at line 204 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

Referenced by BOOST_AUTO_TEST_CASE(), ConvertDirectoryComponent(), and armnn::gatordmock::ReadString().

205 {
206  ARMNN_ASSERT(packetBuffer);
207 
208  return ReadUint16(packetBuffer->GetReadableData(), offset);
209 }
uint16_t ReadUint16(const unsigned char *buffer, unsigned int offset)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ ReadUint16() [2/2]

uint16_t ReadUint16 ( const unsigned char *  buffer,
unsigned int  offset 
)

Definition at line 258 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

259 {
260  ARMNN_ASSERT(buffer);
261 
262  uint32_t value = 0;
263  value = static_cast<uint32_t>(buffer[offset]);
264  value |= static_cast<uint32_t>(buffer[offset + 1]) << 8;
265  return static_cast<uint16_t>(value);
266 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ ReadUint32() [1/2]

◆ ReadUint32() [2/2]

uint32_t ReadUint32 ( const unsigned char *  buffer,
unsigned int  offset 
)

Definition at line 246 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

247 {
248  ARMNN_ASSERT(buffer);
249 
250  uint32_t value = 0;
251  value = static_cast<uint32_t>(buffer[offset]);
252  value |= static_cast<uint32_t>(buffer[offset + 1]) << 8;
253  value |= static_cast<uint32_t>(buffer[offset + 2]) << 16;
254  value |= static_cast<uint32_t>(buffer[offset + 3]) << 24;
255  return value;
256 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ ReadUint64() [1/2]

◆ ReadUint64() [2/2]

uint64_t ReadUint64 ( const unsigned char *  buffer,
unsigned int  offset 
)

Definition at line 229 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

230 {
231  ARMNN_ASSERT(buffer);
232 
233  uint64_t value = 0;
234  value = static_cast<uint64_t>(buffer[offset]);
235  value |= static_cast<uint64_t>(buffer[offset + 1]) << 8;
236  value |= static_cast<uint64_t>(buffer[offset + 2]) << 16;
237  value |= static_cast<uint64_t>(buffer[offset + 3]) << 24;
238  value |= static_cast<uint64_t>(buffer[offset + 4]) << 32;
239  value |= static_cast<uint64_t>(buffer[offset + 5]) << 40;
240  value |= static_cast<uint64_t>(buffer[offset + 6]) << 48;
241  value |= static_cast<uint64_t>(buffer[offset + 7]) << 56;
242 
243  return value;
244 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ ReadUint8() [1/2]

uint8_t ReadUint8 ( const IPacketBufferPtr packetBuffer,
unsigned int  offset 
)

Definition at line 211 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

Referenced by BOOST_AUTO_TEST_CASE(), CheckTimelineDirectory(), ConvertDirectoryComponent(), DirectoryCaptureCommandHandler::GetCounterDirectory(), and TimelineCaptureCommandHandler::ReadLabel().

212 {
213  ARMNN_ASSERT(packetBuffer);
214 
215  return ReadUint8(packetBuffer->GetReadableData(), offset);
216 }
uint8_t ReadUint8(const unsigned char *buffer, unsigned int offset)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ ReadUint8() [2/2]

uint8_t ReadUint8 ( const unsigned char *  buffer,
unsigned int  offset 
)

Definition at line 268 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

269 {
270  ARMNN_ASSERT(buffer);
271 
272  return buffer[offset];
273 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ ReceivePacket()

Packet ReceivePacket ( const unsigned char *  buffer,
uint32_t  length 
)

Definition at line 1054 of file ProfilingUtils.cpp.

Referenced by FileOnlyProfilingConnection::WritePacket().

1055 {
1056  if (buffer == nullptr)
1057  {
1058  throw armnnProfiling::ProfilingException("data buffer is nullptr");
1059  }
1060  if (length < 8)
1061  {
1062  throw armnnProfiling::ProfilingException("length of data buffer is less than 8");
1063  }
1064 
1065  uint32_t metadataIdentifier = 0;
1066  std::memcpy(&metadataIdentifier, buffer, sizeof(metadataIdentifier));
1067 
1068  uint32_t dataLength = 0;
1069  std::memcpy(&dataLength, buffer + 4u, sizeof(dataLength));
1070 
1071  std::unique_ptr<unsigned char[]> packetData;
1072  if (dataLength > 0)
1073  {
1074  packetData = std::make_unique<unsigned char[]>(dataLength);
1075  std::memcpy(packetData.get(), buffer + 8u, dataLength);
1076  }
1077 
1078  return Packet(metadataIdentifier, dataLength, packetData);
1079 }

◆ StringToSwTraceString()

bool armnn::profiling::StringToSwTraceString ( const std::string &  s,
std::vector< uint32_t > &  outputBuffer 
)

Definition at line 98 of file ProfilingUtils.hpp.

References armnn::numeric_cast(), and uint32_t_size.

99 {
100  // Converts the given string to an SWTrace "string" (i.e. a string of "chars"), and writes it into
101  // the given buffer including the null-terminator. It also pads it to the next uint32_t if necessary
102 
103  // Clear the output buffer
104  outputBuffer.clear();
105 
106  // Check that the given string is a valid SWTrace "string" (i.e. a string of "chars")
107  if (!IsValidSwTraceString<SwTracePolicy>(s))
108  {
109  return false;
110  }
111 
112  // Prepare the output buffer
113  size_t s_size = s.size() + 1; // The size of the string (in chars) plus the null-terminator
114  size_t uint32_t_size = sizeof(uint32_t);
115  // Output buffer size = StringLength (32 bit) + amount of complete 32bit words that fit into the string
116  // + an additional 32bit word if there are remaining chars to complete the string
117  // (The rest of the 32bit word is then filled with the NULL terminator)
118  size_t outBufferSize = 1 + (s_size / uint32_t_size) + (s_size % uint32_t_size != 0 ? 1 : 0);
119  outputBuffer.resize(outBufferSize, '\0');
120 
121  // Write the SWTrace string to the output buffer
122  outputBuffer[0] = boost::numeric_cast<uint32_t>(s_size);
123  std::memcpy(outputBuffer.data() + 1, s.data(), s_size);
124 
125  return true;
126 }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33

◆ WriteBytes() [1/3]

void armnn::profiling::WriteBytes ( const IPacketBufferPtr packetBuffer,
unsigned int  offset,
const void *  value,
unsigned int  valueSize 
)

Definition at line 91 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

Referenced by BOOST_AUTO_TEST_CASE(), ConvertDirectoryComponent(), and WriteTimelineEventBinary().

92 {
93  ARMNN_ASSERT(packetBuffer);
94 
95  WriteBytes(packetBuffer->GetWritableData(), offset, value, valueSize);
96 }
void WriteBytes(unsigned char *buffer, unsigned int offset, const void *value, unsigned int valueSize)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ WriteBytes() [2/3]

void WriteBytes ( unsigned char *  buffer,
unsigned int  offset,
const void *  value,
unsigned int  valueSize 
)

Definition at line 133 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

134 {
135  ARMNN_ASSERT(buffer);
136  ARMNN_ASSERT(value);
137 
138  for (unsigned int i = 0; i < valueSize; i++, offset++)
139  {
140  buffer[offset] = *(reinterpret_cast<const unsigned char*>(value) + i);
141  }
142 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ WriteBytes() [3/3]

void armnn::profiling::WriteBytes ( const IPacketBuffer packetBuffer,
unsigned int  offset,
const void *  value,
unsigned int  valueSize 
)

◆ WriteTimelineEntityBinary()

TimelinePacketStatus WriteTimelineEntityBinary ( uint64_t  profilingGuid,
unsigned char *  buffer,
unsigned int  remainingBufferSize,
unsigned int &  numberOfBytesWritten 
)

Definition at line 509 of file ProfilingUtils.cpp.

References BufferExhaustion, Ok, uint32_t_size, WriteUint32(), and WriteUint64().

Referenced by BOOST_AUTO_TEST_CASE(), and SendTimelinePacket::SendTimelineEntityBinaryPacket().

513 {
514  // Initialize the output value
515  numberOfBytesWritten = 0;
516 
517  // Check that the given buffer is valid
518  if (buffer == nullptr || remainingBufferSize == 0)
519  {
520  return TimelinePacketStatus::BufferExhaustion;
521  }
522 
523  // Utils
524  unsigned int uint32_t_size = sizeof(uint32_t);
525  unsigned int uint64_t_size = sizeof(uint64_t);
526 
527  // Calculate the length of the data (in bytes)
528  unsigned int timelineEntityDataLength = uint32_t_size + uint64_t_size; // decl_id + Profiling GUID
529 
530  // Check whether the timeline binary packet fits in the given buffer
531  if (timelineEntityDataLength > remainingBufferSize)
532  {
533  return TimelinePacketStatus::BufferExhaustion;
534  }
535 
536  // Initialize the offset for writing in the buffer
537  unsigned int offset = 0;
538 
539  // Write the decl_Id to the buffer
540  WriteUint32(buffer, offset, 1u);
541  offset += uint32_t_size;
542 
543  // Write the timeline binary packet payload to the buffer
544  WriteUint64(buffer, offset, profilingGuid); // Profiling GUID
545 
546  // Update the number of bytes written
547  numberOfBytesWritten = timelineEntityDataLength;
548 
549  return TimelinePacketStatus::Ok;
550 }
void WriteUint32(unsigned char *buffer, unsigned int offset, uint32_t value)
void WriteUint64(unsigned char *buffer, unsigned int offset, uint64_t value)

◆ WriteTimelineEventBinary()

TimelinePacketStatus WriteTimelineEventBinary ( uint64_t  timestamp,
std::thread::id  threadId,
uint64_t  profilingGuid,
unsigned char *  buffer,
unsigned int  remainingBufferSize,
unsigned int &  numberOfBytesWritten 
)

Definition at line 796 of file ProfilingUtils.cpp.

References BufferExhaustion, Ok, ThreadIdSize, uint32_t_size, WriteBytes(), WriteUint32(), and WriteUint64().

Referenced by BOOST_AUTO_TEST_CASE(), and SendTimelinePacket::SendTimelineEventBinaryPacket().

802 {
803  // Initialize the output value
804  numberOfBytesWritten = 0;
805  // Check that the given buffer is valid
806  if (buffer == nullptr || remainingBufferSize == 0)
807  {
808  return TimelinePacketStatus::BufferExhaustion;
809  }
810 
811  // Utils
812  unsigned int uint32_t_size = sizeof(uint32_t);
813  unsigned int uint64_t_size = sizeof(uint64_t);
814 
815  // decl_id of the timeline message
816  uint32_t declId = 4;
817 
818  // Calculate the length of the data (in bytes)
819  unsigned int timelineEventDataLength = uint32_t_size + // decl_id
820  uint64_t_size + // Timestamp
821  ThreadIdSize + // Thread id
822  uint64_t_size; // Profiling GUID
823 
824  // Check whether the timeline binary packet fits in the given buffer
825  if (timelineEventDataLength > remainingBufferSize)
826  {
827  return TimelinePacketStatus::BufferExhaustion;
828  }
829 
830  // Initialize the offset for writing in the buffer
831  unsigned int offset = 0;
832 
833  // Write the timeline binary payload to the buffer
834  WriteUint32(buffer, offset, declId); // decl_id
835  offset += uint32_t_size;
836  WriteUint64(buffer, offset, timestamp); // Timestamp
837  offset += uint64_t_size;
838  WriteBytes(buffer, offset, &threadId, ThreadIdSize); // Thread id
839  offset += ThreadIdSize;
840  WriteUint64(buffer, offset, profilingGuid); // Profiling GUID
841  offset += uint64_t_size;
842  // Update the number of bytes written
843  numberOfBytesWritten = timelineEventDataLength;
844 
845  return TimelinePacketStatus::Ok;
846 }
void WriteBytes(unsigned char *buffer, unsigned int offset, const void *value, unsigned int valueSize)
void WriteUint32(unsigned char *buffer, unsigned int offset, uint32_t value)
constexpr unsigned int ThreadIdSize
void WriteUint64(unsigned char *buffer, unsigned int offset, uint64_t value)

◆ WriteTimelineEventClassBinary()

TimelinePacketStatus WriteTimelineEventClassBinary ( uint64_t  profilingGuid,
unsigned char *  buffer,
unsigned int  remainingBufferSize,
unsigned int &  numberOfBytesWritten 
)

Definition at line 752 of file ProfilingUtils.cpp.

References BufferExhaustion, Ok, uint32_t_size, WriteUint32(), and WriteUint64().

Referenced by BOOST_AUTO_TEST_CASE(), and SendTimelinePacket::SendTimelineEventClassBinaryPacket().

756 {
757  // Initialize the output value
758  numberOfBytesWritten = 0;
759 
760  // Check that the given buffer is valid
761  if (buffer == nullptr || remainingBufferSize == 0)
762  {
763  return TimelinePacketStatus::BufferExhaustion;
764  }
765 
766  // Utils
767  unsigned int uint32_t_size = sizeof(uint32_t);
768  unsigned int uint64_t_size = sizeof(uint64_t);
769 
770  // decl_id of the timeline message
771  uint32_t declId = 2;
772 
773  // Calculate the length of the data (in bytes)
774  unsigned int dataSize = uint32_t_size + uint64_t_size; // decl_id + Profiling GUID
775 
776  // Check whether the timeline binary fits in the given buffer
777  if (dataSize > remainingBufferSize)
778  {
779  return TimelinePacketStatus::BufferExhaustion;
780  }
781 
782  // Initialize the offset for writing in the buffer
783  unsigned int offset = 0;
784 
785  // Write the timeline binary payload to the buffer
786  WriteUint32(buffer, offset, declId); // decl_id
787  offset += uint32_t_size;
788  WriteUint64(buffer, offset, profilingGuid); // Profiling GUID
789 
790  // Update the number of bytes written
791  numberOfBytesWritten = dataSize;
792 
793  return TimelinePacketStatus::Ok;
794 }
void WriteUint32(unsigned char *buffer, unsigned int offset, uint32_t value)
void WriteUint64(unsigned char *buffer, unsigned int offset, uint64_t value)

◆ WriteTimelineLabelBinaryPacket()

TimelinePacketStatus WriteTimelineLabelBinaryPacket ( uint64_t  profilingGuid,
const std::string &  label,
unsigned char *  buffer,
unsigned int  remainingBufferSize,
unsigned int &  numberOfBytesWritten 
)

Definition at line 446 of file ProfilingUtils.cpp.

References BufferExhaustion, Error, armnn::numeric_cast(), Ok, uint32_t_size, WriteUint32(), and WriteUint64().

Referenced by BOOST_AUTO_TEST_CASE(), and SendTimelinePacket::SendTimelineLabelBinaryPacket().

451 {
452  // Initialize the output value
453  numberOfBytesWritten = 0;
454 
455  // Check that the given buffer is valid
456  if (buffer == nullptr || remainingBufferSize == 0)
457  {
458  return TimelinePacketStatus::BufferExhaustion;
459  }
460 
461  // Utils
462  unsigned int uint32_t_size = sizeof(uint32_t);
463  unsigned int uint64_t_size = sizeof(uint64_t);
464 
465  // Convert the label into a SWTrace string
466  std::vector<uint32_t> swTraceLabel;
467  bool result = StringToSwTraceString<SwTraceCharPolicy>(label, swTraceLabel);
468  if (!result)
469  {
470  return TimelinePacketStatus::Error;
471  }
472 
473  // Calculate the size of the SWTrace string label (in bytes)
474  unsigned int swTraceLabelSize = boost::numeric_cast<unsigned int>(swTraceLabel.size()) * uint32_t_size;
475 
476  // Calculate the length of the data (in bytes)
477  unsigned int timelineLabelPacketDataLength = uint32_t_size + // decl_Id
478  uint64_t_size + // Profiling GUID
479  swTraceLabelSize; // Label
480 
481  // Check whether the timeline binary packet fits in the given buffer
482  if (timelineLabelPacketDataLength > remainingBufferSize)
483  {
484  return TimelinePacketStatus::BufferExhaustion;
485  }
486 
487  // Initialize the offset for writing in the buffer
488  unsigned int offset = 0;
489 
490  // Write decl_Id to the buffer
491  WriteUint32(buffer, offset, 0u);
492  offset += uint32_t_size;
493 
494  // Write the timeline binary packet payload to the buffer
495  WriteUint64(buffer, offset, profilingGuid); // Profiling GUID
496  offset += uint64_t_size;
497  for (uint32_t swTraceLabelWord : swTraceLabel)
498  {
499  WriteUint32(buffer, offset, swTraceLabelWord); // Label
500  offset += uint32_t_size;
501  }
502 
503  // Update the number of bytes written
504  numberOfBytesWritten = timelineLabelPacketDataLength;
505 
506  return TimelinePacketStatus::Ok;
507 }
void WriteUint32(unsigned char *buffer, unsigned int offset, uint32_t value)
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33
void WriteUint64(unsigned char *buffer, unsigned int offset, uint64_t value)

◆ WriteTimelineMessageDirectoryPackage()

TimelinePacketStatus WriteTimelineMessageDirectoryPackage ( unsigned char *  buffer,
unsigned int  remainingBufferSize,
unsigned int &  numberOfBytesWritten 
)

Definition at line 625 of file ProfilingUtils.cpp.

References BufferExhaustion, CreateTimelinePacketHeader(), Error, armnn::numeric_cast(), Ok, ThreadIdSize, uint32_t_size, WriteUint32(), and WriteUint8().

Referenced by BOOST_AUTO_TEST_CASE(), and SendTimelinePacket::SendTimelineMessageDirectoryPackage().

628 {
629  // Initialize the output value
630  numberOfBytesWritten = 0;
631 
632  // Check that the given buffer is valid
633  if (buffer == nullptr || remainingBufferSize == 0)
634  {
635  return TimelinePacketStatus::BufferExhaustion;
636  }
637 
638  // Utils
639  unsigned int uint8_t_size = sizeof(uint8_t);
640  unsigned int uint32_t_size = sizeof(uint32_t);
641  unsigned int uint64_t_size = sizeof(uint64_t);
642 
643  // The payload/data of the packet consists of swtrace event definitions encoded according
644  // to the swtrace directory specification. The messages being the five defined below:
645  //
646  // | decl_id | decl_name | ui_name | arg_types | arg_names |
647  // |-----------|---------------------|-----------------------|-------------|-------------------------------------|
648  // | 0 | declareLabel | declare label | ps | guid,value |
649  // | 1 | declareEntity | declare entity | p | guid |
650  // | 2 | declareEventClass | declare event class | p | guid |
651  // | 3 | declareRelationship | declare relationship | Ippp | relationshipType,relationshipGuid, |
652  // | | | | | headGuid,tailGuid |
653  // | 4 | declareEvent | declare event | @tp | timestamp,threadId,eventGuid |
654  std::vector<std::vector<std::string>> timelineDirectoryMessages
655  {
656  { "0", "declareLabel", "declare label", "ps", "guid,value" },
657  { "1", "declareEntity", "declare entity", "p", "guid" },
658  { "2", "declareEventClass", "declare event class", "p", "guid" },
659  { "3", "declareRelationship", "declare relationship", "Ippp",
660  "relationshipType,relationshipGuid,headGuid,tailGuid" },
661  { "4", "declareEvent", "declare event", "@tp", "timestamp,threadId,eventGuid" }
662  };
663 
664  // Build the message declarations
665  std::vector<uint32_t> swTraceBuffer;
666  for (const auto& directoryComponent : timelineDirectoryMessages)
667  {
668  // decl_id
669  uint32_t declId = 0;
670  try
671  {
672  declId = boost::numeric_cast<uint32_t>(std::stoul(directoryComponent[0]));
673  }
674  catch (const std::exception&)
675  {
676  return TimelinePacketStatus::Error;
677  }
678  swTraceBuffer.push_back(declId);
679 
680  bool result = true;
681  result &= ConvertDirectoryComponent<SwTraceNameCharPolicy>(directoryComponent[1], swTraceBuffer); // decl_name
682  result &= ConvertDirectoryComponent<SwTraceCharPolicy> (directoryComponent[2], swTraceBuffer); // ui_name
683  result &= ConvertDirectoryComponent<SwTraceTypeCharPolicy>(directoryComponent[3], swTraceBuffer); // arg_types
684  result &= ConvertDirectoryComponent<SwTraceCharPolicy> (directoryComponent[4], swTraceBuffer); // arg_names
685  if (!result)
686  {
687  return TimelinePacketStatus::Error;
688  }
689  }
690 
691  unsigned int dataLength = 3 * uint8_t_size + // Stream header (3 bytes)
692  boost::numeric_cast<unsigned int>(swTraceBuffer.size()) *
693  uint32_t_size; // Trace directory (5 messages)
694 
695  // Calculate the timeline directory binary packet size (in bytes)
696  unsigned int timelineDirectoryPacketSize = 2 * uint32_t_size + // Header (2 words)
697  dataLength; // Payload
698 
699  // Check whether the timeline directory binary packet fits in the given buffer
700  if (timelineDirectoryPacketSize > remainingBufferSize)
701  {
702  return TimelinePacketStatus::BufferExhaustion;
703  }
704 
705  // Create packet header
706  auto packetHeader = CreateTimelinePacketHeader(1, 0, 0, 0, 0, boost::numeric_cast<uint32_t>(dataLength));
707 
708  // Initialize the offset for writing in the buffer
709  unsigned int offset = 0;
710 
711  // Write the timeline binary packet header to the buffer
712  WriteUint32(buffer, offset, packetHeader.first);
713  offset += uint32_t_size;
714  WriteUint32(buffer, offset, packetHeader.second);
715  offset += uint32_t_size;
716 
717  // Write the stream header
718  uint8_t streamVersion = 4;
719  uint8_t pointerBytes = boost::numeric_cast<uint8_t>(uint64_t_size); // All GUIDs are uint64_t
720  uint8_t threadIdBytes = boost::numeric_cast<uint8_t>(ThreadIdSize);
721  switch (threadIdBytes)
722  {
723  case 4: // Typically Windows and Android
724  case 8: // Typically Linux
725  break; // Valid values
726  default:
727  return TimelinePacketStatus::Error; // Invalid value
728  }
729  WriteUint8(buffer, offset, streamVersion);
730  offset += uint8_t_size;
731  WriteUint8(buffer, offset, pointerBytes);
732  offset += uint8_t_size;
733  WriteUint8(buffer, offset, threadIdBytes);
734  offset += uint8_t_size;
735 
736  // Write the SWTrace directory
737  uint32_t numberOfDeclarations = boost::numeric_cast<uint32_t>(timelineDirectoryMessages.size());
738  WriteUint32(buffer, offset, numberOfDeclarations); // Number of declarations
739  offset += uint32_t_size;
740  for (uint32_t i : swTraceBuffer)
741  {
742  WriteUint32(buffer, offset, i); // Message declarations
743  offset += uint32_t_size;
744  }
745 
746  // Update the number of bytes written
747  numberOfBytesWritten = timelineDirectoryPacketSize;
748 
749  return TimelinePacketStatus::Ok;
750 }
void WriteUint32(unsigned char *buffer, unsigned int offset, uint32_t value)
std::pair< uint32_t, uint32_t > CreateTimelinePacketHeader(uint32_t packetFamily, uint32_t packetClass, uint32_t packetType, uint32_t streamId, uint32_t sequenceNumbered, uint32_t dataLength)
Creates a timeline packet header.
void WriteUint8(unsigned char *buffer, unsigned int offset, uint8_t value)
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33
constexpr unsigned int ThreadIdSize

◆ WriteTimelineRelationshipBinary()

TimelinePacketStatus WriteTimelineRelationshipBinary ( ProfilingRelationshipType  relationshipType,
uint64_t  relationshipGuid,
uint64_t  headGuid,
uint64_t  tailGuid,
unsigned char *  buffer,
unsigned int  remainingBufferSize,
unsigned int &  numberOfBytesWritten 
)

Definition at line 552 of file ProfilingUtils.cpp.

References BufferExhaustion, DataLink, ExecutionLink, LabelLink, Ok, RetentionLink, uint32_t_size, WriteUint32(), and WriteUint64().

Referenced by BOOST_AUTO_TEST_CASE(), and SendTimelinePacket::SendTimelineRelationshipBinaryPacket().

559 {
560  // Initialize the output value
561  numberOfBytesWritten = 0;
562 
563  // Check that the given buffer is valid
564  if (buffer == nullptr || remainingBufferSize == 0)
565  {
566  return TimelinePacketStatus::BufferExhaustion;
567  }
568 
569  // Utils
570  unsigned int uint32_t_size = sizeof(uint32_t);
571  unsigned int uint64_t_size = sizeof(uint64_t);
572 
573  // Calculate the length of the data (in bytes)
574  unsigned int timelineRelationshipDataLength = uint32_t_size * 2 + // decl_id + Relationship Type
575  uint64_t_size * 3; // Relationship GUID + Head GUID + tail GUID
576 
577  // Check whether the timeline binary fits in the given buffer
578  if (timelineRelationshipDataLength > remainingBufferSize)
579  {
580  return TimelinePacketStatus::BufferExhaustion;
581  }
582 
583  // Initialize the offset for writing in the buffer
584  unsigned int offset = 0;
585 
586  uint32_t relationshipTypeUint = 0;
587 
588  switch (relationshipType)
589  {
590  case ProfilingRelationshipType::RetentionLink:
591  relationshipTypeUint = 0;
592  break;
593  case ProfilingRelationshipType::ExecutionLink:
594  relationshipTypeUint = 1;
595  break;
596  case ProfilingRelationshipType::DataLink:
597  relationshipTypeUint = 2;
598  break;
599  case ProfilingRelationshipType::LabelLink:
600  relationshipTypeUint = 3;
601  break;
602  default:
603  throw InvalidArgumentException("Unknown relationship type given.");
604  }
605 
606  // Write the timeline binary payload to the buffer
607  // decl_id of the timeline message
608  uint32_t declId = 3;
609  WriteUint32(buffer, offset, declId); // decl_id
610  offset += uint32_t_size;
611  WriteUint32(buffer, offset, relationshipTypeUint); // Relationship Type
612  offset += uint32_t_size;
613  WriteUint64(buffer, offset, relationshipGuid); // GUID of this relationship
614  offset += uint64_t_size;
615  WriteUint64(buffer, offset, headGuid); // head of relationship GUID
616  offset += uint64_t_size;
617  WriteUint64(buffer, offset, tailGuid); // tail of relationship GUID
618 
619  // Update the number of bytes written
620  numberOfBytesWritten = timelineRelationshipDataLength;
621 
622  return TimelinePacketStatus::Ok;
623 }
void WriteUint32(unsigned char *buffer, unsigned int offset, uint32_t value)
void WriteUint64(unsigned char *buffer, unsigned int offset, uint64_t value)

◆ WriteUint16() [1/2]

void WriteUint16 ( const IPacketBufferPtr packetBuffer,
unsigned int  offset,
uint16_t  value 
)

Definition at line 119 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

Referenced by BOOST_AUTO_TEST_CASE(), FileOnlyProfilingConnection::Close(), ConvertDirectoryComponent(), PacketWriter(), SendCounterPacket::SendPeriodicCounterCapturePacket(), GatordMockService::SendPeriodicCounterSelectionList(), and SendCounterPacket::SendPeriodicCounterSelectionPacket().

120 {
121  ARMNN_ASSERT(packetBuffer);
122 
123  WriteUint16(packetBuffer->GetWritableData(), offset, value);
124 }
void WriteUint16(unsigned char *buffer, unsigned int offset, uint16_t value)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ WriteUint16() [2/2]

void WriteUint16 ( unsigned char *  buffer,
unsigned int  offset,
uint16_t  value 
)

Definition at line 168 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

169 {
170  ARMNN_ASSERT(buffer);
171 
172  buffer[offset] = static_cast<unsigned char>(value & 0xFF);
173  buffer[offset + 1] = static_cast<unsigned char>((value >> 8) & 0xFF);
174 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ WriteUint32() [1/2]

◆ WriteUint32() [2/2]

void WriteUint32 ( unsigned char *  buffer,
unsigned int  offset,
uint32_t  value 
)

Definition at line 158 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

159 {
160  ARMNN_ASSERT(buffer);
161 
162  buffer[offset] = static_cast<unsigned char>(value & 0xFF);
163  buffer[offset + 1] = static_cast<unsigned char>((value >> 8) & 0xFF);
164  buffer[offset + 2] = static_cast<unsigned char>((value >> 16) & 0xFF);
165  buffer[offset + 3] = static_cast<unsigned char>((value >> 24) & 0xFF);
166 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ WriteUint64() [1/3]

void armnn::profiling::WriteUint64 ( const std::unique_ptr< IPacketBuffer > &  packetBuffer,
unsigned int  offset,
uint64_t  value 
)

Definition at line 105 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

Referenced by BOOST_AUTO_TEST_CASE(), ConvertDirectoryComponent(), SendCounterPacket::SendPeriodicCounterCapturePacket(), WriteTimelineEntityBinary(), WriteTimelineEventBinary(), WriteTimelineEventClassBinary(), WriteTimelineLabelBinaryPacket(), and WriteTimelineRelationshipBinary().

106 {
107  ARMNN_ASSERT(packetBuffer);
108 
109  WriteUint64(packetBuffer->GetWritableData(), offset, value);
110 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
void WriteUint64(unsigned char *buffer, unsigned int offset, uint64_t value)

◆ WriteUint64() [2/3]

void WriteUint64 ( unsigned char *  buffer,
unsigned int  offset,
uint64_t  value 
)

Definition at line 144 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

145 {
146  ARMNN_ASSERT(buffer);
147 
148  buffer[offset] = static_cast<unsigned char>(value & 0xFF);
149  buffer[offset + 1] = static_cast<unsigned char>((value >> 8) & 0xFF);
150  buffer[offset + 2] = static_cast<unsigned char>((value >> 16) & 0xFF);
151  buffer[offset + 3] = static_cast<unsigned char>((value >> 24) & 0xFF);
152  buffer[offset + 4] = static_cast<unsigned char>((value >> 32) & 0xFF);
153  buffer[offset + 5] = static_cast<unsigned char>((value >> 40) & 0xFF);
154  buffer[offset + 6] = static_cast<unsigned char>((value >> 48) & 0xFF);
155  buffer[offset + 7] = static_cast<unsigned char>((value >> 56) & 0xFF);
156 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ WriteUint64() [3/3]

void armnn::profiling::WriteUint64 ( const IPacketBufferPtr packetBuffer,
unsigned int  offset,
uint64_t  value 
)

◆ WriteUint8() [1/2]

void WriteUint8 ( const IPacketBufferPtr packetBuffer,
unsigned int  offset,
uint8_t  value 
)

Definition at line 126 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

Referenced by ConvertDirectoryComponent(), and WriteTimelineMessageDirectoryPackage().

127 {
128  ARMNN_ASSERT(packetBuffer);
129 
130  WriteUint8(packetBuffer->GetWritableData(), offset, value);
131 }
void WriteUint8(unsigned char *buffer, unsigned int offset, uint8_t value)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ WriteUint8() [2/2]

void WriteUint8 ( unsigned char *  buffer,
unsigned int  offset,
uint8_t  value 
)

Definition at line 176 of file ProfilingUtils.cpp.

References ARMNN_ASSERT.

177 {
178  ARMNN_ASSERT(buffer);
179 
180  buffer[offset] = static_cast<unsigned char>(value);
181 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

Variable Documentation

◆ ThreadIdSize

constexpr unsigned int ThreadIdSize = sizeof(std::thread::id)

◆ uint16_t_size

◆ uint32_t_size