ArmNN
 21.08
ProfilingMocks.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <Holder.hpp>
11 #include <ProfilingService.hpp>
12 #include <ProfilingUtils.hpp>
13 #include <SendCounterPacket.hpp>
14 #include <SendThread.hpp>
15 
16 #include <armnn/Exceptions.hpp>
17 #include <armnn/Optional.hpp>
18 #include <armnn/Conversion.hpp>
19 #include <armnn/utility/Assert.hpp>
22 
23 #include <common/include/ProfilingGuidGenerator.hpp>
24 
25 #include <atomic>
26 #include <condition_variable>
27 #include <mutex>
28 #include <thread>
29 
30 namespace armnn
31 {
32 
33 namespace profiling
34 {
35 
37 {
38 public:
40  : m_IsOpen(true)
41  , m_WrittenData()
42  , m_Packet()
43  {}
44 
45  enum class PacketType
46  {
57  Unknown
58  };
59 
60  bool IsOpen() const override
61  {
62  std::lock_guard<std::mutex> lock(m_Mutex);
63 
64  return m_IsOpen;
65  }
66 
67  void Close() override
68  {
69  std::lock_guard<std::mutex> lock(m_Mutex);
70 
71  m_IsOpen = false;
72  }
73 
74  bool WritePacket(const unsigned char* buffer, uint32_t length) override
75  {
76  if (buffer == nullptr || length == 0)
77  {
78  return false;
79  }
80 
81  uint32_t header = ReadUint32(buffer, 0);
82 
83  uint32_t packetFamily = (header >> 26);
84  uint32_t packetId = ((header >> 16) & 1023);
85 
86  PacketType packetType;
87 
88  switch (packetFamily)
89  {
90  case 0:
91  packetType = packetId < 8 ? PacketType(packetId) : PacketType::Unknown;
92  break;
93  case 1:
94  packetType = packetId == 0 ? PacketType::TimelineMessageDirectory : PacketType::Unknown;
95  break;
96  case 3:
97  packetType = packetId == 0 ? PacketType::PeriodicCounterCapture : PacketType::Unknown;
98  break;
99  default:
100  packetType = PacketType::Unknown;
101  }
102 
103  std::lock_guard<std::mutex> lock(m_Mutex);
104 
105  m_WrittenData.push_back({ packetType, length });
106  return true;
107  }
108 
109  long CheckForPacket(const std::pair<PacketType, uint32_t> packetInfo)
110  {
111  std::lock_guard<std::mutex> lock(m_Mutex);
112 
113  if(packetInfo.second != 0)
114  {
115  return static_cast<long>(std::count(m_WrittenData.begin(), m_WrittenData.end(), packetInfo));
116  }
117  else
118  {
119  return static_cast<long>(std::count_if(m_WrittenData.begin(), m_WrittenData.end(),
120  [&packetInfo](const std::pair<PacketType, uint32_t> pair) { return packetInfo.first == pair.first; }));
121  }
122  }
123 
124  bool WritePacket(arm::pipe::Packet&& packet)
125  {
126  std::lock_guard<std::mutex> lock(m_Mutex);
127 
128  m_Packet = std::move(packet);
129  return true;
130  }
131 
132  arm::pipe::Packet ReadPacket(uint32_t timeout) override
133  {
134  IgnoreUnused(timeout);
135 
136  // Simulate a delay in the reading process. The default timeout is way too long.
137  std::this_thread::sleep_for(std::chrono::milliseconds(5));
138  std::lock_guard<std::mutex> lock(m_Mutex);
139  return std::move(m_Packet);
140  }
141 
142  unsigned long GetWrittenDataSize()
143  {
144  std::lock_guard<std::mutex> lock(m_Mutex);
145 
146  return static_cast<unsigned long>(m_WrittenData.size());
147  }
148 
149  void Clear()
150  {
151  std::lock_guard<std::mutex> lock(m_Mutex);
152 
153  m_WrittenData.clear();
154  }
155 
156 private:
157  bool m_IsOpen;
158  std::vector<std::pair<PacketType, uint32_t>> m_WrittenData;
159  arm::pipe::Packet m_Packet;
160  mutable std::mutex m_Mutex;
161 };
162 
164 {
165 public:
167  {
168  IgnoreUnused(options);
169  return std::make_unique<MockProfilingConnection>();
170  }
171 };
172 
174 {
175 public:
176  MockPacketBuffer(unsigned int maxSize)
177  : m_MaxSize(maxSize)
178  , m_Size(0)
179  , m_Data(std::make_unique<unsigned char[]>(m_MaxSize))
180  {}
181 
183 
184  const unsigned char* GetReadableData() const override { return m_Data.get(); }
185 
186  unsigned int GetSize() const override { return m_Size; }
187 
188  void MarkRead() override { m_Size = 0; }
189 
190  void Commit(unsigned int size) override { m_Size = size; }
191 
192  void Release() override { m_Size = 0; }
193 
194  unsigned char* GetWritableData() override { return m_Data.get(); }
195 
196  void Destroy() override {m_Data.reset(nullptr); m_Size = 0; m_MaxSize =0;}
197 
198 private:
199  unsigned int m_MaxSize;
200  unsigned int m_Size;
201  std::unique_ptr<unsigned char[]> m_Data;
202 };
203 
205 {
206 public:
207  MockBufferManager(unsigned int size)
208  : m_BufferSize(size),
209  m_Buffer(std::make_unique<MockPacketBuffer>(size)) {}
210 
212 
213  IPacketBufferPtr Reserve(unsigned int requestedSize, unsigned int& reservedSize) override
214  {
215  if (requestedSize > m_BufferSize)
216  {
217  reservedSize = m_BufferSize;
218  }
219  else
220  {
221  reservedSize = requestedSize;
222  }
223 
224  return std::move(m_Buffer);
225  }
226 
227  void Commit(IPacketBufferPtr& packetBuffer, unsigned int size, bool notifyConsumer = true) override
228  {
229  packetBuffer->Commit(size);
230  m_Buffer = std::move(packetBuffer);
231 
232  if (notifyConsumer)
233  {
234  FlushReadList();
235  }
236  }
237 
239  {
240  return std::move(m_Buffer);
241  }
242 
243  void Release(IPacketBufferPtr& packetBuffer) override
244  {
245  packetBuffer->Release();
246  m_Buffer = std::move(packetBuffer);
247  }
248 
249  void MarkRead(IPacketBufferPtr& packetBuffer) override
250  {
251  packetBuffer->MarkRead();
252  m_Buffer = std::move(packetBuffer);
253  }
254 
255  void SetConsumer(IConsumer* consumer) override
256  {
257  if (consumer != nullptr)
258  {
259  m_Consumer = consumer;
260  }
261  }
262 
263  void FlushReadList() override
264  {
265  // notify consumer that packet is ready to read
266  if (m_Consumer != nullptr)
267  {
268  m_Consumer->SetReadyToRead();
269  }
270  }
271 
272 private:
273  unsigned int m_BufferSize;
274  IPacketBufferPtr m_Buffer;
275  IConsumer* m_Consumer = nullptr;
276 };
277 
279 {
280 public:
281  MockStreamCounterBuffer(unsigned int maxBufferSize = 4096)
282  : m_MaxBufferSize(maxBufferSize)
283  , m_BufferList()
284  , m_CommittedSize(0)
285  , m_ReadableSize(0)
286  , m_ReadSize(0)
287  {}
289 
290  IPacketBufferPtr Reserve(unsigned int requestedSize, unsigned int& reservedSize) override
291  {
292  std::lock_guard<std::mutex> lock(m_Mutex);
293 
294  reservedSize = 0;
295  if (requestedSize > m_MaxBufferSize)
296  {
297  throw armnn::InvalidArgumentException("The maximum buffer size that can be requested is [" +
298  std::to_string(m_MaxBufferSize) + "] bytes");
299  }
300  reservedSize = requestedSize;
301  return std::make_unique<MockPacketBuffer>(requestedSize);
302  }
303 
304  void Commit(IPacketBufferPtr& packetBuffer, unsigned int size, bool notifyConsumer = true) override
305  {
306  std::lock_guard<std::mutex> lock(m_Mutex);
307 
308  packetBuffer->Commit(size);
309  m_BufferList.push_back(std::move(packetBuffer));
310  m_CommittedSize += size;
311 
312  if (notifyConsumer)
313  {
314  FlushReadList();
315  }
316  }
317 
318  void Release(IPacketBufferPtr& packetBuffer) override
319  {
320  std::lock_guard<std::mutex> lock(m_Mutex);
321 
322  packetBuffer->Release();
323  }
324 
326  {
327  std::lock_guard<std::mutex> lock(m_Mutex);
328 
329  if (m_BufferList.empty())
330  {
331  return nullptr;
332  }
333  IPacketBufferPtr buffer = std::move(m_BufferList.back());
334  m_BufferList.pop_back();
335  m_ReadableSize += buffer->GetSize();
336  return buffer;
337  }
338 
339  void MarkRead(IPacketBufferPtr& packetBuffer) override
340  {
341  std::lock_guard<std::mutex> lock(m_Mutex);
342 
343  m_ReadSize += packetBuffer->GetSize();
344  packetBuffer->MarkRead();
345  }
346 
347  void SetConsumer(IConsumer* consumer) override
348  {
349  if (consumer != nullptr)
350  {
351  m_Consumer = consumer;
352  }
353  }
354 
355  void FlushReadList() override
356  {
357  // notify consumer that packet is ready to read
358  if (m_Consumer != nullptr)
359  {
360  m_Consumer->SetReadyToRead();
361  }
362  }
363 
364  unsigned int GetCommittedSize() const { return m_CommittedSize; }
365  unsigned int GetReadableSize() const { return m_ReadableSize; }
366  unsigned int GetReadSize() const { return m_ReadSize; }
367 
368 private:
369  // The maximum buffer size when creating a new buffer
370  unsigned int m_MaxBufferSize;
371 
372  // A list of buffers
373  std::vector<IPacketBufferPtr> m_BufferList;
374 
375  // The mutex to synchronize this mock's methods
376  std::mutex m_Mutex;
377 
378  // The total size of the buffers that has been committed for reading
379  unsigned int m_CommittedSize;
380 
381  // The total size of the buffers that can be read
382  unsigned int m_ReadableSize;
383 
384  // The total size of the buffers that has already been read
385  unsigned int m_ReadSize;
386 
387  // Consumer thread to notify packet is ready to read
388  IConsumer* m_Consumer = nullptr;
389 };
390 
392 {
393 public:
394  MockSendCounterPacket(IBufferManager& sendBuffer) : m_BufferManager(sendBuffer) {}
395 
396  void SendStreamMetaDataPacket() override
397  {
398  std::string message("SendStreamMetaDataPacket");
399  unsigned int reserved = 0;
400  IPacketBufferPtr buffer = m_BufferManager.Reserve(1024, reserved);
401  memcpy(buffer->GetWritableData(), message.c_str(), static_cast<unsigned int>(message.size()) + 1);
402  m_BufferManager.Commit(buffer, reserved, false);
403  }
404 
405  void SendCounterDirectoryPacket(const ICounterDirectory& counterDirectory) override
406  {
407  IgnoreUnused(counterDirectory);
408 
409  std::string message("SendCounterDirectoryPacket");
410  unsigned int reserved = 0;
411  IPacketBufferPtr buffer = m_BufferManager.Reserve(1024, reserved);
412  memcpy(buffer->GetWritableData(), message.c_str(), static_cast<unsigned int>(message.size()) + 1);
413  m_BufferManager.Commit(buffer, reserved);
414  }
415 
416  void SendPeriodicCounterCapturePacket(uint64_t timestamp,
417  const std::vector<CounterValue>& values) override
418  {
419  IgnoreUnused(timestamp, values);
420 
421  std::string message("SendPeriodicCounterCapturePacket");
422  unsigned int reserved = 0;
423  IPacketBufferPtr buffer = m_BufferManager.Reserve(1024, reserved);
424  memcpy(buffer->GetWritableData(), message.c_str(), static_cast<unsigned int>(message.size()) + 1);
425  m_BufferManager.Commit(buffer, reserved);
426  }
427 
428  void SendPeriodicCounterSelectionPacket(uint32_t capturePeriod,
429  const std::vector<uint16_t>& selectedCounterIds) override
430  {
431  IgnoreUnused(capturePeriod, selectedCounterIds);
432 
433  std::string message("SendPeriodicCounterSelectionPacket");
434  unsigned int reserved = 0;
435  IPacketBufferPtr buffer = m_BufferManager.Reserve(1024, reserved);
436  memcpy(buffer->GetWritableData(), message.c_str(), static_cast<unsigned int>(message.size()) + 1);
437  m_BufferManager.Commit(buffer, reserved);
438  }
439 
440 private:
441  IBufferManager& m_BufferManager;
442 };
443 
445 {
446 public:
447  MockCounterDirectory() = default;
448  ~MockCounterDirectory() = default;
449 
450  // Register profiling objects
451  const Category* RegisterCategory(const std::string& categoryName)
452  {
453  // Create the category
454  CategoryPtr category = std::make_unique<Category>(categoryName);
455  ARMNN_ASSERT(category);
456 
457  // Get the raw category pointer
458  const Category* categoryPtr = category.get();
459  ARMNN_ASSERT(categoryPtr);
460 
461  // Register the category
462  m_Categories.insert(std::move(category));
463 
464  return categoryPtr;
465  }
466 
467  const Device* RegisterDevice(const std::string& deviceName,
468  uint16_t cores = 0)
469  {
470  // Get the device UID
471  uint16_t deviceUid = GetNextUid();
472 
473  // Create the device
474  DevicePtr device = std::make_unique<Device>(deviceUid, deviceName, cores);
475  ARMNN_ASSERT(device);
476 
477  // Get the raw device pointer
478  const Device* devicePtr = device.get();
479  ARMNN_ASSERT(devicePtr);
480 
481  // Register the device
482  m_Devices.insert(std::make_pair(deviceUid, std::move(device)));
483 
484  return devicePtr;
485  }
486 
488  const std::string& counterSetName,
489  uint16_t count = 0)
490  {
491  // Get the counter set UID
492  uint16_t counterSetUid = GetNextUid();
493 
494  // Create the counter set
495  CounterSetPtr counterSet = std::make_unique<CounterSet>(counterSetUid, counterSetName, count);
496  ARMNN_ASSERT(counterSet);
497 
498  // Get the raw counter set pointer
499  const CounterSet* counterSetPtr = counterSet.get();
500  ARMNN_ASSERT(counterSetPtr);
501 
502  // Register the counter set
503  m_CounterSets.insert(std::make_pair(counterSetUid, std::move(counterSet)));
504 
505  return counterSetPtr;
506  }
507 
508  const Counter* RegisterCounter(const BackendId& backendId,
509  const uint16_t uid,
510  const std::string& parentCategoryName,
511  uint16_t counterClass,
512  uint16_t interpolation,
513  double multiplier,
514  const std::string& name,
515  const std::string& description,
517  const armnn::Optional<uint16_t>& numberOfCores = armnn::EmptyOptional(),
518  const armnn::Optional<uint16_t>& deviceUid = armnn::EmptyOptional(),
519  const armnn::Optional<uint16_t>& counterSetUid = armnn::EmptyOptional())
520  {
521  IgnoreUnused(backendId);
522 
523  // Get the number of cores from the argument only
524  uint16_t deviceCores = numberOfCores.has_value() ? numberOfCores.value() : 0;
525 
526  // Get the device UID
527  uint16_t deviceUidValue = deviceUid.has_value() ? deviceUid.value() : 0;
528 
529  // Get the counter set UID
530  uint16_t counterSetUidValue = counterSetUid.has_value() ? counterSetUid.value() : 0;
531 
532  // Get the counter UIDs and calculate the max counter UID
533  std::vector<uint16_t> counterUids = GetNextCounterUids(uid, deviceCores);
534  ARMNN_ASSERT(!counterUids.empty());
535  uint16_t maxCounterUid = deviceCores <= 1 ? counterUids.front() : counterUids.back();
536 
537  // Get the counter units
538  const std::string unitsValue = units.has_value() ? units.value() : "";
539 
540  // Create the counter
541  CounterPtr counter = std::make_shared<Counter>(armnn::profiling::BACKEND_ID,
542  counterUids.front(),
543  maxCounterUid,
544  counterClass,
545  interpolation,
546  multiplier,
547  name,
548  description,
549  unitsValue,
550  deviceUidValue,
551  counterSetUidValue);
552  ARMNN_ASSERT(counter);
553 
554  // Get the raw counter pointer
555  const Counter* counterPtr = counter.get();
556  ARMNN_ASSERT(counterPtr);
557 
558  // Process multiple counters if necessary
559  for (uint16_t counterUid : counterUids)
560  {
561  // Connect the counter to the parent category
562  Category* parentCategory = const_cast<Category*>(GetCategory(parentCategoryName));
563  ARMNN_ASSERT(parentCategory);
564  parentCategory->m_Counters.push_back(counterUid);
565 
566  // Register the counter
567  m_Counters.insert(std::make_pair(counterUid, counter));
568  }
569 
570  return counterPtr;
571  }
572 
573  // Getters for counts
574  uint16_t GetCategoryCount() const override { return armnn::numeric_cast<uint16_t>(m_Categories.size()); }
575  uint16_t GetDeviceCount() const override { return armnn::numeric_cast<uint16_t>(m_Devices.size()); }
576  uint16_t GetCounterSetCount() const override { return armnn::numeric_cast<uint16_t>(m_CounterSets.size()); }
577  uint16_t GetCounterCount() const override { return armnn::numeric_cast<uint16_t>(m_Counters.size()); }
578 
579  // Getters for collections
580  const Categories& GetCategories() const override { return m_Categories; }
581  const Devices& GetDevices() const override { return m_Devices; }
582  const CounterSets& GetCounterSets() const override { return m_CounterSets; }
583  const Counters& GetCounters() const override { return m_Counters; }
584 
585  // Getters for profiling objects
586  const Category* GetCategory(const std::string& name) const override
587  {
588  auto it = std::find_if(m_Categories.begin(), m_Categories.end(), [&name](const CategoryPtr& category)
589  {
590  ARMNN_ASSERT(category);
591 
592  return category->m_Name == name;
593  });
594 
595  if (it == m_Categories.end())
596  {
597  return nullptr;
598  }
599 
600  return it->get();
601  }
602 
603  const Device* GetDevice(uint16_t uid) const override
604  {
605  IgnoreUnused(uid);
606  return nullptr; // Not used by the unit tests
607  }
608 
609  const CounterSet* GetCounterSet(uint16_t uid) const override
610  {
611  IgnoreUnused(uid);
612  return nullptr; // Not used by the unit tests
613  }
614 
615  const Counter* GetCounter(uint16_t uid) const override
616  {
617  IgnoreUnused(uid);
618  return nullptr; // Not used by the unit tests
619  }
620 
621 private:
622  Categories m_Categories;
623  Devices m_Devices;
624  CounterSets m_CounterSets;
625  Counters m_Counters;
626 };
627 
629 {
630 public:
632  bool isProfilingEnabled,
633  const CaptureData& captureData) :
634  m_SendCounterPacket(mockBufferManager),
635  m_IsProfilingEnabled(isProfilingEnabled),
636  m_CaptureData(captureData)
637  {}
638 
639  /// Return the next random Guid in the sequence
640  ProfilingDynamicGuid NextGuid() override
641  {
642  return m_GuidGenerator.NextGuid();
643  }
644 
645  /// Create a ProfilingStaticGuid based on a hash of the string
646  ProfilingStaticGuid GenerateStaticId(const std::string& str) override
647  {
648  return m_GuidGenerator.GenerateStaticId(str);
649  }
650 
651  std::unique_ptr<ISendTimelinePacket> GetSendTimelinePacket() const override
652  {
653  return nullptr;
654  }
655 
656  const ICounterMappings& GetCounterMappings() const override
657  {
658  return m_CounterMapping;
659  }
660 
662  {
663  return m_SendCounterPacket;
664  }
665 
666  bool IsProfilingEnabled() const override
667  {
668  return m_IsProfilingEnabled;
669  }
670 
672  {
673  CaptureData copy(m_CaptureData);
674  return copy;
675  }
676 
677  void RegisterMapping(uint16_t globalCounterId,
678  uint16_t backendCounterId,
679  const armnn::BackendId& backendId)
680  {
681  m_CounterMapping.RegisterMapping(globalCounterId, backendCounterId, backendId);
682  }
683 
684  void Reset()
685  {
686  m_CounterMapping.Reset();
687  }
688 
689 private:
690  ProfilingGuidGenerator m_GuidGenerator;
691  CounterIdMap m_CounterMapping;
692  SendCounterPacket m_SendCounterPacket;
693  bool m_IsProfilingEnabled;
694  CaptureData m_CaptureData;
695 };
696 
698 {
699 public:
700  void NotifyProfilingServiceActive() override {}
701  void WaitForProfilingServiceActivation(unsigned int timeout) override { IgnoreUnused(timeout); }
702 };
703 
704 } // namespace profiling
705 
706 } // namespace armnn
const CounterSet * GetCounterSet(uint16_t uid) const override
IPacketBufferPtr Reserve(unsigned int requestedSize, unsigned int &reservedSize) override
MockStreamCounterBuffer(unsigned int maxBufferSize=4096)
ISendCounterPacket & GetSendCounterPacket() override
const Categories & GetCategories() const override
std::unique_ptr< ISendTimelinePacket > GetSendTimelinePacket() const override
const Devices & GetDevices() const override
void SetConsumer(IConsumer *consumer) override
IPacketBufferPtr GetReadableBuffer() override
std::unordered_map< uint16_t, CounterPtr > Counters
void SendStreamMetaDataPacket() override
Create and write a StreamMetaDataPacket in the buffer.
void Commit(IPacketBufferPtr &packetBuffer, unsigned int size, bool notifyConsumer=true) override
void SendCounterDirectoryPacket(const ICounterDirectory &counterDirectory) override
Create and write a CounterDirectoryPacket from the parameters to the buffer.
std::unique_ptr< Device > DevicePtr
std::unique_ptr< CounterSet > CounterSetPtr
std::unique_ptr< IProfilingConnection > IProfilingConnectionPtr
Copyright (c) 2021 ARM Limited and Contributors.
void IgnoreUnused(Ts &&...)
ProfilingDynamicGuid NextGuid() override
Return the next random Guid in the sequence.
void Commit(IPacketBufferPtr &packetBuffer, unsigned int size, bool notifyConsumer=true) override
void SendPeriodicCounterSelectionPacket(uint32_t capturePeriod, const std::vector< uint16_t > &selectedCounterIds) override
Create and write a PeriodicCounterSelectionPacket from the parameters to the buffer.
void Release(IPacketBufferPtr &packetBuffer) override
std::unordered_map< uint16_t, CounterSetPtr > CounterSets
uint16_t GetNextUid(bool peekOnly)
const Counter * RegisterCounter(const BackendId &backendId, const uint16_t uid, const std::string &parentCategoryName, uint16_t counterClass, uint16_t interpolation, double multiplier, const std::string &name, const std::string &description, const armnn::Optional< std::string > &units=armnn::EmptyOptional(), const armnn::Optional< uint16_t > &numberOfCores=armnn::EmptyOptional(), const armnn::Optional< uint16_t > &deviceUid=armnn::EmptyOptional(), const armnn::Optional< uint16_t > &counterSetUid=armnn::EmptyOptional())
void MarkRead(IPacketBufferPtr &packetBuffer) override
uint16_t GetCategoryCount() const override
unsigned char * GetWritableData() override
arm::pipe::Packet ReadPacket(uint32_t timeout) override
void MarkRead(IPacketBufferPtr &packetBuffer) override
const unsigned char * GetReadableData() const override
std::shared_ptr< Counter > CounterPtr
const CounterSets & GetCounterSets() const override
const ICounterMappings & GetCounterMappings() const override
const Device * RegisterDevice(const std::string &deviceName, uint16_t cores=0)
std::vector< uint16_t > GetNextCounterUids(uint16_t firstUid, uint16_t cores)
IPacketBufferPtr GetReadableBuffer() override
const Category * GetCategory(const std::string &name) const override
unsigned int GetSize() const override
ProfilingStaticGuid GenerateStaticId(const std::string &str) override
Create a ProfilingStaticGuid based on a hash of the string.
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
const Category * RegisterCategory(const std::string &categoryName)
const Counter * GetCounter(uint16_t uid) const override
void SendPeriodicCounterCapturePacket(uint64_t timestamp, const std::vector< CounterValue > &values) override
uint16_t GetCounterCount() const override
bool WritePacket(arm::pipe::Packet &&packet)
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)
uint16_t GetCounterSetCount() const override
std::unordered_set< CategoryPtr > Categories
std::vector< uint16_t > m_Counters
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
Definition: Optional.hpp:32
const Counters & GetCounters() const override
void Destroy() override
release the memory held and reset internal point to null.
MockPacketBuffer(unsigned int maxSize)
std::unique_ptr< Category > CategoryPtr
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
bool WritePacket(const unsigned char *buffer, uint32_t length) override
const CounterSet * RegisterCounterSet(const std::string &counterSetName, uint16_t count=0)
long CheckForPacket(const std::pair< PacketType, uint32_t > packetInfo)
const Device * GetDevice(uint16_t uid) const override
std::unordered_map< uint16_t, DevicePtr > Devices
void SetConsumer(IConsumer *consumer) override
IProfilingConnectionPtr GetProfilingConnection(const ExternalProfilingOptions &options) const override
MockProfilingService(MockBufferManager &mockBufferManager, bool isProfilingEnabled, const CaptureData &captureData)
void WaitForProfilingServiceActivation(unsigned int timeout) override
void Release(IPacketBufferPtr &packetBuffer) override
std::unique_ptr< IPacketBuffer > IPacketBufferPtr
IPacketBufferPtr Reserve(unsigned int requestedSize, unsigned int &reservedSize) override
MockSendCounterPacket(IBufferManager &sendBuffer)
uint16_t GetDeviceCount() const override
void RegisterMapping(uint16_t globalCounterId, uint16_t backendCounterId, const armnn::BackendId &backendId)
void Commit(unsigned int size) override