aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Davis <keith.davis@arm.com>2019-10-24 17:30:41 +0100
committerColm Donelan <colm.donelan@arm.com>2019-11-06 08:30:31 +0000
commit3201eea0565ce2bb0418d1936fec71bdeb14c084 (patch)
treef73017f6338d707165dbcfd717ddc9793b1858e0
parentfe2e2cbbbe5294072b2d58755b8a095f32a97e75 (diff)
downloadarmnn-3201eea0565ce2bb0418d1936fec71bdeb14c084.tar.gz
IVGCVSW-3444 File Only Profiling Connection
* Add FileOnlyProfilingConnection Decorator * Fix bug where Conn Ack not automatically sent back * Modify GatordMock to use the Counter Directory class. * Promote DirectoryCaptureCommandHandler from GatordMock into ArmNN. * Remove MockUtils as it's contents were moved or deleted. * Rewrite GatordMockTests to use Counter Directory class. * Flush streams in ProfilingConnectionDumpToFileDecorator::Close. Signed-off-by: Keith Davis <keith.davis@arm.com> Signed-off-by: Colm Donelan <Colm.Donelan@arm.com> Change-Id: I77b2aedece24150dd31691b577f3b5d81b2e226f
-rw-r--r--Android.mk2
-rw-r--r--CMakeLists.txt9
-rw-r--r--src/profiling/ConnectionAcknowledgedCommandHandler.cpp5
-rw-r--r--src/profiling/ConnectionAcknowledgedCommandHandler.hpp10
-rw-r--r--src/profiling/DirectoryCaptureCommandHandler.cpp (renamed from tests/profiling/gatordmock/DirectoryCaptureCommandHandler.cpp)133
-rw-r--r--src/profiling/DirectoryCaptureCommandHandler.hpp84
-rw-r--r--src/profiling/FileOnlyProfilingConnection.cpp216
-rw-r--r--src/profiling/FileOnlyProfilingConnection.hpp82
-rw-r--r--src/profiling/ProfilingConnectionDumpToFileDecorator.cpp2
-rw-r--r--src/profiling/ProfilingConnectionDumpToFileDecorator.hpp2
-rw-r--r--src/profiling/ProfilingConnectionFactory.cpp30
-rw-r--r--src/profiling/ProfilingConnectionFactory.hpp6
-rw-r--r--src/profiling/ProfilingService.hpp2
-rw-r--r--src/profiling/ProfilingUtils.cpp221
-rw-r--r--src/profiling/ProfilingUtils.hpp28
-rw-r--r--src/profiling/test/FileOnlyProfilingDecoratorTests.cpp111
-rw-r--r--src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp1
-rw-r--r--src/profiling/test/ProfilingTests.cpp964
-rw-r--r--tests/profiling/gatordmock/DirectoryCaptureCommandHandler.hpp75
-rw-r--r--tests/profiling/gatordmock/GatordMockMain.cpp4
-rw-r--r--tests/profiling/gatordmock/GatordMockService.cpp23
-rw-r--r--tests/profiling/gatordmock/MockUtils.cpp57
-rw-r--r--tests/profiling/gatordmock/MockUtils.hpp25
-rw-r--r--tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp17
-rw-r--r--tests/profiling/gatordmock/tests/GatordMockTests.cpp142
25 files changed, 1339 insertions, 912 deletions
diff --git a/Android.mk b/Android.mk
index dbc999e651..d8ffdd8720 100644
--- a/Android.mk
+++ b/Android.mk
@@ -178,6 +178,8 @@ LOCAL_SRC_FILES := \
src/profiling/CommandHandlerRegistry.cpp \
src/profiling/ConnectionAcknowledgedCommandHandler.cpp \
src/profiling/CounterDirectory.cpp \
+ src/profiling/DirectoryCaptureCommandHandler.cpp \
+ src/profiling/FileOnlyProfilingConnection.cpp \
src/profiling/Holder.cpp \
src/profiling/LabelsAndEventClasses.cpp \
src/profiling/PacketBuffer.cpp \
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b66ed5fe4c..867fb34071 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -451,7 +451,11 @@ list(APPEND armnn_sources
src/profiling/ConnectionAcknowledgedCommandHandler.hpp
src/profiling/CounterDirectory.cpp
src/profiling/CounterDirectory.hpp
+ src/profiling/DirectoryCaptureCommandHandler.cpp
+ src/profiling/DirectoryCaptureCommandHandler.hpp
src/profiling/EncodeVersion.hpp
+ src/profiling/FileOnlyProfilingConnection.cpp
+ src/profiling/FileOnlyProfilingConnection.hpp
src/profiling/Holder.cpp
src/profiling/Holder.hpp
src/profiling/IBufferManager.hpp
@@ -624,6 +628,7 @@ if(BUILD_UNIT_TESTS)
src/armnnUtils/test/ParserHelperTest.cpp
src/armnnUtils/test/TensorUtilsTest.cpp
src/profiling/test/BufferTests.cpp
+ src/profiling/test/FileOnlyProfilingDecoratorTests.cpp
src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
src/profiling/test/ProfilingGuidTest.cpp
src/profiling/test/ProfilingTests.cpp
@@ -925,12 +930,8 @@ if(BUILD_GATORD_MOCK)
tests/profiling/gatordmock/CommandFileParser.cpp
tests/profiling/gatordmock/CommandLineProcessor.hpp
tests/profiling/gatordmock/CommandLineProcessor.cpp
- tests/profiling/gatordmock/CounterDirectory.hpp
- tests/profiling/gatordmock/DirectoryCaptureCommandHandler.cpp
- tests/profiling/gatordmock/DirectoryCaptureCommandHandler.hpp
tests/profiling/gatordmock/GatordMockService.hpp
tests/profiling/gatordmock/GatordMockService.cpp
- tests/profiling/gatordmock/MockUtils.cpp
tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp
tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp
tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.cpp
diff --git a/src/profiling/ConnectionAcknowledgedCommandHandler.cpp b/src/profiling/ConnectionAcknowledgedCommandHandler.cpp
index deffd1414b..a0825c7ba7 100644
--- a/src/profiling/ConnectionAcknowledgedCommandHandler.cpp
+++ b/src/profiling/ConnectionAcknowledgedCommandHandler.cpp
@@ -38,6 +38,11 @@ void ConnectionAcknowledgedCommandHandler::operator()(const Packet& packet)
// Once a Connection Acknowledged packet has been received, move to the Active state immediately
m_StateMachine.TransitionToState(ProfilingState::Active);
+ m_SendCounterPacket.SendCounterDirectoryPacket(m_CounterDirectory);
+
+ // Notify the Send Thread that new data is available in the Counter Stream Buffer
+ m_SendCounterPacket.SetReadyToRead();
+
break;
case ProfilingState::Active:
return; // NOP
diff --git a/src/profiling/ConnectionAcknowledgedCommandHandler.hpp b/src/profiling/ConnectionAcknowledgedCommandHandler.hpp
index 255fcf645a..7e7904de0f 100644
--- a/src/profiling/ConnectionAcknowledgedCommandHandler.hpp
+++ b/src/profiling/ConnectionAcknowledgedCommandHandler.hpp
@@ -6,6 +6,7 @@
#pragma once
#include "CommandHandlerFunctor.hpp"
+#include "ISendCounterPacket.hpp"
#include "Packet.hpp"
#include "ProfilingStateMachine.hpp"
@@ -22,15 +23,22 @@ public:
ConnectionAcknowledgedCommandHandler(uint32_t familyId,
uint32_t packetId,
uint32_t version,
+ ICounterDirectory& counterDirectory,
+ ISendCounterPacket& sendCounterPacket,
ProfilingStateMachine& profilingStateMachine)
: CommandHandlerFunctor(familyId, packetId, version)
+ , m_CounterDirectory(counterDirectory)
+ , m_SendCounterPacket(sendCounterPacket)
, m_StateMachine(profilingStateMachine)
{}
void operator()(const Packet& packet) override;
private:
- ProfilingStateMachine& m_StateMachine;
+ const ICounterDirectory& m_CounterDirectory;
+ ISendCounterPacket& m_SendCounterPacket;
+ ProfilingStateMachine& m_StateMachine;
+
};
} // namespace profiling
diff --git a/tests/profiling/gatordmock/DirectoryCaptureCommandHandler.cpp b/src/profiling/DirectoryCaptureCommandHandler.cpp
index eafef0b53c..22d1e6d0dd 100644
--- a/tests/profiling/gatordmock/DirectoryCaptureCommandHandler.cpp
+++ b/src/profiling/DirectoryCaptureCommandHandler.cpp
@@ -3,13 +3,15 @@
// SPDX-License-Identifier: MIT
//
-#include <atomic>
#include "DirectoryCaptureCommandHandler.hpp"
+#include "SendCounterPacket.hpp"
+
+#include <iostream>
namespace armnn
{
-namespace gatordmock
+namespace profiling
{
// Utils
@@ -30,7 +32,7 @@ void DirectoryCaptureCommandHandler::ParseData(const armnn::profiling::Packet& p
return;
}
- const unsigned char* data = reinterpret_cast<const unsigned char*>(packet.GetData());
+ const unsigned char* data = packet.GetData();
// Body header word 0:
// 0:15 [16] reserved: all zeros
offset += uint16_t_size;
@@ -89,29 +91,15 @@ void DirectoryCaptureCommandHandler::ParseData(const armnn::profiling::Packet& p
offset += uint32_t_size;
}
- m_CounterDirectory.m_DeviceRecords = ReadDeviceRecords(data, offset, deviceRecordOffsets);
- m_CounterDirectory.m_CounterSets = ReadCounterSetRecords(data, offset, counterSetOffsets);
- m_CounterDirectory.m_Categories = ReadCategoryRecords(data, offset, categoryOffsets);
-
- m_CounterDirectoryCount.operator++(std::memory_order_release);
-}
-
-std::vector<DeviceRecord> DirectoryCaptureCommandHandler::ReadDeviceRecords(const unsigned char* const data,
- uint32_t offset,
- std::vector<uint32_t> deviceRecordOffsets)
-{
- uint32_t deviceRecordCount = static_cast<uint32_t >(deviceRecordOffsets.size());
- std::vector<DeviceRecord> deviceRecords(deviceRecordCount);
-
- for(uint32_t deviceIndex = 0; deviceIndex < deviceRecordCount; ++deviceIndex)
+ for (uint32_t deviceIndex = 0; deviceIndex < deviceRecordCount; ++deviceIndex)
{
uint32_t deviceRecordOffset = offset + deviceRecordOffsets[deviceIndex];
// Device record word 0:
// 0:15 [16] cores: the number of individual streams of counters for one or more cores of some device
- deviceRecords[deviceIndex].m_DeviceCores = profiling::ReadUint16(data, deviceRecordOffset);
+ uint16_t deviceCores = profiling::ReadUint16(data, deviceRecordOffset);
// 16:31 [16] deviceUid: the unique identifier for the device
deviceRecordOffset += uint16_t_size;
- deviceRecords[deviceIndex].m_DeviceUid = profiling::ReadUint16(data, deviceRecordOffset);
+ uint16_t deviceUid = profiling::ReadUint16(data, deviceRecordOffset);
deviceRecordOffset += uint16_t_size;
// Device record word 1:
@@ -122,32 +110,22 @@ std::vector<DeviceRecord> DirectoryCaptureCommandHandler::ReadDeviceRecords(cons
deviceRecordOffset += uint32_t_size;
deviceRecordOffset += nameOffset;
- deviceRecords[deviceIndex].m_DeviceName = GetStringNameFromBuffer(data, deviceRecordOffset);
+ const std::string& deviceName = GetStringNameFromBuffer(data, deviceRecordOffset);
+ const Device* registeredDevice = m_CounterDirectory.RegisterDevice(deviceName, deviceCores);
+ m_UidTranslation[registeredDevice->m_Uid] = deviceUid;
}
- return deviceRecords;
-}
-
-
-std::vector<CounterSetRecord>
- DirectoryCaptureCommandHandler::ReadCounterSetRecords(const unsigned char* const data,
- uint32_t offset,
- std::vector<uint32_t> counterSetOffsets)
-{
- uint32_t counterSetRecordCount = static_cast<uint32_t >(counterSetOffsets.size());
- std::vector<CounterSetRecord> counterSets(counterSetRecordCount);
-
for (uint32_t counterSetIndex = 0; counterSetIndex < counterSetRecordCount; ++counterSetIndex)
{
uint32_t counterSetOffset = offset + counterSetOffsets[counterSetIndex];
// Counter set record word 0:
// 0:15 [16] count: the number of counters which can be active in this set at any one time
- counterSets[counterSetIndex].m_CounterSetCount = profiling::ReadUint16(data, counterSetOffset);
+ uint16_t counterSetCount = profiling::ReadUint16(data, counterSetOffset);
counterSetOffset += uint16_t_size;
// 16:31 [16] deviceUid: the unique identifier for the counter_set
- counterSets[counterSetIndex].m_CounterSetUid = profiling::ReadUint16(data, counterSetOffset);
+ uint16_t counterSetUid = profiling::ReadUint16(data, counterSetOffset);
counterSetOffset += uint16_t_size;
// Counter set record word 1:
@@ -156,18 +134,18 @@ std::vector<CounterSetRecord>
counterSetOffset += uint32_t_size;
counterSetOffset += uint32_t_size;
- counterSets[counterSetIndex].m_CounterSetName = GetStringNameFromBuffer(data, counterSetOffset);
+ auto counterSet =
+ m_CounterDirectory.RegisterCounterSet(GetStringNameFromBuffer(data, counterSetOffset), counterSetCount);
+ m_UidTranslation[counterSet->m_Uid] = counterSetUid;
}
-
- return counterSets;
+ ReadCategoryRecords(data, offset, categoryOffsets);
}
-std::vector<CategoryRecord> DirectoryCaptureCommandHandler::ReadCategoryRecords(const unsigned char* const data,
- uint32_t offset,
- std::vector<uint32_t> categoryOffsets)
+void DirectoryCaptureCommandHandler::ReadCategoryRecords(const unsigned char* const data,
+ uint32_t offset,
+ std::vector<uint32_t> categoryOffsets)
{
- uint32_t categoryRecordCount = static_cast<uint32_t >(categoryOffsets.size());
- std::vector<CategoryRecord> categories(categoryRecordCount);
+ uint32_t categoryRecordCount = static_cast<uint32_t>(categoryOffsets.size());
for (uint32_t categoryIndex = 0; categoryIndex < categoryRecordCount; ++categoryIndex)
{
@@ -176,19 +154,20 @@ std::vector<CategoryRecord> DirectoryCaptureCommandHandler::ReadCategoryRecords(
// Category record word 0:
// 0:15 The deviceUid of a counter_set the category is associated with.
// Set to zero if the category is NOT associated with a counter set.
- categories[categoryIndex].m_CounterSet = profiling::ReadUint16(data, categoryRecordOffset);
+ uint16_t counterSetUid = profiling::ReadUint16(data, categoryRecordOffset);
categoryRecordOffset += uint16_t_size;
// 16:31 The deviceUid of a device element which identifies some hardware device that the category belongs to.
// Set to zero if the category is NOT associated with a device
- categories[categoryIndex].m_DeviceUid = profiling::ReadUint16(data, categoryRecordOffset);
+ uint16_t deviceUid = profiling::ReadUint16(data, categoryRecordOffset);
+
categoryRecordOffset += uint16_t_size;
// Category record word 1:
// 0:15 Reserved, value 0x0000.
categoryRecordOffset += uint16_t_size;
// 16:31 Number of events belonging to this category.
- categories[categoryIndex].m_EventCount = profiling::ReadUint16(data, categoryRecordOffset);
+ uint32_t eventCount = profiling::ReadUint16(data, categoryRecordOffset);
categoryRecordOffset += uint16_t_size;
// Category record word 2
@@ -201,9 +180,6 @@ std::vector<CategoryRecord> DirectoryCaptureCommandHandler::ReadCategoryRecords(
uint32_t nameOffset = profiling::ReadUint32(data, categoryRecordOffset);
categoryRecordOffset += uint32_t_size;
- //Get the events for the category
- uint32_t eventCount = categories[categoryIndex].m_EventCount;
-
std::vector<uint32_t> eventRecordsOffsets(eventCount);
eventPointerTableOffset += categoryRecordOffset;
@@ -211,27 +187,31 @@ std::vector<CategoryRecord> DirectoryCaptureCommandHandler::ReadCategoryRecords(
for (uint32_t eventIndex = 0; eventIndex < eventCount; ++eventIndex)
{
eventRecordsOffsets[eventIndex] =
- profiling::ReadUint32(data, eventPointerTableOffset + uint32_t_size * eventIndex);
+ profiling::ReadUint32(data, eventPointerTableOffset + uint32_t_size * eventIndex);
}
- categories[categoryIndex].m_EventRecords = ReadEventRecords(data, categoryRecordOffset, eventRecordsOffsets);
-
+ const std::vector<CounterDirectoryEventRecord>& eventRecords =
+ ReadEventRecords(data, categoryRecordOffset, eventRecordsOffsets);
categoryRecordOffset += uint32_t_size;
- categories[categoryIndex].m_CategoryName = GetStringNameFromBuffer(data, categoryRecordOffset + nameOffset);
+ const Category* category = m_CounterDirectory.RegisterCategory(
+ GetStringNameFromBuffer(data, categoryRecordOffset + nameOffset), deviceUid, counterSetUid);
+ for (auto& counter : eventRecords)
+ {
+ const Counter* registeredCounter = m_CounterDirectory.RegisterCounter(
+ category->m_Name, counter.m_CounterClass, counter.m_CounterInterpolation, counter.m_CounterMultiplier,
+ counter.m_CounterName, counter.m_CounterDescription, counter.m_CounterUnits);
+ m_UidTranslation[registeredCounter->m_Uid] = counter.m_CounterUid;
+ }
}
-
- return categories;
}
-
-std::vector<EventRecord> DirectoryCaptureCommandHandler::ReadEventRecords(const unsigned char* const data,
- uint32_t offset,
- std::vector<uint32_t> eventRecordsOffsets)
+std::vector<CounterDirectoryEventRecord> DirectoryCaptureCommandHandler::ReadEventRecords(
+ const unsigned char* data, uint32_t offset, std::vector<uint32_t> eventRecordsOffsets)
{
uint32_t eventCount = static_cast<uint32_t>(eventRecordsOffsets.size());
- std::vector<EventRecord> eventRecords(eventCount);
+ std::vector<CounterDirectoryEventRecord> eventRecords(eventCount);
for (unsigned long i = 0; i < eventCount; ++i)
{
uint32_t eventRecordOffset = eventRecordsOffsets[i] + offset;
@@ -261,7 +241,7 @@ std::vector<EventRecord> DirectoryCaptureCommandHandler::ReadEventRecords(const
// Event record word 2:
// 0:15 [16] interpolation: type describing how to interpolate each data point in a stream of data points
- eventRecords[i].m_CounterClass =profiling::ReadUint16(data, eventRecordOffset);
+ eventRecords[i].m_CounterClass = profiling::ReadUint16(data, eventRecordOffset);
eventRecordOffset += uint16_t_size;
// 16:31 [16] class: type describing how to treat each data point in a stream of data points
@@ -313,29 +293,44 @@ std::vector<EventRecord> DirectoryCaptureCommandHandler::ReadEventRecords(const
void DirectoryCaptureCommandHandler::operator()(const profiling::Packet& packet)
{
- if (!m_QuietOperation)// Are we supposed to print to stdout?
+ if (!m_QuietOperation) // Are we supposed to print to stdout?
{
std::cout << "Counter directory packet received." << std::endl;
}
- ParseData(packet);
+ // The ArmNN counter directory is static per ArmNN instance. Ensure we don't parse it a second time.
+ if (!ParsedCounterDirectory())
+ {
+ ParseData(packet);
+ m_AlreadyParsed = true;
+ }
if (!m_QuietOperation)
{
- m_CounterDirectory.print();
+ armnn::profiling::PrintCounterDirectory(m_CounterDirectory);
}
}
-CounterDirectory DirectoryCaptureCommandHandler::GetCounterDirectory() const
+const ICounterDirectory& DirectoryCaptureCommandHandler::GetCounterDirectory() const
{
return m_CounterDirectory;
}
-uint32_t DirectoryCaptureCommandHandler::GetCounterDirectoryCount() const
+std::string DirectoryCaptureCommandHandler::GetStringNameFromBuffer(const unsigned char* const data, uint32_t offset)
{
- return m_CounterDirectoryCount.load(std::memory_order_acquire);
+ std::string deviceName;
+ u_char nextChar = profiling::ReadUint8(data, offset);
+
+ while (isprint(nextChar))
+ {
+ deviceName += static_cast<char>(nextChar);
+ offset++;
+ nextChar = profiling::ReadUint8(data, offset);
+ }
+
+ return deviceName;
}
-} // namespace gatordmock
+} // namespace profiling
-} // namespace armnn \ No newline at end of file
+} // namespace armnn \ No newline at end of file
diff --git a/src/profiling/DirectoryCaptureCommandHandler.hpp b/src/profiling/DirectoryCaptureCommandHandler.hpp
new file mode 100644
index 0000000000..03bbb1eb09
--- /dev/null
+++ b/src/profiling/DirectoryCaptureCommandHandler.hpp
@@ -0,0 +1,84 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "CommandHandlerFunctor.hpp"
+#include "CounterDirectory.hpp"
+
+#include <atomic>
+
+namespace armnn
+{
+
+namespace profiling
+{
+
+struct CounterDirectoryEventRecord
+{
+ uint16_t m_CounterClass;
+ std::string m_CounterDescription;
+ uint16_t m_CounterInterpolation;
+ double m_CounterMultiplier;
+ std::string m_CounterName;
+ uint16_t m_CounterSetUid;
+ uint16_t m_CounterUid;
+ std::string m_CounterUnits;
+ uint16_t m_DeviceUid;
+ uint16_t m_MaxCounterUid;
+};
+
+class DirectoryCaptureCommandHandler : public profiling::CommandHandlerFunctor
+{
+
+public:
+ DirectoryCaptureCommandHandler(uint32_t familyId, uint32_t packetId, uint32_t version, bool quietOperation = true)
+ : CommandHandlerFunctor(familyId, packetId, version)
+ , m_QuietOperation(quietOperation)
+ , m_AlreadyParsed(false)
+ {}
+
+ void operator()(const armnn::profiling::Packet& packet) override;
+
+ const ICounterDirectory& GetCounterDirectory() const;
+
+ bool ParsedCounterDirectory()
+ {
+ return m_AlreadyParsed.load();
+ }
+
+ /**
+ * Given a Uid that came from a copy of the counter directory translate it to the original.
+ *
+ * @param copyUid
+ * @return the original Uid that the copy maps to.
+ */
+ uint16_t TranslateUIDCopyToOriginal(uint16_t copyUid)
+ {
+ return m_UidTranslation[copyUid];
+ }
+
+private:
+ void ParseData(const armnn::profiling::Packet& packet);
+
+ void ReadCategoryRecords(const unsigned char* data, uint32_t offset, std::vector<uint32_t> categoryOffsets);
+
+ std::vector<CounterDirectoryEventRecord>
+ ReadEventRecords(const unsigned char* data, uint32_t offset, std::vector<uint32_t> eventRecordsOffsets);
+
+ std::string GetStringNameFromBuffer(const unsigned char* data, uint32_t offset);
+ bool IsValidChar(unsigned char c);
+
+ CounterDirectory m_CounterDirectory;
+ std::unordered_map<uint16_t, uint16_t> m_UidTranslation;
+ bool m_QuietOperation;
+ // We can only parse the counter directory once per instance. It won't change anyway as it's static
+ // per instance of ArmNN.
+ std::atomic<bool> m_AlreadyParsed;
+};
+
+} // namespace profiling
+
+} // namespace armnn
diff --git a/src/profiling/FileOnlyProfilingConnection.cpp b/src/profiling/FileOnlyProfilingConnection.cpp
new file mode 100644
index 0000000000..b32ae49911
--- /dev/null
+++ b/src/profiling/FileOnlyProfilingConnection.cpp
@@ -0,0 +1,216 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "FileOnlyProfilingConnection.hpp"
+#include "PacketVersionResolver.hpp"
+
+#include <armnn/Exceptions.hpp>
+
+#include <boost/numeric/conversion/cast.hpp>
+#include <iostream>
+#include <thread>
+
+namespace armnn
+{
+
+namespace profiling
+{
+
+FileOnlyProfilingConnection::~FileOnlyProfilingConnection()
+{
+ Close();
+}
+
+bool FileOnlyProfilingConnection::IsOpen() const
+{
+ // This type of connection is always open.
+ return true;
+}
+
+void FileOnlyProfilingConnection::Close()
+{
+ // Dump any unread packets out of the queue.
+ for (unsigned int i = 0; i < m_PacketQueue.size(); i++)
+ {
+ m_PacketQueue.pop();
+ }
+}
+
+bool FileOnlyProfilingConnection::WaitForStreamMeta(const unsigned char* buffer, uint32_t length)
+{
+ // The first word, stream_metadata_identifer, should always be 0.
+ if (ToUint32(buffer, TargetEndianness::BeWire) != 0)
+ {
+ Fail("Protocol error. The stream_metadata_identifer was not 0.");
+ }
+
+ // Before we interpret the length we need to read the pipe_magic word to determine endianness.
+ if (ToUint32(buffer + 8, TargetEndianness::BeWire) == PIPE_MAGIC)
+ {
+ m_Endianness = TargetEndianness::BeWire;
+ }
+ else if (ToUint32(buffer + 8, TargetEndianness::LeWire) == PIPE_MAGIC)
+ {
+ m_Endianness = TargetEndianness::LeWire;
+ }
+ else
+ {
+ Fail("Protocol read error. Unable to read PIPE_MAGIC value.");
+ }
+ return true;
+}
+
+void FileOnlyProfilingConnection::SendConnectionAck()
+{
+ if (!m_QuietOp)
+ {
+ std::cout << "Sending connection acknowledgement." << std::endl;
+ }
+ std::unique_ptr<unsigned char[]> uniqueNullPtr = nullptr;
+ m_PacketQueue.push(Packet(0x10000, 0, uniqueNullPtr));
+}
+
+bool FileOnlyProfilingConnection::SendCounterSelectionPacket()
+{
+ uint32_t uint16_t_size = sizeof(uint16_t);
+ uint32_t uint32_t_size = sizeof(uint32_t);
+
+ uint32_t offset = 0;
+ uint32_t bodySize = uint32_t_size + boost::numeric_cast<uint32_t>(m_IdList.size()) * uint16_t_size;
+
+ auto uniqueData = std::make_unique<unsigned char[]>(bodySize);
+ unsigned char* data = reinterpret_cast<unsigned char*>(uniqueData.get());
+
+ // Copy capturePeriod
+ WriteUint32(data, offset, m_Options.m_CapturePeriod);
+
+ // Copy m_IdList
+ offset += uint32_t_size;
+ for (const uint16_t& id : m_IdList)
+ {
+ WriteUint16(data, offset, id);
+ offset += uint16_t_size;
+ }
+
+ m_PacketQueue.push(Packet(0x40000, bodySize, uniqueData));
+
+ return true;
+}
+
+bool FileOnlyProfilingConnection::WritePacket(const unsigned char* buffer, uint32_t length)
+{
+ BOOST_ASSERT(buffer);
+
+ // Read Header and determine case
+ uint32_t outgoingHeaderAsWords[2];
+ PackageActivity packageActivity = GetPackageActivity(buffer, outgoingHeaderAsWords);
+
+ switch (packageActivity)
+ {
+ case PackageActivity::StreamMetaData:
+ {
+ if (!WaitForStreamMeta(buffer, length))
+ {
+ return EXIT_FAILURE;
+ }
+
+ SendConnectionAck();
+ break;
+ }
+ case PackageActivity::CounterDirectory:
+ {
+ std::unique_ptr<unsigned char[]> uniqueCounterData = std::make_unique<unsigned char[]>(length - 8);
+
+ std::memcpy(uniqueCounterData.get(), buffer + 8, length - 8);
+
+ Packet directoryPacket(outgoingHeaderAsWords[0], length - 8, uniqueCounterData);
+
+ armnn::profiling::PacketVersionResolver packetVersionResolver;
+ DirectoryCaptureCommandHandler directoryCaptureCommandHandler(
+ 0, 2, packetVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue());
+ directoryCaptureCommandHandler.operator()(directoryPacket);
+ const ICounterDirectory& counterDirectory = directoryCaptureCommandHandler.GetCounterDirectory();
+ for (auto& category : counterDirectory.GetCategories())
+ {
+ // Remember we need to translate the Uid's from our CounterDirectory instance to the parent one.
+ std::vector<uint16_t> translatedCounters;
+ for (auto const& copyUid : category->m_Counters)
+ {
+ translatedCounters.emplace_back(directoryCaptureCommandHandler.TranslateUIDCopyToOriginal(copyUid));
+ }
+ m_IdList.insert(std::end(m_IdList), std::begin(translatedCounters), std::end(translatedCounters));
+ }
+ SendCounterSelectionPacket();
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ return true;
+}
+
+Packet FileOnlyProfilingConnection::ReadPacket(uint32_t timeout)
+{
+ uint16_t loopCount = 10;
+ uint32_t timeoutFraction = timeout / loopCount;
+ while (m_PacketQueue.empty())
+ {
+ std::this_thread::sleep_for(std::chrono::milliseconds(timeoutFraction));
+ --loopCount;
+ if ((loopCount) == 0)
+ {
+ throw armnn::TimeoutException("Thread has timed out as per requested time limit");
+ }
+ }
+ Packet returnedPacket = std::move(m_PacketQueue.front());
+ m_PacketQueue.pop();
+ return returnedPacket;
+}
+
+PackageActivity FileOnlyProfilingConnection::GetPackageActivity(const unsigned char* buffer, uint32_t headerAsWords[2])
+{
+ headerAsWords[0] = ToUint32(buffer, m_Endianness);
+ headerAsWords[1] = ToUint32(buffer + 4, m_Endianness);
+ if (headerAsWords[0] == 0x20000) // Packet family = 0 Packet Id = 2
+ {
+ return PackageActivity::CounterDirectory;
+ }
+ else if (headerAsWords[0] == 0) // Packet family = 0 Packet Id = 0
+ {
+ return PackageActivity::StreamMetaData;
+ }
+ else
+ {
+ return PackageActivity::Unknown;
+ }
+}
+
+uint32_t FileOnlyProfilingConnection::ToUint32(const unsigned char* data, TargetEndianness endianness)
+{
+ // Extract the first 4 bytes starting at data and push them into a 32bit integer based on the
+ // specified endianness.
+ if (endianness == TargetEndianness::BeWire)
+ {
+ return static_cast<uint32_t>(data[0]) << 24 | static_cast<uint32_t>(data[1]) << 16 |
+ static_cast<uint32_t>(data[2]) << 8 | static_cast<uint32_t>(data[3]);
+ }
+ else
+ {
+ return static_cast<uint32_t>(data[3]) << 24 | static_cast<uint32_t>(data[2]) << 16 |
+ static_cast<uint32_t>(data[1]) << 8 | static_cast<uint32_t>(data[0]);
+ }
+}
+
+void FileOnlyProfilingConnection::Fail(const std::string& errorMessage)
+{
+ Close();
+ throw RuntimeException(errorMessage);
+}
+
+} // namespace profiling
+
+} // namespace armnn
diff --git a/src/profiling/FileOnlyProfilingConnection.hpp b/src/profiling/FileOnlyProfilingConnection.hpp
new file mode 100644
index 0000000000..12a87a1535
--- /dev/null
+++ b/src/profiling/FileOnlyProfilingConnection.hpp
@@ -0,0 +1,82 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "CounterDirectory.hpp"
+#include "DirectoryCaptureCommandHandler.hpp"
+#include "IProfilingConnection.hpp"
+#include "ProfilingUtils.hpp"
+#include "Runtime.hpp"
+
+#include <fstream>
+#include <queue>
+
+namespace armnn
+{
+
+namespace profiling
+{
+
+enum class TargetEndianness
+{
+ BeWire,
+ LeWire
+};
+
+enum class PackageActivity
+{
+ StreamMetaData,
+ CounterDirectory,
+ Unknown
+};
+
+class FileOnlyProfilingConnection : public IProfilingConnection
+{
+public:
+ FileOnlyProfilingConnection(const Runtime::CreationOptions::ExternalProfilingOptions& options,
+ const bool quietOp = true)
+ : m_Options(options)
+ , m_QuietOp(quietOp)
+ , m_Endianness(TargetEndianness::LeWire) // Set a sensible default. WaitForStreamMeta will set a real value.
+ {};
+
+ ~FileOnlyProfilingConnection();
+
+ bool IsOpen() const override;
+
+ void Close() override;
+
+ // This is effectively receiving a data packet from ArmNN.
+ bool WritePacket(const unsigned char* buffer, uint32_t length) override;
+
+ // Sending a packet back to ArmNN.
+ Packet ReadPacket(uint32_t timeout) override;
+
+private:
+ bool WaitForStreamMeta(const unsigned char* buffer, uint32_t length);
+
+ uint32_t ToUint32(const unsigned char* data, TargetEndianness endianness);
+
+ void SendConnectionAck();
+
+ bool SendCounterSelectionPacket();
+
+ PackageActivity GetPackageActivity(const unsigned char* buffer, uint32_t headerAsWords[2]);
+
+ void Fail(const std::string& errorMessage);
+
+ static const uint32_t PIPE_MAGIC = 0x45495434;
+
+ Runtime::CreationOptions::ExternalProfilingOptions m_Options;
+ bool m_QuietOp;
+ std::vector<uint16_t> m_IdList;
+ std::queue<Packet> m_PacketQueue;
+ TargetEndianness m_Endianness;
+};
+
+} // namespace profiling
+
+} // namespace armnn \ No newline at end of file
diff --git a/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp b/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp
index 5a14aa864e..d61911b54e 100644
--- a/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp
+++ b/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp
@@ -43,7 +43,9 @@ bool ProfilingConnectionDumpToFileDecorator::IsOpen() const
void ProfilingConnectionDumpToFileDecorator::Close()
{
+ m_IncomingDumpFileStream.flush();
m_IncomingDumpFileStream.close();
+ m_OutgoingDumpFileStream.flush();
m_OutgoingDumpFileStream.close();
m_Connection->Close();
}
diff --git a/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp b/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp
index 450c38a243..545c57f728 100644
--- a/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp
+++ b/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp
@@ -28,7 +28,7 @@ public:
ProfilingConnectionDumpToFileDecorator(std::unique_ptr<IProfilingConnection> connection,
const Runtime::CreationOptions::ExternalProfilingOptions& options,
- bool ignoreFailures);
+ bool ignoreFailures = false);
~ProfilingConnectionDumpToFileDecorator();
diff --git a/src/profiling/ProfilingConnectionFactory.cpp b/src/profiling/ProfilingConnectionFactory.cpp
index 759eb7a95e..4af81a024e 100644
--- a/src/profiling/ProfilingConnectionFactory.cpp
+++ b/src/profiling/ProfilingConnectionFactory.cpp
@@ -1,11 +1,13 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "ProfilingConnectionFactory.hpp"
-#include "SocketProfilingConnection.hpp"
+
+#include "FileOnlyProfilingConnection.hpp"
#include "ProfilingConnectionDumpToFileDecorator.hpp"
+#include "SocketProfilingConnection.hpp"
namespace armnn
{
@@ -16,19 +18,31 @@ namespace profiling
std::unique_ptr<IProfilingConnection> ProfilingConnectionFactory::GetProfilingConnection(
const Runtime::CreationOptions::ExternalProfilingOptions& options) const
{
- if ( !options.m_IncomingCaptureFile.empty() || !options.m_OutgoingCaptureFile.empty() )
+ // We can create 3 different types of IProfilingConnection.
+ // 1: If no relevant options are specified then a SocketProfilingConnection is returned.
+ // 2: If both incoming and outgoing capture files are specified then a SocketProfilingConnection decorated by a
+ // ProfilingConnectionDumpToFileDecorator is returned.
+ // 3: If both incoming and outgoing capture files are specified and "file only" then a FileOnlyProfilingConnection
+ // decorated by a ProfilingConnectionDumpToFileDecorator is returned.
+ if ((!options.m_IncomingCaptureFile.empty() || !options.m_OutgoingCaptureFile.empty()) && !options.m_FileOnly)
{
- bool ignoreFailures = false;
+ // This is type 2.
return std::make_unique<ProfilingConnectionDumpToFileDecorator>(std::make_unique<SocketProfilingConnection>(),
- options,
- ignoreFailures);
+ options);
+ }
+ else if ((!options.m_IncomingCaptureFile.empty() || !options.m_OutgoingCaptureFile.empty()) && options.m_FileOnly)
+ {
+ // This is type 3.
+ return std::make_unique<ProfilingConnectionDumpToFileDecorator>(
+ std::make_unique<FileOnlyProfilingConnection>(options), options);
}
else
{
+ // This is type 1.
return std::make_unique<SocketProfilingConnection>();
}
}
-} // namespace profiling
+} // namespace profiling
-} // namespace armnn
+} // namespace armnn
diff --git a/src/profiling/ProfilingConnectionFactory.hpp b/src/profiling/ProfilingConnectionFactory.hpp
index c4b10c6445..b3a1658548 100644
--- a/src/profiling/ProfilingConnectionFactory.hpp
+++ b/src/profiling/ProfilingConnectionFactory.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -26,6 +26,6 @@ public:
IProfilingConnectionPtr GetProfilingConnection(const ExternalProfilingOptions& options) const override;
};
-} // namespace profiling
+} // namespace profiling
-} // namespace armnn
+} // namespace armnn
diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp
index 54b0f93694..427cdbd0c4 100644
--- a/src/profiling/ProfilingService.hpp
+++ b/src/profiling/ProfilingService.hpp
@@ -136,6 +136,8 @@ protected:
, m_ConnectionAcknowledgedCommandHandler(0,
1,
m_PacketVersionResolver.ResolvePacketVersion(0, 1).GetEncodedValue(),
+ m_CounterDirectory,
+ m_SendCounterPacket,
m_StateMachine)
, m_RequestCounterDirectoryCommandHandler(0,
3,
diff --git a/src/profiling/ProfilingUtils.cpp b/src/profiling/ProfilingUtils.cpp
index 93eca25956..4202b68662 100644
--- a/src/profiling/ProfilingUtils.cpp
+++ b/src/profiling/ProfilingUtils.cpp
@@ -11,6 +11,7 @@
#include <boost/assert.hpp>
#include <fstream>
+#include <iostream>
#include <limits>
namespace armnn
@@ -94,7 +95,23 @@ void WriteBytes(const IPacketBufferPtr& packetBuffer, unsigned int offset, cons
WriteBytes(packetBuffer->GetWritableData(), offset, value, valueSize);
}
-void WriteUint64(const IPacketBufferPtr& packetBuffer, unsigned int offset, uint64_t value)
+uint32_t ConstructHeader(uint32_t packetFamily,
+ uint32_t packetId)
+{
+ return ((packetFamily & 0x3F) << 26)|
+ ((packetId & 0x3FF) << 16);
+}
+
+uint32_t ConstructHeader(uint32_t packetFamily,
+ uint32_t packetClass,
+ uint32_t packetType)
+{
+ return ((packetFamily & 0x3F) << 26)|
+ ((packetClass & 0x3FF) << 19)|
+ ((packetType & 0x3FFF) << 16);
+}
+
+void WriteUint64(const std::unique_ptr<IPacketBuffer>& packetBuffer, unsigned int offset, uint64_t value)
{
BOOST_ASSERT(packetBuffer);
@@ -872,6 +889,208 @@ TimelinePacketStatus WriteTimelineEventBinaryPacket(uint64_t timestamp,
return TimelinePacketStatus::Ok;
}
+
+std::string CentreAlignFormatting(const std::string& stringToPass, const int spacingWidth)
+{
+ std::stringstream outputStream, centrePadding;
+ int padding = spacingWidth - static_cast<int>(stringToPass.size());
+
+ for (int i = 0; i < padding / 2; ++i)
+ {
+ centrePadding << " ";
+ }
+
+ outputStream << centrePadding.str() << stringToPass << centrePadding.str();
+
+ if (padding > 0 && padding %2 != 0)
+ {
+ outputStream << " ";
+ }
+
+ return outputStream.str();
+}
+
+void PrintDeviceDetails(const std::pair<const unsigned short, std::unique_ptr<Device>>& devicePair)
+{
+ std::string body;
+
+ body.append(CentreAlignFormatting(devicePair.second->m_Name, 20));
+ body.append(" | ");
+ body.append(CentreAlignFormatting(std::to_string(devicePair.first), 13));
+ body.append(" | ");
+ body.append(CentreAlignFormatting(std::to_string(devicePair.second->m_Cores), 10));
+ body.append("\n");
+
+ std::cout << std::string(body.size(), '-') << "\n";
+ std::cout<< body;
+}
+
+void PrintCounterSetDetails(const std::pair<const unsigned short, std::unique_ptr<CounterSet>>& counterSetPair)
+{
+ std::string body;
+
+ body.append(CentreAlignFormatting(counterSetPair.second->m_Name, 20));
+ body.append(" | ");
+ body.append(CentreAlignFormatting(std::to_string(counterSetPair.first), 13));
+ body.append(" | ");
+ body.append(CentreAlignFormatting(std::to_string(counterSetPair.second->m_Count), 10));
+ body.append("\n");
+
+ std::cout << std::string(body.size(), '-') << "\n";
+
+ std::cout<< body;
+}
+
+void PrintCounterDetails(std::shared_ptr<Counter>& counter)
+{
+ std::string body;
+
+ body.append(CentreAlignFormatting(counter->m_Name, 20));
+ body.append(" | ");
+ body.append(CentreAlignFormatting(counter->m_Description, 50));
+ body.append(" | ");
+ body.append(CentreAlignFormatting(counter->m_Units, 14));
+ body.append(" | ");
+ body.append(CentreAlignFormatting(std::to_string(counter->m_Uid), 6));
+ body.append(" | ");
+ body.append(CentreAlignFormatting(std::to_string(counter->m_MaxCounterUid), 10));
+ body.append(" | ");
+ body.append(CentreAlignFormatting(std::to_string(counter->m_Class), 8));
+ body.append(" | ");
+ body.append(CentreAlignFormatting(std::to_string(counter->m_Interpolation), 14));
+ body.append(" | ");
+ body.append(CentreAlignFormatting(std::to_string(counter->m_Multiplier), 20));
+ body.append(" | ");
+ body.append(CentreAlignFormatting(std::to_string(counter->m_CounterSetUid), 16));
+ body.append(" | ");
+ body.append(CentreAlignFormatting(std::to_string(counter->m_DeviceUid), 14));
+
+ body.append("\n");
+
+ std::cout << std::string(body.size(), '-') << "\n";
+
+ std::cout << body;
+}
+
+void PrintCategoryDetails(const std::unique_ptr<Category>& category,
+ std::unordered_map<unsigned short, std::shared_ptr<Counter>> counterMap)
+{
+ std::string categoryBody;
+ std::string categoryHeader;
+
+ categoryHeader.append(CentreAlignFormatting("Name", 20));
+ categoryHeader.append(" | ");
+ categoryHeader.append(CentreAlignFormatting("Device", 12));
+ categoryHeader.append(" | ");
+ categoryHeader.append(CentreAlignFormatting("Counter set UID:", 16));
+ categoryHeader.append(" | ");
+ categoryHeader.append(CentreAlignFormatting("Event Count", 14));
+ categoryHeader.append("\n");
+
+ categoryBody.append(CentreAlignFormatting(category->m_Name, 20));
+ categoryBody.append(" | ");
+ categoryBody.append(CentreAlignFormatting(std::to_string(category->m_DeviceUid), 12));
+ categoryBody.append(" | ");
+ categoryBody.append(CentreAlignFormatting(std::to_string(category->m_CounterSetUid), 16));
+ categoryBody.append(" | ");
+ categoryBody.append(CentreAlignFormatting(std::to_string(category->m_Counters.size()), 14));
+
+ std::cout << "\n" << "\n";
+ std::cout << CentreAlignFormatting("CATEGORY", static_cast<int>(categoryHeader.size()));
+ std::cout << "\n";
+ std::cout << std::string(categoryHeader.size(), '=') << "\n";
+
+ std::cout << categoryHeader;
+
+ std::cout << std::string(categoryBody.size(), '-') << "\n";
+
+ std::cout << categoryBody;
+
+ std::string counterHeader;
+
+ counterHeader.append(CentreAlignFormatting("Counter Name", 20));
+ counterHeader.append(" | ");
+ counterHeader.append(CentreAlignFormatting("Description", 50));
+ counterHeader.append(" | ");
+ counterHeader.append(CentreAlignFormatting("Units", 14));
+ counterHeader.append(" | ");
+ counterHeader.append(CentreAlignFormatting("UID", 6));
+ counterHeader.append(" | ");
+ counterHeader.append(CentreAlignFormatting("Max UID", 10));
+ counterHeader.append(" | ");
+ counterHeader.append(CentreAlignFormatting("Class", 8));
+ counterHeader.append(" | ");
+ counterHeader.append(CentreAlignFormatting("Interpolation", 14));
+ counterHeader.append(" | ");
+ counterHeader.append(CentreAlignFormatting("Multiplier", 20));
+ counterHeader.append(" | ");
+ counterHeader.append(CentreAlignFormatting("Counter set UID", 16));
+ counterHeader.append(" | ");
+ counterHeader.append(CentreAlignFormatting("Device UID", 14));
+ counterHeader.append("\n");
+
+ std::cout << "\n" << "\n";
+ std::cout << CentreAlignFormatting("EVENTS IN CATEGORY: " + category->m_Name,
+ static_cast<int>(counterHeader.size()));
+ std::cout << "\n";
+ std::cout << std::string(counterHeader.size(), '=') << "\n";
+ std::cout << counterHeader;
+ for (auto& it: category->m_Counters) {
+ auto search = counterMap.find(it);
+ if(search != counterMap.end()) {
+ PrintCounterDetails(search->second);
+ }
+ }
+}
+
+void PrintCounterDirectory(ICounterDirectory& counterDirectory)
+{
+ std::string devicesHeader;
+
+ devicesHeader.append(CentreAlignFormatting("Device name", 20));
+ devicesHeader.append(" | ");
+ devicesHeader.append(CentreAlignFormatting("UID", 13));
+ devicesHeader.append(" | ");
+ devicesHeader.append(CentreAlignFormatting("Cores", 10));
+ devicesHeader.append("\n");
+
+ std::cout << "\n" << "\n";
+ std::cout << CentreAlignFormatting("DEVICES", static_cast<int>(devicesHeader.size()));
+ std::cout << "\n";
+ std::cout << std::string(devicesHeader.size(), '=') << "\n";
+ std::cout << devicesHeader;
+ for (auto& it: counterDirectory.GetDevices()) {
+ PrintDeviceDetails(it);
+ }
+
+ std::string counterSetHeader;
+
+ counterSetHeader.append(CentreAlignFormatting("Counter set name", 20));
+ counterSetHeader.append(" | ");
+ counterSetHeader.append(CentreAlignFormatting("UID", 13));
+ counterSetHeader.append(" | ");
+ counterSetHeader.append(CentreAlignFormatting("Count", 10));
+ counterSetHeader.append("\n");
+
+ std::cout << "\n" << "\n";
+ std::cout << CentreAlignFormatting("COUNTER SETS", static_cast<int>(counterSetHeader.size()));
+ std::cout << "\n";
+ std::cout << std::string(counterSetHeader.size(), '=') << "\n";
+
+ std::cout << counterSetHeader;
+
+ for (auto& it: counterDirectory.GetCounterSets()) {
+ PrintCounterSetDetails(it);
+ }
+
+ auto counters = counterDirectory.GetCounters();
+ for (auto& it: counterDirectory.GetCategories()) {
+ PrintCategoryDetails(it, counters);
+ }
+ std::cout << "\n";
+}
+
+
} // namespace profiling
} // namespace armnn
diff --git a/src/profiling/ProfilingUtils.hpp b/src/profiling/ProfilingUtils.hpp
index 3e0a8a2cec..fae1a83024 100644
--- a/src/profiling/ProfilingUtils.hpp
+++ b/src/profiling/ProfilingUtils.hpp
@@ -7,6 +7,7 @@
#include <armnn/Exceptions.hpp>
+#include "ICounterDirectory.hpp"
#include "IPacketBuffer.hpp"
#include <boost/numeric/conversion/cast.hpp>
@@ -55,10 +56,7 @@ template <typename SwTracePolicy>
bool IsValidSwTraceString(const std::string& s)
{
// Check that all the characters in the given string conform to the given policy
- return std::all_of(s.begin(), s.end(), [](unsigned char c)
- {
- return SwTracePolicy::IsValidChar(c);
- });
+ return std::all_of(s.begin(), s.end(), [](unsigned char c) { return SwTracePolicy::IsValidChar(c); });
}
template <typename SwTracePolicy>
@@ -77,7 +75,7 @@ bool StringToSwTraceString(const std::string& s, std::vector<uint32_t>& outputBu
}
// Prepare the output buffer
- size_t s_size = s.size() + 1; // The size of the string (in chars) plus the null-terminator
+ size_t s_size = s.size() + 1; // The size of the string (in chars) plus the null-terminator
size_t uint32_t_size = sizeof(uint32_t);
size_t outBufferSize = 1 + s_size / uint32_t_size + (s_size % uint32_t_size != 0 ? 1 : 0);
outputBuffer.resize(outBufferSize, '\0');
@@ -95,6 +93,10 @@ std::vector<uint16_t> GetNextCounterUids(uint16_t cores);
void WriteBytes(const IPacketBuffer& packetBuffer, unsigned int offset, const void* value, unsigned int valueSize);
+uint32_t ConstructHeader(uint32_t packetFamily, uint32_t packetId);
+
+uint32_t ConstructHeader(uint32_t packetFamily, uint32_t packetClass, uint32_t packetType);
+
void WriteUint64(const IPacketBufferPtr& packetBuffer, unsigned int offset, uint64_t value);
void WriteUint32(const IPacketBufferPtr& packetBuffer, unsigned int offset, uint32_t value);
@@ -146,10 +148,10 @@ enum class TimelinePacketStatus
enum class ProfilingRelationshipType
{
- RetentionLink, /// Head retains(parents) Tail
- ExecutionLink, /// Head execution start depends on Tail execution completion
- DataLink, /// Head uses data of Tail
- LabelLink /// Head uses label Tail (Tail MUST be a guid of a label).
+ RetentionLink, /// Head retains(parents) Tail
+ ExecutionLink, /// Head execution start depends on Tail execution completion
+ DataLink, /// Head uses data of Tail
+ LabelLink /// Head uses label Tail (Tail MUST be a guid of a label).
};
uint32_t CalculateSizeOfPaddedSwString(const std::string& str);
@@ -191,14 +193,18 @@ TimelinePacketStatus WriteTimelineEventBinaryPacket(uint64_t timestamp,
unsigned int bufferSize,
unsigned int& numberOfBytesWritten);
+std::string CentreAlignFormatting(const std::string& stringToPass, const int spacingWidth);
+
+void PrintCounterDirectory(ICounterDirectory& counterDirectory);
+
class BufferExhaustion : public armnn::Exception
{
using Exception::Exception;
};
-} // namespace profiling
+} // namespace profiling
-} // namespace armnn
+} // namespace armnn
namespace std
{
diff --git a/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp b/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp
new file mode 100644
index 0000000000..7f927bdeee
--- /dev/null
+++ b/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp
@@ -0,0 +1,111 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "../FileOnlyProfilingConnection.hpp"
+#include <Runtime.hpp>
+
+#include <boost/core/ignore_unused.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <ProfilingService.hpp>
+#include <cstdio>
+#include <fstream>
+#include <sstream>
+#include <sys/stat.h>
+
+#if defined(__ANDROID__)
+#define ARMNN_PROFILING_CONNECTION_TEST_DUMP_DIR "/data/local/tmp"
+#else
+#define ARMNN_PROFILING_CONNECTION_TEST_DUMP_DIR "/tmp"
+#endif
+
+using namespace armnn::profiling;
+using namespace armnn;
+
+using namespace std::chrono_literals;
+
+BOOST_AUTO_TEST_SUITE(FileOnlyProfilingDecoratorTests)
+
+BOOST_AUTO_TEST_CASE(DumpOutgoingValidFileEndToEnd)
+{
+ // Create a temporary file name.
+ boost::filesystem::path tempPath = boost::filesystem::temp_directory_path();
+ boost::filesystem::path tempFile = boost::filesystem::unique_path();
+ tempPath = tempPath / tempFile;
+ armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
+ options.m_EnableProfiling = true;
+ options.m_FileOnly = true;
+ options.m_IncomingCaptureFile = "";
+ options.m_OutgoingCaptureFile = tempPath.c_str();
+ options.m_CapturePeriod = 100;
+
+ // Enable the profiling service
+ ProfilingService& profilingService = ProfilingService::Instance();
+ profilingService.ResetExternalProfilingOptions(options, true);
+ // Bring the profiling service to the "WaitingForAck" state
+ profilingService.Update();
+ profilingService.Update();
+
+ u_int32_t timeout = 2000;
+ u_int32_t sleepTime = 50;
+ u_int32_t timeSlept = 0;
+
+ // Give the profiling service sending thread time start executing and send the stream metadata.
+ while (profilingService.GetCurrentState() != ProfilingState::WaitingForAck)
+ {
+ if (timeSlept >= timeout)
+ {
+ BOOST_FAIL("Timeout: Profiling service did not switch to WaitingForAck state");
+ }
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime));
+ timeSlept += sleepTime;
+ }
+
+ profilingService.Update();
+
+ timeSlept = 0;
+
+ while (profilingService.GetCurrentState() != profiling::ProfilingState::Active)
+ {
+ if (timeSlept >= timeout)
+ {
+ BOOST_FAIL("Timeout: Profiling service did not switch to Active state");
+ }
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime));
+ timeSlept += sleepTime;
+ }
+
+ // Minimum test here is to check that the file was created.
+ BOOST_CHECK(boost::filesystem::exists(tempPath.c_str()) == true);
+
+ // Increment a counter.
+ BOOST_CHECK(profilingService.IsCounterRegistered(0) == true);
+ profilingService.IncrementCounterValue(0);
+ BOOST_CHECK(profilingService.GetCounterValue(0) > 0);
+
+ // At this point the profiling service is active and we've activated all the counters. Waiting a collection
+ // period should be enough to have some data in the file.
+
+ // Wait for 1 collection period plus a bit of overhead..
+ std::this_thread::sleep_for(std::chrono::milliseconds(150));
+
+ // In order to flush the files we need to gracefully close the profiling service.
+ options.m_EnableProfiling = false;
+ profilingService.ResetExternalProfilingOptions(options, true);
+ // Wait a short time to allow the threads to clean themselves up.
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+
+ // The output file size should be greater than 0.
+ struct stat statusBuffer;
+ BOOST_CHECK(stat(tempPath.c_str(), &statusBuffer) == 0);
+ BOOST_CHECK(statusBuffer.st_size > 0);
+
+ // Delete the tmp file.
+ BOOST_CHECK(remove(tempPath.c_str()) == 0);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
index c42891d9bf..ec4e591836 100644
--- a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
+++ b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
@@ -81,7 +81,6 @@ std::vector<char> ReadDumpFile(const std::string& dumpFileName)
BOOST_AUTO_TEST_SUITE(ProfilingConnectionDumpToFileDecoratorTests)
-
BOOST_AUTO_TEST_CASE(DumpIncomingInvalidFile)
{
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp
index aba967507e..79a241b540 100644
--- a/src/profiling/test/ProfilingTests.cpp
+++ b/src/profiling/test/ProfilingTests.cpp
@@ -32,10 +32,10 @@
#include <cstdint>
#include <cstring>
+#include <iostream>
#include <limits>
#include <map>
#include <random>
-#include <iostream>
using namespace armnn::profiling;
@@ -58,53 +58,49 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerKeyComparisons)
BOOST_CHECK(testKey1_0 == testKey1_1);
BOOST_CHECK(testKey1_0 < testKey1_2);
- BOOST_CHECK(testKey1<testKey4);
- BOOST_CHECK(testKey1>testKey3);
- BOOST_CHECK(testKey1<=testKey4);
- BOOST_CHECK(testKey1>=testKey3);
- BOOST_CHECK(testKey1<=testKey2);
- BOOST_CHECK(testKey1>=testKey2);
- BOOST_CHECK(testKey1==testKey2);
- BOOST_CHECK(testKey1==testKey1);
+ BOOST_CHECK(testKey1 < testKey4);
+ BOOST_CHECK(testKey1 > testKey3);
+ BOOST_CHECK(testKey1 <= testKey4);
+ BOOST_CHECK(testKey1 >= testKey3);
+ BOOST_CHECK(testKey1 <= testKey2);
+ BOOST_CHECK(testKey1 >= testKey2);
+ BOOST_CHECK(testKey1 == testKey2);
+ BOOST_CHECK(testKey1 == testKey1);
- BOOST_CHECK(!(testKey1==testKey5));
- BOOST_CHECK(!(testKey1!=testKey1));
- BOOST_CHECK(testKey1!=testKey5);
+ BOOST_CHECK(!(testKey1 == testKey5));
+ BOOST_CHECK(!(testKey1 != testKey1));
+ BOOST_CHECK(testKey1 != testKey5);
- BOOST_CHECK(testKey1==testKey2 && testKey2==testKey1);
- BOOST_CHECK(testKey0==testKey1 && testKey1==testKey2 && testKey0==testKey2);
+ BOOST_CHECK(testKey1 == testKey2 && testKey2 == testKey1);
+ BOOST_CHECK(testKey0 == testKey1 && testKey1 == testKey2 && testKey0 == testKey2);
- BOOST_CHECK(testKey1.GetPacketId()==1);
- BOOST_CHECK(testKey1.GetVersion()==1);
+ BOOST_CHECK(testKey1.GetPacketId() == 1);
+ BOOST_CHECK(testKey1.GetVersion() == 1);
- std::vector<CommandHandlerKey> vect =
- {
- CommandHandlerKey(0,0,1), CommandHandlerKey(0,2,0), CommandHandlerKey(0,1,0),
- CommandHandlerKey(0,2,1), CommandHandlerKey(0,1,1), CommandHandlerKey(0,0,1),
- CommandHandlerKey(0,2,0), CommandHandlerKey(0,0,0)
- };
+ std::vector<CommandHandlerKey> vect = { CommandHandlerKey(0, 0, 1), CommandHandlerKey(0, 2, 0),
+ CommandHandlerKey(0, 1, 0), CommandHandlerKey(0, 2, 1),
+ CommandHandlerKey(0, 1, 1), CommandHandlerKey(0, 0, 1),
+ CommandHandlerKey(0, 2, 0), CommandHandlerKey(0, 0, 0) };
std::sort(vect.begin(), vect.end());
- std::vector<CommandHandlerKey> expectedVect =
- {
- CommandHandlerKey(0,0,0), CommandHandlerKey(0,0,1), CommandHandlerKey(0,0,1),
- CommandHandlerKey(0,1,0), CommandHandlerKey(0,1,1), CommandHandlerKey(0,2,0),
- CommandHandlerKey(0,2,0), CommandHandlerKey(0,2,1)
- };
+ std::vector<CommandHandlerKey> expectedVect = { CommandHandlerKey(0, 0, 0), CommandHandlerKey(0, 0, 1),
+ CommandHandlerKey(0, 0, 1), CommandHandlerKey(0, 1, 0),
+ CommandHandlerKey(0, 1, 1), CommandHandlerKey(0, 2, 0),
+ CommandHandlerKey(0, 2, 0), CommandHandlerKey(0, 2, 1) };
BOOST_CHECK(vect == expectedVect);
}
BOOST_AUTO_TEST_CASE(CheckPacketKeyComparisons)
{
- PacketKey key0(0,0);
- PacketKey key1(0,0);
- PacketKey key2(0,1);
- PacketKey key3(0,2);
- PacketKey key4(1,0);
- PacketKey key5(1,0);
- PacketKey key6(1,1);
+ PacketKey key0(0, 0);
+ PacketKey key1(0, 0);
+ PacketKey key2(0, 1);
+ PacketKey key3(0, 2);
+ PacketKey key4(1, 0);
+ PacketKey key5(1, 0);
+ PacketKey key6(1, 1);
BOOST_CHECK(!(key0 < key1));
BOOST_CHECK(!(key0 > key1));
@@ -129,8 +125,11 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandler)
TestProfilingConnectionBase testProfilingConnectionBase;
TestProfilingConnectionTimeoutError testProfilingConnectionTimeOutError;
TestProfilingConnectionArmnnError testProfilingConnectionArmnnError;
-
- ConnectionAcknowledgedCommandHandler connectionAcknowledgedCommandHandler(0, 1, 4194304, profilingStateMachine);
+ CounterDirectory counterDirectory;
+ MockBufferManager mockBuffer(1024);
+ SendCounterPacket sendCounterPacket(profilingStateMachine, mockBuffer);
+ ConnectionAcknowledgedCommandHandler connectionAcknowledgedCommandHandler(0, 1, 4194304, counterDirectory,
+ sendCounterPacket, profilingStateMachine);
CommandHandlerRegistry commandHandlerRegistry;
commandHandlerRegistry.RegisterFunctor(&connectionAcknowledgedCommandHandler);
@@ -138,10 +137,7 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandler)
profilingStateMachine.TransitionToState(ProfilingState::NotConnected);
profilingStateMachine.TransitionToState(ProfilingState::WaitingForAck);
- CommandHandler commandHandler0(1,
- true,
- commandHandlerRegistry,
- packetVersionResolver);
+ CommandHandler commandHandler0(1, true, commandHandlerRegistry, packetVersionResolver);
commandHandler0.Start(testProfilingConnectionBase);
commandHandler0.Start(testProfilingConnectionBase);
@@ -154,10 +150,7 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandler)
profilingStateMachine.TransitionToState(ProfilingState::NotConnected);
profilingStateMachine.TransitionToState(ProfilingState::WaitingForAck);
// commandHandler1 should give up after one timeout
- CommandHandler commandHandler1(10,
- true,
- commandHandlerRegistry,
- packetVersionResolver);
+ CommandHandler commandHandler1(10, true, commandHandlerRegistry, packetVersionResolver);
commandHandler1.Start(testProfilingConnectionTimeOutError);
@@ -185,10 +178,7 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandler)
BOOST_CHECK(profilingStateMachine.GetCurrentState() == ProfilingState::Active);
- CommandHandler commandHandler2(100,
- false,
- commandHandlerRegistry,
- packetVersionResolver);
+ CommandHandler commandHandler2(100, false, commandHandlerRegistry, packetVersionResolver);
commandHandler2.Start(testProfilingConnectionArmnnError);
@@ -231,7 +221,7 @@ BOOST_AUTO_TEST_CASE(CheckEncodeVersion)
BOOST_AUTO_TEST_CASE(CheckPacketClass)
{
- uint32_t length = 4;
+ uint32_t length = 4;
std::unique_ptr<unsigned char[]> packetData0 = std::make_unique<unsigned char[]>(length);
std::unique_ptr<unsigned char[]> packetData1 = std::make_unique<unsigned char[]>(0);
std::unique_ptr<unsigned char[]> nullPacketData;
@@ -288,11 +278,11 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerFunctor)
// Check the order of the map is correct
auto it = registry.begin();
- BOOST_CHECK(it->first==keyC); // familyId == 5
+ BOOST_CHECK(it->first == keyC); // familyId == 5
it++;
- BOOST_CHECK(it->first==keyA); // familyId == 7
+ BOOST_CHECK(it->first == keyA); // familyId == 7
it++;
- BOOST_CHECK(it->first==keyB); // familyId == 8
+ BOOST_CHECK(it->first == keyB); // familyId == 8
std::unique_ptr<unsigned char[]> packetDataA;
std::unique_ptr<unsigned char[]> packetDataB;
@@ -407,7 +397,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingStateMachine)
{
ProfilingStateMachine profilingState1(ProfilingState::Uninitialised);
profilingState1.TransitionToState(ProfilingState::Uninitialised);
- BOOST_CHECK(profilingState1.GetCurrentState() == ProfilingState::Uninitialised);
+ BOOST_CHECK(profilingState1.GetCurrentState() == ProfilingState::Uninitialised);
ProfilingStateMachine profilingState2(ProfilingState::Uninitialised);
profilingState2.TransitionToState(ProfilingState::NotConnected);
@@ -438,44 +428,37 @@ BOOST_AUTO_TEST_CASE(CheckProfilingStateMachine)
BOOST_CHECK(profilingState8.GetCurrentState() == ProfilingState::Active);
ProfilingStateMachine profilingState9(ProfilingState::Uninitialised);
- BOOST_CHECK_THROW(profilingState9.TransitionToState(ProfilingState::WaitingForAck),
- armnn::Exception);
+ BOOST_CHECK_THROW(profilingState9.TransitionToState(ProfilingState::WaitingForAck), armnn::Exception);
ProfilingStateMachine profilingState10(ProfilingState::Uninitialised);
- BOOST_CHECK_THROW(profilingState10.TransitionToState(ProfilingState::Active),
- armnn::Exception);
+ BOOST_CHECK_THROW(profilingState10.TransitionToState(ProfilingState::Active), armnn::Exception);
ProfilingStateMachine profilingState11(ProfilingState::NotConnected);
- BOOST_CHECK_THROW(profilingState11.TransitionToState(ProfilingState::Uninitialised),
- armnn::Exception);
+ BOOST_CHECK_THROW(profilingState11.TransitionToState(ProfilingState::Uninitialised), armnn::Exception);
ProfilingStateMachine profilingState12(ProfilingState::NotConnected);
- BOOST_CHECK_THROW(profilingState12.TransitionToState(ProfilingState::Active),
- armnn::Exception);
+ BOOST_CHECK_THROW(profilingState12.TransitionToState(ProfilingState::Active), armnn::Exception);
ProfilingStateMachine profilingState13(ProfilingState::WaitingForAck);
- BOOST_CHECK_THROW(profilingState13.TransitionToState(ProfilingState::Uninitialised),
- armnn::Exception);
+ BOOST_CHECK_THROW(profilingState13.TransitionToState(ProfilingState::Uninitialised), armnn::Exception);
ProfilingStateMachine profilingState14(ProfilingState::WaitingForAck);
profilingState14.TransitionToState(ProfilingState::NotConnected);
BOOST_CHECK(profilingState14.GetCurrentState() == ProfilingState::NotConnected);
ProfilingStateMachine profilingState15(ProfilingState::Active);
- BOOST_CHECK_THROW(profilingState15.TransitionToState(ProfilingState::Uninitialised),
- armnn::Exception);
+ BOOST_CHECK_THROW(profilingState15.TransitionToState(ProfilingState::Uninitialised), armnn::Exception);
ProfilingStateMachine profilingState16(armnn::profiling::ProfilingState::Active);
- BOOST_CHECK_THROW(profilingState16.TransitionToState(ProfilingState::WaitingForAck),
- armnn::Exception);
+ BOOST_CHECK_THROW(profilingState16.TransitionToState(ProfilingState::WaitingForAck), armnn::Exception);
ProfilingStateMachine profilingState17(ProfilingState::Uninitialised);
- std::thread thread1 (ProfilingCurrentStateThreadImpl,std::ref(profilingState17));
- std::thread thread2 (ProfilingCurrentStateThreadImpl,std::ref(profilingState17));
- std::thread thread3 (ProfilingCurrentStateThreadImpl,std::ref(profilingState17));
- std::thread thread4 (ProfilingCurrentStateThreadImpl,std::ref(profilingState17));
- std::thread thread5 (ProfilingCurrentStateThreadImpl,std::ref(profilingState17));
+ std::thread thread1(ProfilingCurrentStateThreadImpl, std::ref(profilingState17));
+ std::thread thread2(ProfilingCurrentStateThreadImpl, std::ref(profilingState17));
+ std::thread thread3(ProfilingCurrentStateThreadImpl, std::ref(profilingState17));
+ std::thread thread4(ProfilingCurrentStateThreadImpl, std::ref(profilingState17));
+ std::thread thread5(ProfilingCurrentStateThreadImpl, std::ref(profilingState17));
thread1.join();
thread2.join();
@@ -541,17 +524,14 @@ BOOST_AUTO_TEST_CASE(CheckCaptureDataHolder)
std::vector<std::thread> readThreadsVect;
for (uint32_t i = 0; i < numThreads; ++i)
{
- threadsVect.emplace_back(std::thread(CaptureDataWriteThreadImpl,
- std::ref(holder),
- i,
- std::ref(periodIdMap[i])));
+ threadsVect.emplace_back(
+ std::thread(CaptureDataWriteThreadImpl, std::ref(holder), i, std::ref(periodIdMap[i])));
// Verify that the CaptureData goes into the thread in a virgin state
BOOST_CHECK(captureDataIdMap.at(i).GetCapturePeriod() == 0);
BOOST_CHECK(captureDataIdMap.at(i).GetCounterIds().empty());
- readThreadsVect.emplace_back(std::thread(CaptureDataReadThreadImpl,
- std::ref(holder),
- std::ref(captureDataIdMap.at(i))));
+ readThreadsVect.emplace_back(
+ std::thread(CaptureDataReadThreadImpl, std::ref(holder), std::ref(captureDataIdMap.at(i))));
}
for (uint32_t i = 0; i < numThreads; ++i)
@@ -572,7 +552,7 @@ BOOST_AUTO_TEST_CASE(CheckCaptureDataHolder)
BOOST_AUTO_TEST_CASE(CaptureDataMethods)
{
// Check CaptureData setter and getter functions
- std::vector<uint16_t> counterIds = {42, 29, 13};
+ std::vector<uint16_t> counterIds = { 42, 29, 13 };
CaptureData captureData;
BOOST_CHECK(captureData.GetCapturePeriod() == 0);
BOOST_CHECK((captureData.GetCounterIds()).empty());
@@ -611,7 +591,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceEnabled)
LogLevelSwapper logLevelSwapper(armnn::LogSeverity::Warning);
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
ProfilingService& profilingService = ProfilingService::Instance();
profilingService.ResetExternalProfilingOptions(options, true);
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
@@ -672,13 +652,13 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceCounterDirectory)
BOOST_AUTO_TEST_CASE(CheckProfilingServiceCounterValues)
{
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
ProfilingService& profilingService = ProfilingService::Instance();
profilingService.ResetExternalProfilingOptions(options, true);
profilingService.Update();
const ICounterDirectory& counterDirectory = profilingService.GetCounterDirectory();
- const Counters& counters = counterDirectory.GetCounters();
+ const Counters& counters = counterDirectory.GetCounters();
BOOST_CHECK(!counters.empty());
// Get the UID of the first counter for testing
@@ -687,13 +667,13 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceCounterValues)
ProfilingService* profilingServicePtr = &profilingService;
std::vector<std::thread> writers;
- for (int i = 0; i < 100 ; ++i)
+ for (int i = 0; i < 100; ++i)
{
// Increment and decrement the first counter
writers.push_back(std::thread(&ProfilingService::IncrementCounterValue, profilingServicePtr, counterUid));
writers.push_back(std::thread(&ProfilingService::DecrementCounterValue, profilingServicePtr, counterUid));
// Add 10 and subtract 5 from the first counter
- writers.push_back(std::thread(&ProfilingService::AddCounterValue, profilingServicePtr, counterUid, 10));
+ writers.push_back(std::thread(&ProfilingService::AddCounterValue, profilingServicePtr, counterUid, 10));
writers.push_back(std::thread(&ProfilingService::SubtractCounterValue, profilingServicePtr, counterUid, 5));
}
@@ -733,7 +713,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingObjectUids)
BOOST_CHECK_NO_THROW(counterUidsMultiCore = GetNextCounterUids(numberOfCores));
BOOST_CHECK(counterUidsMultiCore.size() == numberOfCores);
BOOST_CHECK(counterUidsMultiCore.front() >= nextCounterUids[0]);
- for (size_t i = 1; i < numberOfCores; i ++)
+ for (size_t i = 1; i < numberOfCores; i++)
{
BOOST_CHECK(counterUidsMultiCore[i] == counterUidsMultiCore[i - 1] + 1);
}
@@ -743,10 +723,10 @@ BOOST_AUTO_TEST_CASE(CheckProfilingObjectUids)
BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCategory)
{
CounterDirectory counterDirectory;
- BOOST_CHECK(counterDirectory.GetCategoryCount() == 0);
- BOOST_CHECK(counterDirectory.GetDeviceCount() == 0);
+ BOOST_CHECK(counterDirectory.GetCategoryCount() == 0);
+ BOOST_CHECK(counterDirectory.GetDeviceCount() == 0);
BOOST_CHECK(counterDirectory.GetCounterSetCount() == 0);
- BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
+ BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
// Register a category with an invalid name
const Category* noCategory = nullptr;
@@ -762,7 +742,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCategory)
// Register a new category
const std::string categoryName = "some_category";
- const Category* category = nullptr;
+ const Category* category = nullptr;
BOOST_CHECK_NO_THROW(category = counterDirectory.RegisterCategory(categoryName));
BOOST_CHECK(counterDirectory.GetCategoryCount() == 1);
BOOST_CHECK(category);
@@ -791,7 +771,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCategory)
// Register a device for testing
const std::string deviceName = "some_device";
- const Device* device = nullptr;
+ const Device* device = nullptr;
BOOST_CHECK_NO_THROW(device = counterDirectory.RegisterDevice(deviceName));
BOOST_CHECK(counterDirectory.GetDeviceCount() == 1);
BOOST_CHECK(device);
@@ -801,7 +781,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCategory)
// Register a new category not associated to any device
const std::string categoryWoDeviceName = "some_category_without_device";
- const Category* categoryWoDevice = nullptr;
+ const Category* categoryWoDevice = nullptr;
BOOST_CHECK_NO_THROW(categoryWoDevice = counterDirectory.RegisterCategory(categoryWoDeviceName, 0));
BOOST_CHECK(counterDirectory.GetCategoryCount() == 2);
BOOST_CHECK(categoryWoDevice);
@@ -818,19 +798,17 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCategory)
ARMNN_NO_CONVERSION_WARN_END
const Category* categoryWInvalidDevice = nullptr;
- BOOST_CHECK_THROW(categoryWInvalidDevice
- = counterDirectory.RegisterCategory(categoryWInvalidDeviceName,
- invalidDeviceUid),
+ BOOST_CHECK_THROW(categoryWInvalidDevice =
+ counterDirectory.RegisterCategory(categoryWInvalidDeviceName, invalidDeviceUid),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCategoryCount() == 2);
BOOST_CHECK(!categoryWInvalidDevice);
// Register a new category associated to a valid device
const std::string categoryWValidDeviceName = "some_category_with_valid_device";
- const Category* categoryWValidDevice = nullptr;
- BOOST_CHECK_NO_THROW(categoryWValidDevice
- = counterDirectory.RegisterCategory(categoryWValidDeviceName,
- device->m_Uid));
+ const Category* categoryWValidDevice = nullptr;
+ BOOST_CHECK_NO_THROW(categoryWValidDevice =
+ counterDirectory.RegisterCategory(categoryWValidDeviceName, device->m_Uid));
BOOST_CHECK(counterDirectory.GetCategoryCount() == 3);
BOOST_CHECK(categoryWValidDevice);
BOOST_CHECK(categoryWValidDevice != category);
@@ -840,7 +818,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCategory)
// Register a counter set for testing
const std::string counterSetName = "some_counter_set";
- const CounterSet* counterSet = nullptr;
+ const CounterSet* counterSet = nullptr;
BOOST_CHECK_NO_THROW(counterSet = counterDirectory.RegisterCounterSet(counterSetName));
BOOST_CHECK(counterDirectory.GetCounterSetCount() == 1);
BOOST_CHECK(counterSet);
@@ -850,11 +828,9 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCategory)
// Register a new category not associated to any counter set
const std::string categoryWoCounterSetName = "some_category_without_counter_set";
- const Category* categoryWoCounterSet = nullptr;
- BOOST_CHECK_NO_THROW(categoryWoCounterSet
- = counterDirectory.RegisterCategory(categoryWoCounterSetName,
- armnn::EmptyOptional(),
- 0));
+ const Category* categoryWoCounterSet = nullptr;
+ BOOST_CHECK_NO_THROW(categoryWoCounterSet =
+ counterDirectory.RegisterCategory(categoryWoCounterSetName, armnn::EmptyOptional(), 0));
BOOST_CHECK(counterDirectory.GetCategoryCount() == 4);
BOOST_CHECK(categoryWoCounterSet);
BOOST_CHECK(categoryWoCounterSet->m_Name == categoryWoCounterSetName);
@@ -869,21 +845,17 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCategory)
ARMNN_NO_CONVERSION_WARN_END
const Category* categoryWInvalidCounterSet = nullptr;
- BOOST_CHECK_THROW(categoryWInvalidCounterSet
- = counterDirectory.RegisterCategory(categoryWInvalidCounterSetName,
- armnn::EmptyOptional(),
- invalidCunterSetUid),
+ BOOST_CHECK_THROW(categoryWInvalidCounterSet = counterDirectory.RegisterCategory(
+ categoryWInvalidCounterSetName, armnn::EmptyOptional(), invalidCunterSetUid),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCategoryCount() == 4);
BOOST_CHECK(!categoryWInvalidCounterSet);
// Register a new category associated to a valid counter set
const std::string categoryWValidCounterSetName = "some_category_with_valid_counter_set";
- const Category* categoryWValidCounterSet = nullptr;
- BOOST_CHECK_NO_THROW(categoryWValidCounterSet
- = counterDirectory.RegisterCategory(categoryWValidCounterSetName,
- armnn::EmptyOptional(),
- counterSet->m_Uid));
+ const Category* categoryWValidCounterSet = nullptr;
+ BOOST_CHECK_NO_THROW(categoryWValidCounterSet = counterDirectory.RegisterCategory(
+ categoryWValidCounterSetName, armnn::EmptyOptional(), counterSet->m_Uid));
BOOST_CHECK(counterDirectory.GetCategoryCount() == 5);
BOOST_CHECK(categoryWValidCounterSet);
BOOST_CHECK(categoryWValidCounterSet != category);
@@ -893,11 +865,9 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCategory)
// Register a new category associated to a valid device and counter set
const std::string categoryWValidDeviceAndValidCounterSetName = "some_category_with_valid_device_and_counter_set";
- const Category* categoryWValidDeviceAndValidCounterSet = nullptr;
- BOOST_CHECK_NO_THROW(categoryWValidDeviceAndValidCounterSet
- = counterDirectory.RegisterCategory(categoryWValidDeviceAndValidCounterSetName,
- device->m_Uid,
- counterSet->m_Uid));
+ const Category* categoryWValidDeviceAndValidCounterSet = nullptr;
+ BOOST_CHECK_NO_THROW(categoryWValidDeviceAndValidCounterSet = counterDirectory.RegisterCategory(
+ categoryWValidDeviceAndValidCounterSetName, device->m_Uid, counterSet->m_Uid));
BOOST_CHECK(counterDirectory.GetCategoryCount() == 6);
BOOST_CHECK(categoryWValidDeviceAndValidCounterSet);
BOOST_CHECK(categoryWValidDeviceAndValidCounterSet != category);
@@ -909,10 +879,10 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCategory)
BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterDevice)
{
CounterDirectory counterDirectory;
- BOOST_CHECK(counterDirectory.GetCategoryCount() == 0);
- BOOST_CHECK(counterDirectory.GetDeviceCount() == 0);
+ BOOST_CHECK(counterDirectory.GetCategoryCount() == 0);
+ BOOST_CHECK(counterDirectory.GetDeviceCount() == 0);
BOOST_CHECK(counterDirectory.GetCounterSetCount() == 0);
- BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
+ BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
// Register a device with an invalid name
const Device* noDevice = nullptr;
@@ -927,7 +897,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterDevice)
// Register a new device with no cores or parent category
const std::string deviceName = "some_device";
- const Device* device = nullptr;
+ const Device* device = nullptr;
BOOST_CHECK_NO_THROW(device = counterDirectory.RegisterDevice(deviceName));
BOOST_CHECK(counterDirectory.GetDeviceCount() == 1);
BOOST_CHECK(device);
@@ -953,7 +923,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterDevice)
// Register a new device with cores and no parent category
const std::string deviceWCoresName = "some_device_with_cores";
- const Device* deviceWCores = nullptr;
+ const Device* deviceWCores = nullptr;
BOOST_CHECK_NO_THROW(deviceWCores = counterDirectory.RegisterDevice(deviceWCoresName, 2));
BOOST_CHECK(counterDirectory.GetDeviceCount() == 2);
BOOST_CHECK(deviceWCores);
@@ -971,29 +941,25 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterDevice)
// Register a new device with cores and invalid parent category
const std::string deviceWCoresWInvalidParentCategoryName = "some_device_with_cores_with_invalid_parent_category";
- const Device* deviceWCoresWInvalidParentCategory = nullptr;
- BOOST_CHECK_THROW(deviceWCoresWInvalidParentCategory
- = counterDirectory.RegisterDevice(deviceWCoresWInvalidParentCategoryName,
- 3,
- std::string("")),
+ const Device* deviceWCoresWInvalidParentCategory = nullptr;
+ BOOST_CHECK_THROW(deviceWCoresWInvalidParentCategory =
+ counterDirectory.RegisterDevice(deviceWCoresWInvalidParentCategoryName, 3, std::string("")),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetDeviceCount() == 2);
BOOST_CHECK(!deviceWCoresWInvalidParentCategory);
// Register a new device with cores and invalid parent category
const std::string deviceWCoresWInvalidParentCategoryName2 = "some_device_with_cores_with_invalid_parent_category2";
- const Device* deviceWCoresWInvalidParentCategory2 = nullptr;
- BOOST_CHECK_THROW(deviceWCoresWInvalidParentCategory2
- = counterDirectory.RegisterDevice(deviceWCoresWInvalidParentCategoryName2,
- 3,
- std::string("invalid_parent_category")),
+ const Device* deviceWCoresWInvalidParentCategory2 = nullptr;
+ BOOST_CHECK_THROW(deviceWCoresWInvalidParentCategory2 = counterDirectory.RegisterDevice(
+ deviceWCoresWInvalidParentCategoryName2, 3, std::string("invalid_parent_category")),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetDeviceCount() == 2);
BOOST_CHECK(!deviceWCoresWInvalidParentCategory2);
// Register a category for testing
const std::string categoryName = "some_category";
- const Category* category = nullptr;
+ const Category* category = nullptr;
BOOST_CHECK_NO_THROW(category = counterDirectory.RegisterCategory(categoryName));
BOOST_CHECK(counterDirectory.GetCategoryCount() == 1);
BOOST_CHECK(category);
@@ -1004,11 +970,9 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterDevice)
// Register a new device with cores and valid parent category
const std::string deviceWCoresWValidParentCategoryName = "some_device_with_cores_with_valid_parent_category";
- const Device* deviceWCoresWValidParentCategory = nullptr;
- BOOST_CHECK_NO_THROW(deviceWCoresWValidParentCategory
- = counterDirectory.RegisterDevice(deviceWCoresWValidParentCategoryName,
- 4,
- categoryName));
+ const Device* deviceWCoresWValidParentCategory = nullptr;
+ BOOST_CHECK_NO_THROW(deviceWCoresWValidParentCategory =
+ counterDirectory.RegisterDevice(deviceWCoresWValidParentCategoryName, 4, categoryName));
BOOST_CHECK(counterDirectory.GetDeviceCount() == 3);
BOOST_CHECK(deviceWCoresWValidParentCategory);
BOOST_CHECK(deviceWCoresWValidParentCategory->m_Name == deviceWCoresWValidParentCategoryName);
@@ -1020,7 +984,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterDevice)
// Register a device associated to a category already associated to a different device
const std::string deviceSameCategoryName = "some_device_with_invalid_parent_category";
- const Device* deviceSameCategory = nullptr;
+ const Device* deviceSameCategory = nullptr;
BOOST_CHECK_THROW(deviceSameCategory = counterDirectory.RegisterDevice(deviceSameCategoryName, 0, categoryName),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetDeviceCount() == 3);
@@ -1030,10 +994,10 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterDevice)
BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounterSet)
{
CounterDirectory counterDirectory;
- BOOST_CHECK(counterDirectory.GetCategoryCount() == 0);
- BOOST_CHECK(counterDirectory.GetDeviceCount() == 0);
+ BOOST_CHECK(counterDirectory.GetCategoryCount() == 0);
+ BOOST_CHECK(counterDirectory.GetDeviceCount() == 0);
BOOST_CHECK(counterDirectory.GetCounterSetCount() == 0);
- BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
+ BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
// Register a counter set with an invalid name
const CounterSet* noCounterSet = nullptr;
@@ -1049,7 +1013,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounterSet)
// Register a new counter set with no count or parent category
const std::string counterSetName = "some_counter_set";
- const CounterSet* counterSet = nullptr;
+ const CounterSet* counterSet = nullptr;
BOOST_CHECK_NO_THROW(counterSet = counterDirectory.RegisterCounterSet(counterSetName));
BOOST_CHECK(counterDirectory.GetCounterSetCount() == 1);
BOOST_CHECK(counterSet);
@@ -1076,7 +1040,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounterSet)
// Register a new counter set with count and no parent category
const std::string counterSetWCountName = "some_counter_set_with_count";
- const CounterSet* counterSetWCount = nullptr;
+ const CounterSet* counterSetWCount = nullptr;
BOOST_CHECK_NO_THROW(counterSetWCount = counterDirectory.RegisterCounterSet(counterSetWCountName, 37));
BOOST_CHECK(counterDirectory.GetCounterSetCount() == 2);
BOOST_CHECK(counterSetWCount);
@@ -1096,10 +1060,8 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounterSet)
const std::string counterSetWCountWInvalidParentCategoryName = "some_counter_set_with_count_"
"with_invalid_parent_category";
const CounterSet* counterSetWCountWInvalidParentCategory = nullptr;
- BOOST_CHECK_THROW(counterSetWCountWInvalidParentCategory
- = counterDirectory.RegisterCounterSet(counterSetWCountWInvalidParentCategoryName,
- 42,
- std::string("")),
+ BOOST_CHECK_THROW(counterSetWCountWInvalidParentCategory = counterDirectory.RegisterCounterSet(
+ counterSetWCountWInvalidParentCategoryName, 42, std::string("")),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterSetCount() == 2);
BOOST_CHECK(!counterSetWCountWInvalidParentCategory);
@@ -1108,17 +1070,15 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounterSet)
const std::string counterSetWCountWInvalidParentCategoryName2 = "some_counter_set_with_count_"
"with_invalid_parent_category2";
const CounterSet* counterSetWCountWInvalidParentCategory2 = nullptr;
- BOOST_CHECK_THROW(counterSetWCountWInvalidParentCategory2
- = counterDirectory.RegisterCounterSet(counterSetWCountWInvalidParentCategoryName2,
- 42,
- std::string("invalid_parent_category")),
+ BOOST_CHECK_THROW(counterSetWCountWInvalidParentCategory2 = counterDirectory.RegisterCounterSet(
+ counterSetWCountWInvalidParentCategoryName2, 42, std::string("invalid_parent_category")),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterSetCount() == 2);
BOOST_CHECK(!counterSetWCountWInvalidParentCategory2);
// Register a category for testing
const std::string categoryName = "some_category";
- const Category* category = nullptr;
+ const Category* category = nullptr;
BOOST_CHECK_NO_THROW(category = counterDirectory.RegisterCategory(categoryName));
BOOST_CHECK(counterDirectory.GetCategoryCount() == 1);
BOOST_CHECK(category);
@@ -1131,10 +1091,8 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounterSet)
const std::string counterSetWCountWValidParentCategoryName = "some_counter_set_with_count_"
"with_valid_parent_category";
const CounterSet* counterSetWCountWValidParentCategory = nullptr;
- BOOST_CHECK_NO_THROW(counterSetWCountWValidParentCategory
- = counterDirectory.RegisterCounterSet(counterSetWCountWValidParentCategoryName,
- 42,
- categoryName));
+ BOOST_CHECK_NO_THROW(counterSetWCountWValidParentCategory = counterDirectory.RegisterCounterSet(
+ counterSetWCountWValidParentCategoryName, 42, categoryName));
BOOST_CHECK(counterDirectory.GetCounterSetCount() == 3);
BOOST_CHECK(counterSetWCountWValidParentCategory);
BOOST_CHECK(counterSetWCountWValidParentCategory->m_Name == counterSetWCountWValidParentCategoryName);
@@ -1146,10 +1104,9 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounterSet)
// Register a counter set associated to a category already associated to a different counter set
const std::string counterSetSameCategoryName = "some_counter_set_with_invalid_parent_category";
- const CounterSet* counterSetSameCategory = nullptr;
- BOOST_CHECK_THROW(counterSetSameCategory = counterDirectory.RegisterCounterSet(counterSetSameCategoryName,
- 0,
- categoryName),
+ const CounterSet* counterSetSameCategory = nullptr;
+ BOOST_CHECK_THROW(counterSetSameCategory =
+ counterDirectory.RegisterCounterSet(counterSetSameCategoryName, 0, categoryName),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterSetCount() == 3);
BOOST_CHECK(!counterSetSameCategory);
@@ -1158,130 +1115,85 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounterSet)
BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
{
CounterDirectory counterDirectory;
- BOOST_CHECK(counterDirectory.GetCategoryCount() == 0);
- BOOST_CHECK(counterDirectory.GetDeviceCount() == 0);
+ BOOST_CHECK(counterDirectory.GetCategoryCount() == 0);
+ BOOST_CHECK(counterDirectory.GetDeviceCount() == 0);
BOOST_CHECK(counterDirectory.GetCounterSetCount() == 0);
- BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
+ BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
// Register a counter with an invalid parent category name
const Counter* noCounter = nullptr;
- BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("",
- 0,
- 1,
- 123.45f,
- "valid name",
- "valid description"),
+ BOOST_CHECK_THROW(noCounter =
+ counterDirectory.RegisterCounter("", 0, 1, 123.45f, "valid name", "valid description"),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
BOOST_CHECK(!noCounter);
// Register a counter with an invalid parent category name
- BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("invalid parent category",
- 0,
- 1,
- 123.45f,
- "valid name",
- "valid description"),
+ BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("invalid parent category", 0, 1, 123.45f,
+ "valid name", "valid description"),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
BOOST_CHECK(!noCounter);
// Register a counter with an invalid class
- BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category",
- 2,
- 1,
- 123.45f,
- "valid name",
+ BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category", 2, 1, 123.45f, "valid name",
"valid description"),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
BOOST_CHECK(!noCounter);
// Register a counter with an invalid interpolation
- BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category",
- 0,
- 3,
- 123.45f,
- "valid name",
+ BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category", 0, 3, 123.45f, "valid name",
"valid description"),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
BOOST_CHECK(!noCounter);
// Register a counter with an invalid multiplier
- BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category",
- 0,
- 1,
- .0f,
- "valid name",
+ BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category", 0, 1, .0f, "valid name",
"valid description"),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
BOOST_CHECK(!noCounter);
// Register a counter with an invalid name
- BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category",
- 0,
- 1,
- 123.45f,
- "",
- "valid description"),
- armnn::InvalidArgumentException);
+ BOOST_CHECK_THROW(
+ noCounter = counterDirectory.RegisterCounter("valid_parent_category", 0, 1, 123.45f, "", "valid description"),
+ armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
BOOST_CHECK(!noCounter);
// Register a counter with an invalid name
- BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category",
- 0,
- 1,
- 123.45f,
- "invalid nam€",
- "valid description"),
+ BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category", 0, 1, 123.45f,
+ "invalid nam€", "valid description"),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
BOOST_CHECK(!noCounter);
// Register a counter with an invalid description
- BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category",
- 0,
- 1,
- 123.45f,
- "valid name",
- ""),
+ BOOST_CHECK_THROW(noCounter =
+ counterDirectory.RegisterCounter("valid_parent_category", 0, 1, 123.45f, "valid name", ""),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
BOOST_CHECK(!noCounter);
// Register a counter with an invalid description
- BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category",
- 0,
- 1,
- 123.45f,
- "valid name",
+ BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category", 0, 1, 123.45f, "valid name",
"inv@lid description"),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
BOOST_CHECK(!noCounter);
// Register a counter with an invalid unit2
- BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category",
- 0,
- 1,
- 123.45f,
- "valid name",
- "valid description",
- std::string("Mb/s2")),
+ BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("valid_parent_category", 0, 1, 123.45f, "valid name",
+ "valid description", std::string("Mb/s2")),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
BOOST_CHECK(!noCounter);
// Register a counter with a non-existing parent category name
- BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("invalid_parent_category",
- 0,
- 1,
- 123.45f,
- "valid name",
- "valid description"),
+ BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter("invalid_parent_category", 0, 1, 123.45f,
+ "valid name", "valid description"),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterCount() == 0);
BOOST_CHECK(!noCounter);
@@ -1292,7 +1204,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a category for testing
const std::string categoryName = "some_category";
- const Category* category = nullptr;
+ const Category* category = nullptr;
BOOST_CHECK_NO_THROW(category = counterDirectory.RegisterCategory(categoryName));
BOOST_CHECK(counterDirectory.GetCategoryCount() == 1);
BOOST_CHECK(category);
@@ -1303,12 +1215,8 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a counter with a valid parent category name
const Counter* counter = nullptr;
- BOOST_CHECK_NO_THROW(counter = counterDirectory.RegisterCounter(categoryName,
- 0,
- 1,
- 123.45f,
- "valid name",
- "valid description"));
+ BOOST_CHECK_NO_THROW(
+ counter = counterDirectory.RegisterCounter(categoryName, 0, 1, 123.45f, "valid name", "valid description"));
BOOST_CHECK(counterDirectory.GetCounterCount() == 1);
BOOST_CHECK(counter);
BOOST_CHECK(counter->m_Uid >= 0);
@@ -1326,25 +1234,17 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a counter with a name of a counter already registered for the given parent category name
const Counter* counterSameName = nullptr;
- BOOST_CHECK_THROW(counterSameName = counterDirectory.RegisterCounter(categoryName,
- 0,
- 0,
- 1.0f,
- "valid name",
- "valid description"),
+ BOOST_CHECK_THROW(counterSameName =
+ counterDirectory.RegisterCounter(categoryName, 0, 0, 1.0f, "valid name", "valid description"),
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterCount() == 1);
BOOST_CHECK(!counterSameName);
// Register a counter with a valid parent category name and units
const Counter* counterWUnits = nullptr;
- BOOST_CHECK_NO_THROW(counterWUnits = counterDirectory.RegisterCounter(categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 2",
+ BOOST_CHECK_NO_THROW(counterWUnits = counterDirectory.RegisterCounter(categoryName, 0, 1, 123.45f, "valid name 2",
"valid description",
- std::string("Mnnsq2"))); // Units
+ std::string("Mnnsq2"))); // Units
BOOST_CHECK(counterDirectory.GetCounterCount() == 2);
BOOST_CHECK(counterWUnits);
BOOST_CHECK(counterWUnits->m_Uid >= 0);
@@ -1363,15 +1263,11 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a counter with a valid parent category name and not associated with a device
const Counter* counterWoDevice = nullptr;
- BOOST_CHECK_NO_THROW(counterWoDevice = counterDirectory.RegisterCounter(categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 3",
- "valid description",
- armnn::EmptyOptional(), // Units
- armnn::EmptyOptional(), // Number of cores
- 0)); // Device UID
+ BOOST_CHECK_NO_THROW(counterWoDevice = counterDirectory.RegisterCounter(
+ categoryName, 0, 1, 123.45f, "valid name 3", "valid description",
+ armnn::EmptyOptional(), // Units
+ armnn::EmptyOptional(), // Number of cores
+ 0)); // Device UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 3);
BOOST_CHECK(counterWoDevice);
BOOST_CHECK(counterWoDevice->m_Uid >= 0);
@@ -1389,22 +1285,18 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
BOOST_CHECK(category->m_Counters.back() == counterWoDevice->m_Uid);
// Register a counter with a valid parent category name and associated to an invalid device
- BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 4",
+ BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(categoryName, 0, 1, 123.45f, "valid name 4",
"valid description",
- armnn::EmptyOptional(), // Units
- armnn::EmptyOptional(), // Number of cores
- 100), // Device UID
+ armnn::EmptyOptional(), // Units
+ armnn::EmptyOptional(), // Number of cores
+ 100), // Device UID
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterCount() == 3);
BOOST_CHECK(!noCounter);
// Register a device for testing
const std::string deviceName = "some_device";
- const Device* device = nullptr;
+ const Device* device = nullptr;
BOOST_CHECK_NO_THROW(device = counterDirectory.RegisterDevice(deviceName));
BOOST_CHECK(counterDirectory.GetDeviceCount() == 1);
BOOST_CHECK(device);
@@ -1414,15 +1306,11 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a counter with a valid parent category name and associated to a device
const Counter* counterWDevice = nullptr;
- BOOST_CHECK_NO_THROW(counterWDevice = counterDirectory.RegisterCounter(categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 5",
+ BOOST_CHECK_NO_THROW(counterWDevice = counterDirectory.RegisterCounter(categoryName, 0, 1, 123.45f, "valid name 5",
"valid description",
- armnn::EmptyOptional(), // Units
- armnn::EmptyOptional(), // Number of cores
- device->m_Uid)); // Device UID
+ armnn::EmptyOptional(), // Units
+ armnn::EmptyOptional(), // Number of cores
+ device->m_Uid)); // Device UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 4);
BOOST_CHECK(counterWDevice);
BOOST_CHECK(counterWDevice->m_Uid >= 0);
@@ -1441,17 +1329,12 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a counter with a valid parent category name and not associated with a counter set
const Counter* counterWoCounterSet = nullptr;
- BOOST_CHECK_NO_THROW(counterWoCounterSet
- = counterDirectory.RegisterCounter(categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 6",
- "valid description",
- armnn::EmptyOptional(), // Units
- armnn::EmptyOptional(), // Number of cores
- armnn::EmptyOptional(), // Device UID
- 0)); // Counter set UID
+ BOOST_CHECK_NO_THROW(counterWoCounterSet = counterDirectory.RegisterCounter(
+ categoryName, 0, 1, 123.45f, "valid name 6", "valid description",
+ armnn::EmptyOptional(), // Units
+ armnn::EmptyOptional(), // Number of cores
+ armnn::EmptyOptional(), // Device UID
+ 0)); // Counter set UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 5);
BOOST_CHECK(counterWoCounterSet);
BOOST_CHECK(counterWoCounterSet->m_Uid >= 0);
@@ -1469,34 +1352,25 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
BOOST_CHECK(category->m_Counters.back() == counterWoCounterSet->m_Uid);
// Register a counter with a valid parent category name and associated to an invalid counter set
- BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 7",
+ BOOST_CHECK_THROW(noCounter = counterDirectory.RegisterCounter(categoryName, 0, 1, 123.45f, "valid name 7",
"valid description",
- armnn::EmptyOptional(), // Units
- armnn::EmptyOptional(), // Number of cores
- armnn::EmptyOptional(), // Device UID
- 100), // Counter set UID
+ armnn::EmptyOptional(), // Units
+ armnn::EmptyOptional(), // Number of cores
+ armnn::EmptyOptional(), // Device UID
+ 100), // Counter set UID
armnn::InvalidArgumentException);
BOOST_CHECK(counterDirectory.GetCounterCount() == 5);
BOOST_CHECK(!noCounter);
// Register a counter with a valid parent category name and with a given number of cores
const Counter* counterWNumberOfCores = nullptr;
- uint16_t numberOfCores = 15;
- BOOST_CHECK_NO_THROW(counterWNumberOfCores
- = counterDirectory.RegisterCounter(categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 8",
- "valid description",
- armnn::EmptyOptional(), // Units
- numberOfCores, // Number of cores
- armnn::EmptyOptional(), // Device UID
- armnn::EmptyOptional())); // Counter set UID
+ uint16_t numberOfCores = 15;
+ BOOST_CHECK_NO_THROW(counterWNumberOfCores = counterDirectory.RegisterCounter(
+ categoryName, 0, 1, 123.45f, "valid name 8", "valid description",
+ armnn::EmptyOptional(), // Units
+ numberOfCores, // Number of cores
+ armnn::EmptyOptional(), // Device UID
+ armnn::EmptyOptional())); // Counter set UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 20);
BOOST_CHECK(counterWNumberOfCores);
BOOST_CHECK(counterWNumberOfCores->m_Uid >= 0);
@@ -1511,7 +1385,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
BOOST_CHECK(counterWNumberOfCores->m_DeviceUid == 0);
BOOST_CHECK(counterWNumberOfCores->m_CounterSetUid == 0);
BOOST_CHECK(category->m_Counters.size() == 20);
- for (size_t i = 0; i < numberOfCores; i ++)
+ for (size_t i = 0; i < numberOfCores; i++)
{
BOOST_CHECK(category->m_Counters[category->m_Counters.size() - numberOfCores + i] ==
counterWNumberOfCores->m_Uid + i);
@@ -1519,7 +1393,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a multi-core device for testing
const std::string multiCoreDeviceName = "some_multi_core_device";
- const Device* multiCoreDevice = nullptr;
+ const Device* multiCoreDevice = nullptr;
BOOST_CHECK_NO_THROW(multiCoreDevice = counterDirectory.RegisterDevice(multiCoreDeviceName, 4));
BOOST_CHECK(counterDirectory.GetDeviceCount() == 2);
BOOST_CHECK(multiCoreDevice);
@@ -1529,17 +1403,12 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a counter with a valid parent category name and associated to the multi-core device
const Counter* counterWMultiCoreDevice = nullptr;
- BOOST_CHECK_NO_THROW(counterWMultiCoreDevice
- = counterDirectory.RegisterCounter(categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 9",
- "valid description",
- armnn::EmptyOptional(), // Units
- armnn::EmptyOptional(), // Number of cores
- multiCoreDevice->m_Uid, // Device UID
- armnn::EmptyOptional())); // Counter set UID
+ BOOST_CHECK_NO_THROW(counterWMultiCoreDevice = counterDirectory.RegisterCounter(
+ categoryName, 0, 1, 123.45f, "valid name 9", "valid description",
+ armnn::EmptyOptional(), // Units
+ armnn::EmptyOptional(), // Number of cores
+ multiCoreDevice->m_Uid, // Device UID
+ armnn::EmptyOptional())); // Counter set UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 24);
BOOST_CHECK(counterWMultiCoreDevice);
BOOST_CHECK(counterWMultiCoreDevice->m_Uid >= 0);
@@ -1555,16 +1424,16 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
BOOST_CHECK(counterWMultiCoreDevice->m_DeviceUid == multiCoreDevice->m_Uid);
BOOST_CHECK(counterWMultiCoreDevice->m_CounterSetUid == 0);
BOOST_CHECK(category->m_Counters.size() == 24);
- for (size_t i = 0; i < 4; i ++)
+ for (size_t i = 0; i < 4; i++)
{
BOOST_CHECK(category->m_Counters[category->m_Counters.size() - 4 + i] == counterWMultiCoreDevice->m_Uid + i);
}
// Register a multi-core device associate to a parent category for testing
const std::string multiCoreDeviceNameWParentCategory = "some_multi_core_device_with_parent_category";
- const Device* multiCoreDeviceWParentCategory = nullptr;
+ const Device* multiCoreDeviceWParentCategory = nullptr;
BOOST_CHECK_NO_THROW(multiCoreDeviceWParentCategory =
- counterDirectory.RegisterDevice(multiCoreDeviceNameWParentCategory, 2, categoryName));
+ counterDirectory.RegisterDevice(multiCoreDeviceNameWParentCategory, 2, categoryName));
BOOST_CHECK(counterDirectory.GetDeviceCount() == 3);
BOOST_CHECK(multiCoreDeviceWParentCategory);
BOOST_CHECK(multiCoreDeviceWParentCategory->m_Name == multiCoreDeviceNameWParentCategory);
@@ -1574,17 +1443,12 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a counter with a valid parent category name and getting the number of cores of the multi-core device
// associated to that category
const Counter* counterWMultiCoreDeviceWParentCategory = nullptr;
- BOOST_CHECK_NO_THROW(counterWMultiCoreDeviceWParentCategory
- = counterDirectory.RegisterCounter(categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 10",
- "valid description",
- armnn::EmptyOptional(), // Units
- armnn::EmptyOptional(), // Number of cores
- armnn::EmptyOptional(), // Device UID
- armnn::EmptyOptional())); // Counter set UID
+ BOOST_CHECK_NO_THROW(counterWMultiCoreDeviceWParentCategory = counterDirectory.RegisterCounter(
+ categoryName, 0, 1, 123.45f, "valid name 10", "valid description",
+ armnn::EmptyOptional(), // Units
+ armnn::EmptyOptional(), // Number of cores
+ armnn::EmptyOptional(), // Device UID
+ armnn::EmptyOptional())); // Counter set UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 26);
BOOST_CHECK(counterWMultiCoreDeviceWParentCategory);
BOOST_CHECK(counterWMultiCoreDeviceWParentCategory->m_Uid >= 0);
@@ -1600,7 +1464,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
BOOST_CHECK(counterWMultiCoreDeviceWParentCategory->m_DeviceUid == 0);
BOOST_CHECK(counterWMultiCoreDeviceWParentCategory->m_CounterSetUid == 0);
BOOST_CHECK(category->m_Counters.size() == 26);
- for (size_t i = 0; i < 2; i ++)
+ for (size_t i = 0; i < 2; i++)
{
BOOST_CHECK(category->m_Counters[category->m_Counters.size() - 2 + i] ==
counterWMultiCoreDeviceWParentCategory->m_Uid + i);
@@ -1608,7 +1472,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a counter set for testing
const std::string counterSetName = "some_counter_set";
- const CounterSet* counterSet = nullptr;
+ const CounterSet* counterSet = nullptr;
BOOST_CHECK_NO_THROW(counterSet = counterDirectory.RegisterCounterSet(counterSetName));
BOOST_CHECK(counterDirectory.GetCounterSetCount() == 1);
BOOST_CHECK(counterSet);
@@ -1618,17 +1482,12 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a counter with a valid parent category name and associated to a counter set
const Counter* counterWCounterSet = nullptr;
- BOOST_CHECK_NO_THROW(counterWCounterSet
- = counterDirectory.RegisterCounter(categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 11",
- "valid description",
- armnn::EmptyOptional(), // Units
- 0, // Number of cores
- armnn::EmptyOptional(), // Device UID
- counterSet->m_Uid)); // Counter set UID
+ BOOST_CHECK_NO_THROW(counterWCounterSet = counterDirectory.RegisterCounter(
+ categoryName, 0, 1, 123.45f, "valid name 11", "valid description",
+ armnn::EmptyOptional(), // Units
+ 0, // Number of cores
+ armnn::EmptyOptional(), // Device UID
+ counterSet->m_Uid)); // Counter set UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 27);
BOOST_CHECK(counterWCounterSet);
BOOST_CHECK(counterWCounterSet->m_Uid >= 0);
@@ -1647,17 +1506,12 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a counter with a valid parent category name and associated to a device and a counter set
const Counter* counterWDeviceWCounterSet = nullptr;
- BOOST_CHECK_NO_THROW(counterWDeviceWCounterSet
- = counterDirectory.RegisterCounter(categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 12",
- "valid description",
- armnn::EmptyOptional(), // Units
- 1, // Number of cores
- device->m_Uid, // Device UID
- counterSet->m_Uid)); // Counter set UID
+ BOOST_CHECK_NO_THROW(counterWDeviceWCounterSet = counterDirectory.RegisterCounter(
+ categoryName, 0, 1, 123.45f, "valid name 12", "valid description",
+ armnn::EmptyOptional(), // Units
+ 1, // Number of cores
+ device->m_Uid, // Device UID
+ counterSet->m_Uid)); // Counter set UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 28);
BOOST_CHECK(counterWDeviceWCounterSet);
BOOST_CHECK(counterWDeviceWCounterSet->m_Uid >= 0);
@@ -1676,7 +1530,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register another category for testing
const std::string anotherCategoryName = "some_other_category";
- const Category* anotherCategory = nullptr;
+ const Category* anotherCategory = nullptr;
BOOST_CHECK_NO_THROW(anotherCategory = counterDirectory.RegisterCategory(anotherCategoryName));
BOOST_CHECK(counterDirectory.GetCategoryCount() == 2);
BOOST_CHECK(anotherCategory);
@@ -1688,16 +1542,12 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a counter to the other category
const Counter* anotherCounter = nullptr;
- BOOST_CHECK_NO_THROW(anotherCounter = counterDirectory.RegisterCounter(anotherCategoryName,
- 1,
- 0,
- .00043f,
- "valid name",
- "valid description",
- armnn::EmptyOptional(), // Units
- armnn::EmptyOptional(), // Number of cores
- device->m_Uid, // Device UID
- counterSet->m_Uid)); // Counter set UID
+ BOOST_CHECK_NO_THROW(anotherCounter = counterDirectory.RegisterCounter(anotherCategoryName, 1, 0, .00043f,
+ "valid name", "valid description",
+ armnn::EmptyOptional(), // Units
+ armnn::EmptyOptional(), // Number of cores
+ device->m_Uid, // Device UID
+ counterSet->m_Uid)); // Counter set UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 29);
BOOST_CHECK(anotherCounter);
BOOST_CHECK(anotherCounter->m_Uid >= 0);
@@ -1722,15 +1572,26 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData)
class TestCaptureThread : public IPeriodicCounterCapture
{
- void Start() override {}
- void Stop() override {}
+ void Start() override
+ {}
+ void Stop() override
+ {}
};
class TestReadCounterValues : public IReadCounterValues
{
- bool IsCounterRegistered(uint16_t counterUid) const override { return true; }
- uint16_t GetCounterCount() const override { return 0; }
- uint32_t GetCounterValue(uint16_t counterUid) const override { return 0; }
+ bool IsCounterRegistered(uint16_t counterUid) const override
+ {
+ return true;
+ }
+ uint16_t GetCounterCount() const override
+ {
+ return 0;
+ }
+ uint32_t GetCounterValue(uint16_t counterUid) const override
+ {
+ return 0;
+ }
};
const uint32_t familyId = 0;
const uint32_t packetId = 0x40000;
@@ -1746,12 +1607,12 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData)
uint32_t sizeOfUint16 = numeric_cast<uint32_t>(sizeof(uint16_t));
// Data with period and counters
- uint32_t period1 = 10;
+ uint32_t period1 = 10;
uint32_t dataLength1 = 8;
- uint32_t offset = 0;
+ uint32_t offset = 0;
std::unique_ptr<unsigned char[]> uniqueData1 = std::make_unique<unsigned char[]>(dataLength1);
- unsigned char* data1 = reinterpret_cast<unsigned char*>(uniqueData1.get());
+ unsigned char* data1 = reinterpret_cast<unsigned char*>(uniqueData1.get());
WriteUint32(data1, offset, period1);
offset += sizeOfUint32;
@@ -1761,14 +1622,8 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData)
Packet packetA(packetId, dataLength1, uniqueData1);
- PeriodicCounterSelectionCommandHandler commandHandler(familyId,
- packetId,
- version,
- holder,
- captureThread,
- readCounterValues,
- sendCounterPacket,
- profilingStateMachine);
+ PeriodicCounterSelectionCommandHandler commandHandler(familyId, packetId, version, holder, captureThread,
+ readCounterValues, sendCounterPacket, profilingStateMachine);
profilingStateMachine.TransitionToState(ProfilingState::Uninitialised);
BOOST_CHECK_THROW(commandHandler(packetA), armnn::RuntimeException);
@@ -1796,10 +1651,10 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData)
offset += sizeOfUint32;
uint32_t period = ReadUint32(readBuffer, offset);
- BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0); // packet family
- BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 4); // packet id
- BOOST_TEST(headerWord1 == 8); // data lenght
- BOOST_TEST(period == 10); // capture period
+ BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0); // packet family
+ BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 4); // packet id
+ BOOST_TEST(headerWord1 == 8); // data lenght
+ BOOST_TEST(period == 10); // capture period
uint16_t counterId = 0;
offset += sizeOfUint32;
@@ -1812,7 +1667,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData)
mockBuffer.MarkRead(readBuffer);
// Data with period only
- uint32_t period2 = 11;
+ uint32_t period2 = 11;
uint32_t dataLength2 = 4;
std::unique_ptr<unsigned char[]> uniqueData2 = std::make_unique<unsigned char[]>(dataLength2);
@@ -1838,30 +1693,30 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData)
offset += sizeOfUint32;
period = ReadUint32(readBuffer, offset);
- BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0); // packet family
- BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 4); // packet id
- BOOST_TEST(headerWord1 == 4); // data length
- BOOST_TEST(period == 11); // capture period
+ BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0); // packet family
+ BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 4); // packet id
+ BOOST_TEST(headerWord1 == 4); // data length
+ BOOST_TEST(period == 11); // capture period
}
BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged)
{
using boost::numeric_cast;
- const uint32_t packetFamilyId = 0;
+ const uint32_t packetFamilyId = 0;
const uint32_t connectionPacketId = 0x10000;
- const uint32_t version = 1;
+ const uint32_t version = 1;
uint32_t sizeOfUint32 = numeric_cast<uint32_t>(sizeof(uint32_t));
uint32_t sizeOfUint16 = numeric_cast<uint32_t>(sizeof(uint16_t));
// Data with period and counters
- uint32_t period1 = 10;
+ uint32_t period1 = 10;
uint32_t dataLength1 = 8;
- uint32_t offset = 0;
+ uint32_t offset = 0;
std::unique_ptr<unsigned char[]> uniqueData1 = std::make_unique<unsigned char[]>(dataLength1);
- unsigned char* data1 = reinterpret_cast<unsigned char*>(uniqueData1.get());
+ unsigned char* data1 = reinterpret_cast<unsigned char*>(uniqueData1.get());
WriteUint32(data1, offset, period1);
offset += sizeOfUint32;
@@ -1873,8 +1728,12 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged)
ProfilingStateMachine profilingState(ProfilingState::Uninitialised);
BOOST_CHECK(profilingState.GetCurrentState() == ProfilingState::Uninitialised);
+ CounterDirectory counterDirectory;
+ MockBufferManager mockBuffer(1024);
+ SendCounterPacket sendCounterPacket(profilingState, mockBuffer);
- ConnectionAcknowledgedCommandHandler commandHandler(packetFamilyId, connectionPacketId, version, profilingState);
+ ConnectionAcknowledgedCommandHandler commandHandler(packetFamilyId, connectionPacketId, version, counterDirectory,
+ sendCounterPacket, profilingState);
// command handler received packet on ProfilingState::Uninitialised
BOOST_CHECK_THROW(commandHandler(packetA), armnn::Exception);
@@ -1899,8 +1758,8 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged)
Packet packetB(differentPacketId, dataLength1, uniqueData1);
profilingState.TransitionToState(ProfilingState::NotConnected);
profilingState.TransitionToState(ProfilingState::WaitingForAck);
- ConnectionAcknowledgedCommandHandler differentCommandHandler(
- packetFamilyId, differentPacketId, version, profilingState);
+ ConnectionAcknowledgedCommandHandler differentCommandHandler(packetFamilyId, differentPacketId, version,
+ counterDirectory, sendCounterPacket, profilingState);
BOOST_CHECK_THROW(differentCommandHandler(packetB), armnn::Exception);
}
@@ -2021,7 +1880,7 @@ void StringToSwTraceStringTestHelper(const std::string& testString, std::vector<
// The buffer must include the null-terminator at the end of the string
size_t nullTerminatorIndex = sizeof(uint32_t) + testString.size();
- BOOST_CHECK(reinterpret_cast<unsigned char*>(buffer.data())[nullTerminatorIndex] == '\0');
+ BOOST_CHECK(reinterpret_cast<unsigned char*>(buffer.data())[nullTerminatorIndex] == '\0');
}
BOOST_AUTO_TEST_CASE(StringToSwTraceStringTest)
@@ -2083,7 +1942,7 @@ BOOST_AUTO_TEST_CASE(CheckPeriodicCounterCaptureThread)
public:
CaptureReader(uint16_t counterSize)
{
- for(uint16_t i = 0; i < counterSize; ++i)
+ for (uint16_t i = 0; i < counterSize; ++i)
{
m_Data[i] = 0;
}
@@ -2102,7 +1961,7 @@ BOOST_AUTO_TEST_CASE(CheckPeriodicCounterCaptureThread)
uint32_t GetCounterValue(uint16_t counterUid) const override
{
- if(counterUid > m_CounterSize)
+ if (counterUid > m_CounterSize)
{
BOOST_FAIL("Invalid counter Uid");
}
@@ -2111,7 +1970,7 @@ BOOST_AUTO_TEST_CASE(CheckPeriodicCounterCaptureThread)
void SetCounterValue(uint16_t counterUid, uint32_t value)
{
- if(counterUid > m_CounterSize)
+ if (counterUid > m_CounterSize)
{
BOOST_FAIL("Invalid counter Uid");
}
@@ -2135,8 +1994,8 @@ BOOST_AUTO_TEST_CASE(CheckPeriodicCounterCaptureThread)
std::vector<uint16_t> counterIds;
CaptureReader captureReader(2);
- unsigned int valueA = 10;
- unsigned int valueB = 15;
+ unsigned int valueA = 10;
+ unsigned int valueB = 15;
unsigned int numSteps = 5;
PeriodicCounterCapture periodicCounterCapture(std::ref(data), std::ref(sendCounterPacket), captureReader);
@@ -2156,12 +2015,12 @@ BOOST_AUTO_TEST_CASE(CheckPeriodicCounterCaptureThread)
uint32_t headerWord0 = ReadUint32(buffer, 0);
uint32_t headerWord1 = ReadUint32(buffer, 4);
- BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 1); // packet family
- BOOST_TEST(((headerWord0 >> 19) & 0x0000007F) == 0); // packet class
- BOOST_TEST(((headerWord0 >> 16) & 0x00000007) == 0); // packet type
+ BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 1); // packet family
+ BOOST_TEST(((headerWord0 >> 19) & 0x0000007F) == 0); // packet class
+ BOOST_TEST(((headerWord0 >> 16) & 0x00000007) == 0); // packet type
BOOST_TEST(headerWord1 == 20);
- uint32_t offset = 16;
+ uint32_t offset = 16;
uint16_t readIndex = ReadUint16(buffer, offset);
BOOST_TEST(0 == readIndex);
@@ -2184,50 +2043,46 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1)
const uint32_t familyId = 0;
const uint32_t packetId = 3;
- const uint32_t version = 1;
+ const uint32_t version = 1;
ProfilingStateMachine profilingStateMachine;
CounterDirectory counterDirectory;
MockBufferManager mockBuffer(1024);
SendCounterPacket sendCounterPacket(profilingStateMachine, mockBuffer);
- RequestCounterDirectoryCommandHandler commandHandler(familyId,
- packetId,
- version,
- counterDirectory,
- sendCounterPacket,
- profilingStateMachine);
+ RequestCounterDirectoryCommandHandler commandHandler(familyId, packetId, version, counterDirectory,
+ sendCounterPacket, profilingStateMachine);
const uint32_t wrongPacketId = 47;
- const uint32_t wrongHeader = (wrongPacketId & 0x000003FF) << 16;
+ const uint32_t wrongHeader = (wrongPacketId & 0x000003FF) << 16;
Packet wrongPacket(wrongHeader);
profilingStateMachine.TransitionToState(ProfilingState::Uninitialised);
- BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state
+ BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state
profilingStateMachine.TransitionToState(ProfilingState::NotConnected);
- BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state
+ BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state
profilingStateMachine.TransitionToState(ProfilingState::WaitingForAck);
- BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state
+ BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state
profilingStateMachine.TransitionToState(ProfilingState::Active);
- BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::InvalidArgumentException); // Wrong packet
+ BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::InvalidArgumentException); // Wrong packet
const uint32_t rightHeader = (packetId & 0x000003FF) << 16;
Packet rightPacket(rightHeader);
- BOOST_CHECK_NO_THROW(commandHandler(rightPacket)); // Right packet
+ BOOST_CHECK_NO_THROW(commandHandler(rightPacket)); // Right packet
auto readBuffer = mockBuffer.GetReadableBuffer();
uint32_t headerWord0 = ReadUint32(readBuffer, 0);
uint32_t headerWord1 = ReadUint32(readBuffer, 4);
- BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 0); // packet family
- BOOST_TEST(((headerWord0 >> 16) & 0x000003FF) == 2); // packet id
- BOOST_TEST(headerWord1 == 24); // data length
+ BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 0); // packet family
+ BOOST_TEST(((headerWord0 >> 16) & 0x000003FF) == 2); // packet id
+ BOOST_TEST(headerWord1 == 24); // data length
- uint32_t bodyHeaderWord0 = ReadUint32(readBuffer, 8);
+ uint32_t bodyHeaderWord0 = ReadUint32(readBuffer, 8);
uint16_t deviceRecordCount = numeric_cast<uint16_t>(bodyHeaderWord0 >> 16);
- BOOST_TEST(deviceRecordCount == 0); // device_records_count
+ BOOST_TEST(deviceRecordCount == 0); // device_records_count
}
BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2)
@@ -2236,32 +2091,28 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2)
const uint32_t familyId = 0;
const uint32_t packetId = 3;
- const uint32_t version = 1;
+ const uint32_t version = 1;
ProfilingStateMachine profilingStateMachine;
CounterDirectory counterDirectory;
MockBufferManager mockBuffer(1024);
SendCounterPacket sendCounterPacket(profilingStateMachine, mockBuffer);
- RequestCounterDirectoryCommandHandler commandHandler(familyId,
- packetId,
- version,
- counterDirectory,
- sendCounterPacket,
- profilingStateMachine);
+ RequestCounterDirectoryCommandHandler commandHandler(familyId, packetId, version, counterDirectory,
+ sendCounterPacket, profilingStateMachine);
const uint32_t header = (packetId & 0x000003FF) << 16;
Packet packet(header);
- const Device* device = counterDirectory.RegisterDevice("deviceA", 1);
+ const Device* device = counterDirectory.RegisterDevice("deviceA", 1);
const CounterSet* counterSet = counterDirectory.RegisterCounterSet("countersetA");
counterDirectory.RegisterCategory("categoryA", device->m_Uid, counterSet->m_Uid);
counterDirectory.RegisterCounter("categoryA", 0, 1, 2.0f, "counterA", "descA");
counterDirectory.RegisterCounter("categoryA", 1, 1, 3.0f, "counterB", "descB");
profilingStateMachine.TransitionToState(ProfilingState::Uninitialised);
- BOOST_CHECK_THROW(commandHandler(packet), armnn::RuntimeException); // Wrong profiling state
+ BOOST_CHECK_THROW(commandHandler(packet), armnn::RuntimeException); // Wrong profiling state
profilingStateMachine.TransitionToState(ProfilingState::NotConnected);
- BOOST_CHECK_THROW(commandHandler(packet), armnn::RuntimeException); // Wrong profiling state
+ BOOST_CHECK_THROW(commandHandler(packet), armnn::RuntimeException); // Wrong profiling state
profilingStateMachine.TransitionToState(ProfilingState::WaitingForAck);
- BOOST_CHECK_THROW(commandHandler(packet), armnn::RuntimeException); // Wrong profiling state
+ BOOST_CHECK_THROW(commandHandler(packet), armnn::RuntimeException); // Wrong profiling state
profilingStateMachine.TransitionToState(ProfilingState::Active);
BOOST_CHECK_NO_THROW(commandHandler(packet));
@@ -2270,34 +2121,34 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2)
uint32_t headerWord0 = ReadUint32(readBuffer, 0);
uint32_t headerWord1 = ReadUint32(readBuffer, 4);
- BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 0); // packet family
- BOOST_TEST(((headerWord0 >> 16) & 0x000003FF) == 2); // packet id
- BOOST_TEST(headerWord1 == 240); // data length
-
- uint32_t bodyHeaderWord0 = ReadUint32(readBuffer, 8);
- uint32_t bodyHeaderWord1 = ReadUint32(readBuffer, 12);
- uint32_t bodyHeaderWord2 = ReadUint32(readBuffer, 16);
- uint32_t bodyHeaderWord3 = ReadUint32(readBuffer, 20);
- uint32_t bodyHeaderWord4 = ReadUint32(readBuffer, 24);
- uint32_t bodyHeaderWord5 = ReadUint32(readBuffer, 28);
- uint16_t deviceRecordCount = numeric_cast<uint16_t>(bodyHeaderWord0 >> 16);
+ BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 0); // packet family
+ BOOST_TEST(((headerWord0 >> 16) & 0x000003FF) == 2); // packet id
+ BOOST_TEST(headerWord1 == 240); // data length
+
+ uint32_t bodyHeaderWord0 = ReadUint32(readBuffer, 8);
+ uint32_t bodyHeaderWord1 = ReadUint32(readBuffer, 12);
+ uint32_t bodyHeaderWord2 = ReadUint32(readBuffer, 16);
+ uint32_t bodyHeaderWord3 = ReadUint32(readBuffer, 20);
+ uint32_t bodyHeaderWord4 = ReadUint32(readBuffer, 24);
+ uint32_t bodyHeaderWord5 = ReadUint32(readBuffer, 28);
+ uint16_t deviceRecordCount = numeric_cast<uint16_t>(bodyHeaderWord0 >> 16);
uint16_t counterSetRecordCount = numeric_cast<uint16_t>(bodyHeaderWord2 >> 16);
- uint16_t categoryRecordCount = numeric_cast<uint16_t>(bodyHeaderWord4 >> 16);
- BOOST_TEST(deviceRecordCount == 1); // device_records_count
- BOOST_TEST(bodyHeaderWord1 == 0); // device_records_pointer_table_offset
- BOOST_TEST(counterSetRecordCount == 1); // counter_set_count
- BOOST_TEST(bodyHeaderWord3 == 4); // counter_set_pointer_table_offset
- BOOST_TEST(categoryRecordCount == 1); // categories_count
- BOOST_TEST(bodyHeaderWord5 == 8); // categories_pointer_table_offset
+ uint16_t categoryRecordCount = numeric_cast<uint16_t>(bodyHeaderWord4 >> 16);
+ BOOST_TEST(deviceRecordCount == 1); // device_records_count
+ BOOST_TEST(bodyHeaderWord1 == 0); // device_records_pointer_table_offset
+ BOOST_TEST(counterSetRecordCount == 1); // counter_set_count
+ BOOST_TEST(bodyHeaderWord3 == 4); // counter_set_pointer_table_offset
+ BOOST_TEST(categoryRecordCount == 1); // categories_count
+ BOOST_TEST(bodyHeaderWord5 == 8); // categories_pointer_table_offset
uint32_t deviceRecordOffset = ReadUint32(readBuffer, 32);
- BOOST_TEST(deviceRecordOffset == 0);
+ BOOST_TEST(deviceRecordOffset == 0);
uint32_t counterSetRecordOffset = ReadUint32(readBuffer, 36);
BOOST_TEST(counterSetRecordOffset == 20);
uint32_t categoryRecordOffset = ReadUint32(readBuffer, 40);
- BOOST_TEST(categoryRecordOffset == 44);
+ BOOST_TEST(categoryRecordOffset == 44);
}
BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadConnectionAcknowledgedPacket)
@@ -2313,21 +2164,21 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadConnectionAcknowledgedPacket)
StreamRedirector streamRedirector(std::cout, ss.rdbuf());
// Calculate the size of a Stream Metadata packet
- std::string processName = GetProcessName().substr(0, 60);
+ std::string processName = GetProcessName().substr(0, 60);
unsigned int processNameSize = processName.empty() ? 0 : boost::numeric_cast<unsigned int>(processName.size()) + 1;
unsigned int streamMetadataPacketsize = 118 + processNameSize;
// Reset the profiling service to the uninitialized state
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
ProfilingService& profilingService = ProfilingService::Instance();
profilingService.ResetExternalProfilingOptions(options, true);
// Bring the profiling service to the "WaitingForAck" state
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
- profilingService.Update(); // Initialize the counter directory
+ profilingService.Update(); // Initialize the counter directory
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected);
- profilingService.Update();// Create the profiling connection
+ profilingService.Update(); // Create the profiling connection
// Get the mock profiling connection
MockProfilingConnection* mockProfilingConnection = helper.GetMockProfilingConnection();
@@ -2356,9 +2207,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadConnectionAcknowledgedPacket)
// 8:15 [8] reserved: Reserved, value 0b00000000
// 0:7 [8] reserved: Reserved, value 0b00000000
uint32_t packetFamily = 0;
- uint32_t packetId = 37; // Wrong packet id!!!
- uint32_t header = ((packetFamily & 0x0000003F) << 26) |
- ((packetId & 0x000003FF) << 16);
+ uint32_t packetId = 37; // Wrong packet id!!!
+ uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Connection Acknowledged Packet
Packet connectionAcknowledgedPacket(header);
@@ -2387,21 +2237,21 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodConnectionAcknowledgedPacket)
SwapProfilingConnectionFactoryHelper helper;
// Calculate the size of a Stream Metadata packet
- std::string processName = GetProcessName().substr(0, 60);
+ std::string processName = GetProcessName().substr(0, 60);
unsigned int processNameSize = processName.empty() ? 0 : boost::numeric_cast<unsigned int>(processName.size()) + 1;
unsigned int streamMetadataPacketsize = 118 + processNameSize;
// Reset the profiling service to the uninitialized state
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
ProfilingService& profilingService = ProfilingService::Instance();
profilingService.ResetExternalProfilingOptions(options, true);
// Bring the profiling service to the "WaitingForAck" state
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
- profilingService.Update(); // Initialize the counter directory
+ profilingService.Update(); // Initialize the counter directory
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected);
- profilingService.Update(); // Create the profiling connection
+ profilingService.Update(); // Create the profiling connection
// Get the mock profiling connection
MockProfilingConnection* mockProfilingConnection = helper.GetMockProfilingConnection();
@@ -2411,7 +2261,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodConnectionAcknowledgedPacket)
mockProfilingConnection->Clear();
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::WaitingForAck);
- profilingService.Update(); // Start the command handler and the send thread
+ profilingService.Update(); // Start the command handler and the send thread
// Wait for the Stream Metadata packet to be sent
helper.WaitForProfilingPacketsSent();
@@ -2431,8 +2281,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodConnectionAcknowledgedPacket)
// 0:7 [8] reserved: Reserved, value 0b00000000
uint32_t packetFamily = 0;
uint32_t packetId = 1;
- uint32_t header = ((packetFamily & 0x0000003F) << 26) |
- ((packetId & 0x000003FF) << 16);
+ uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Connection Acknowledged Packet
Packet connectionAcknowledgedPacket(header);
@@ -2466,7 +2315,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadRequestCounterDirectoryPacket)
// Reset the profiling service to the uninitialized state
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
ProfilingService& profilingService = ProfilingService::Instance();
profilingService.ResetExternalProfilingOptions(options, true);
@@ -2474,9 +2323,9 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadRequestCounterDirectoryPacket)
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
helper.ForceTransitionToState(ProfilingState::NotConnected);
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected);
- profilingService.Update(); // Create the profiling connection
+ profilingService.Update(); // Create the profiling connection
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::WaitingForAck);
- profilingService.Update(); // Start the command handler and the send thread
+ profilingService.Update(); // Start the command handler and the send thread
// Wait for the Stream Metadata packet the be sent
// (we are not testing the connection acknowledgement here so it will be ignored by this test)
@@ -2502,9 +2351,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadRequestCounterDirectoryPacket)
// 8:15 [8] reserved: Reserved, value 0b00000000
// 0:7 [8] reserved: Reserved, value 0b00000000
uint32_t packetFamily = 0;
- uint32_t packetId = 123; // Wrong packet id!!!
- uint32_t header = ((packetFamily & 0x0000003F) << 26) |
- ((packetId & 0x000003FF) << 16);
+ uint32_t packetId = 123; // Wrong packet id!!!
+ uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Request Counter Directory packet
Packet requestCounterDirectoryPacket(header);
@@ -2534,17 +2382,17 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodRequestCounterDirectoryPacket)
// Reset the profiling service to the uninitialized state
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
ProfilingService& profilingService = ProfilingService::Instance();
profilingService.ResetExternalProfilingOptions(options, true);
// Bring the profiling service to the "Active" state
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
- profilingService.Update(); // Initialize the counter directory
+ profilingService.Update(); // Initialize the counter directory
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected);
- profilingService.Update(); // Create the profiling connection
+ profilingService.Update(); // Create the profiling connection
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::WaitingForAck);
- profilingService.Update(); // Start the command handler and the send thread
+ profilingService.Update(); // Start the command handler and the send thread
// Wait for the Stream Metadata packet the be sent
// (we are not testing the connection acknowledgement here so it will be ignored by this test)
@@ -2571,8 +2419,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodRequestCounterDirectoryPacket)
// 0:7 [8] reserved: Reserved, value 0b00000000
uint32_t packetFamily = 0;
uint32_t packetId = 3;
- uint32_t header = ((packetFamily & 0x0000003F) << 26) |
- ((packetId & 0x000003FF) << 16);
+ uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Request Counter Directory packet
Packet requestCounterDirectoryPacket(header);
@@ -2586,7 +2433,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodRequestCounterDirectoryPacket)
// Check that the mock profiling connection contains one Counter Directory packet
const std::vector<uint32_t> writtenData = mockProfilingConnection->GetWrittenData();
BOOST_TEST(writtenData.size() == 1);
- BOOST_TEST(writtenData[0] == 416); // The size of the expected Counter Directory packet
+ BOOST_TEST(writtenData[0] == 416); // The size of the expected Counter Directory packet
// The Request Counter Directory Command Handler should not have updated the profiling state
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Active);
@@ -2610,17 +2457,17 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadPeriodicCounterSelectionPacket)
// Reset the profiling service to the uninitialized state
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
ProfilingService& profilingService = ProfilingService::Instance();
profilingService.ResetExternalProfilingOptions(options, true);
// Bring the profiling service to the "Active" state
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
- profilingService.Update(); // Initialize the counter directory
+ profilingService.Update(); // Initialize the counter directory
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected);
- profilingService.Update(); // Create the profiling connection
+ profilingService.Update(); // Create the profiling connection
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::WaitingForAck);
- profilingService.Update(); // Start the command handler and the send thread
+ profilingService.Update(); // Start the command handler and the send thread
// Wait for the Stream Metadata packet the be sent
// (we are not testing the connection acknowledgement here so it will be ignored by this test)
@@ -2646,12 +2493,11 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadPeriodicCounterSelectionPacket)
// 8:15 [8] reserved: Reserved, value 0b00000000
// 0:7 [8] reserved: Reserved, value 0b00000000
uint32_t packetFamily = 0;
- uint32_t packetId = 999; // Wrong packet id!!!
- uint32_t header = ((packetFamily & 0x0000003F) << 26) |
- ((packetId & 0x000003FF) << 16);
+ uint32_t packetId = 999; // Wrong packet id!!!
+ uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters
+ Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -2681,17 +2527,17 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadPeriodicCounterSelectionPacketInval
// Reset the profiling service to the uninitialized state
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
ProfilingService& profilingService = ProfilingService::Instance();
profilingService.ResetExternalProfilingOptions(options, true);
// Bring the profiling service to the "Active" state
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
- profilingService.Update(); // Initialize the counter directory
+ profilingService.Update(); // Initialize the counter directory
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected);
- profilingService.Update(); // Create the profiling connection
+ profilingService.Update(); // Create the profiling connection
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::WaitingForAck);
- profilingService.Update(); // Start the command handler and the send thread
+ profilingService.Update(); // Start the command handler and the send thread
// Wait for the Stream Metadata packet the be sent
// (we are not testing the connection acknowledgement here so it will be ignored by this test)
@@ -2718,17 +2564,16 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadPeriodicCounterSelectionPacketInval
// 0:7 [8] reserved: Reserved, value 0b00000000
uint32_t packetFamily = 0;
uint32_t packetId = 4;
- uint32_t header = ((packetFamily & 0x0000003F) << 26) |
- ((packetId & 0x000003FF) << 16);
+ uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
- uint32_t capturePeriod = 123456; // Some capture period (microseconds)
+ uint32_t capturePeriod = 123456; // Some capture period (microseconds)
// Get the first valid counter UID
const ICounterDirectory& counterDirectory = profilingService.GetCounterDirectory();
- const Counters& counters = counterDirectory.GetCounters();
+ const Counters& counters = counterDirectory.GetCounters();
BOOST_CHECK(counters.size() > 1);
- uint16_t counterUidA = counters.begin()->first; // First valid counter UID
- uint16_t counterUidB = 9999; // Second invalid counter UID
+ uint16_t counterUidA = counters.begin()->first; // First valid counter UID
+ uint16_t counterUidB = 9999; // Second invalid counter UID
uint32_t length = 8;
@@ -2738,8 +2583,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadPeriodicCounterSelectionPacketInval
WriteUint16(data.get(), 6, counterUidB);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter
- // Capture thread
+ Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter
+ // Capture thread
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -2760,8 +2605,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadPeriodicCounterSelectionPacketInval
}
receivedPackets.insert(receivedPackets.end(), writtenData.begin(), writtenData.end());
expectedPackets -= boost::numeric_cast<int>(writtenData.size());
- }
- while (expectedPackets > 0);
+ } while (expectedPackets > 0);
BOOST_TEST(!receivedPackets.empty());
// The size of the expected Periodic Counter Selection packet
@@ -2784,17 +2628,17 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketNoCo
// Reset the profiling service to the uninitialized state
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
ProfilingService& profilingService = ProfilingService::Instance();
profilingService.ResetExternalProfilingOptions(options, true);
// Bring the profiling service to the "Active" state
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
- profilingService.Update(); // Initialize the counter directory
+ profilingService.Update(); // Initialize the counter directory
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected);
- profilingService.Update(); // Create the profiling connection
+ profilingService.Update(); // Create the profiling connection
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::WaitingForAck);
- profilingService.Update(); // Start the command handler and the send thread
+ profilingService.Update(); // Start the command handler and the send thread
// Wait for the Stream Metadata packet the be sent
// (we are not testing the connection acknowledgement here so it will be ignored by this test)
@@ -2821,11 +2665,10 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketNoCo
// 0:7 [8] reserved: Reserved, value 0b00000000
uint32_t packetFamily = 0;
uint32_t packetId = 4;
- uint32_t header = ((packetFamily & 0x0000003F) << 26) |
- ((packetId & 0x000003FF) << 16);
+ uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters
+ Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -2838,8 +2681,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketNoCo
// Check that the mock profiling connection contains one Periodic Counter Selection
const std::vector<uint32_t> writtenData = mockProfilingConnection->GetWrittenData();
- BOOST_TEST(writtenData.size() == 1); // Only one packet is expected (no Periodic Counter packets)
- BOOST_TEST(writtenData[0] == 12); // The size of the expected Periodic Counter Selection (echos the sent one)
+ BOOST_TEST(writtenData.size() == 1); // Only one packet is expected (no Periodic Counter packets)
+ BOOST_TEST(writtenData[0] == 12); // The size of the expected Periodic Counter Selection (echos the sent one)
// Reset the profiling service to stop any running thread
options.m_EnableProfiling = false;
@@ -2853,17 +2696,17 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketSing
// Reset the profiling service to the uninitialized state
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
ProfilingService& profilingService = ProfilingService::Instance();
profilingService.ResetExternalProfilingOptions(options, true);
// Bring the profiling service to the "Active" state
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
- profilingService.Update(); // Initialize the counter directory
+ profilingService.Update(); // Initialize the counter directory
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected);
- profilingService.Update(); // Create the profiling connection
+ profilingService.Update(); // Create the profiling connection
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::WaitingForAck);
- profilingService.Update(); // Start the command handler and the send thread
+ profilingService.Update(); // Start the command handler and the send thread
// Wait for the Stream Metadata packet the be sent
// (we are not testing the connection acknowledgement here so it will be ignored by this test)
@@ -2890,16 +2733,15 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketSing
// 0:7 [8] reserved: Reserved, value 0b00000000
uint32_t packetFamily = 0;
uint32_t packetId = 4;
- uint32_t header = ((packetFamily & 0x0000003F) << 26) |
- ((packetId & 0x000003FF) << 16);
+ uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
- uint32_t capturePeriod = 123456; // Some capture period (microseconds)
+ uint32_t capturePeriod = 123456; // Some capture period (microseconds)
// Get the first valid counter UID
const ICounterDirectory& counterDirectory = profilingService.GetCounterDirectory();
- const Counters& counters = counterDirectory.GetCounters();
+ const Counters& counters = counterDirectory.GetCounters();
BOOST_CHECK(!counters.empty());
- uint16_t counterUid = counters.begin()->first; // Valid counter UID
+ uint16_t counterUid = counters.begin()->first; // Valid counter UID
uint32_t length = 6;
@@ -2908,8 +2750,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketSing
WriteUint16(data.get(), 4, counterUid);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter
- // Capture thread
+ Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter
+ // Capture thread
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -2930,8 +2772,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketSing
}
receivedPackets.insert(receivedPackets.end(), writtenData.begin(), writtenData.end());
expectedPackets -= boost::numeric_cast<int>(writtenData.size());
- }
- while (expectedPackets > 0);
+ } while (expectedPackets > 0);
BOOST_TEST(!receivedPackets.empty());
// The size of the expected Periodic Counter Selection packet (echos the sent one)
@@ -2954,17 +2795,17 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketMult
// Reset the profiling service to the uninitialized state
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
ProfilingService& profilingService = ProfilingService::Instance();
profilingService.ResetExternalProfilingOptions(options, true);
// Bring the profiling service to the "Active" state
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
- profilingService.Update(); // Initialize the counter directory
+ profilingService.Update(); // Initialize the counter directory
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected);
- profilingService.Update(); // Create the profiling connection
+ profilingService.Update(); // Create the profiling connection
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::WaitingForAck);
- profilingService.Update(); // Start the command handler and the send thread
+ profilingService.Update(); // Start the command handler and the send thread
// Wait for the Stream Metadata packet the be sent
// (we are not testing the connection acknowledgement here so it will be ignored by this test)
@@ -2991,17 +2832,16 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketMult
// 0:7 [8] reserved: Reserved, value 0b00000000
uint32_t packetFamily = 0;
uint32_t packetId = 4;
- uint32_t header = ((packetFamily & 0x0000003F) << 26) |
- ((packetId & 0x000003FF) << 16);
+ uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
- uint32_t capturePeriod = 123456; // Some capture period (microseconds)
+ uint32_t capturePeriod = 123456; // Some capture period (microseconds)
// Get the first valid counter UID
const ICounterDirectory& counterDirectory = profilingService.GetCounterDirectory();
- const Counters& counters = counterDirectory.GetCounters();
+ const Counters& counters = counterDirectory.GetCounters();
BOOST_CHECK(counters.size() > 1);
- uint16_t counterUidA = counters.begin()->first; // First valid counter UID
- uint16_t counterUidB = (counters.begin()++)->first; // Second valid counter UID
+ uint16_t counterUidA = counters.begin()->first; // First valid counter UID
+ uint16_t counterUidB = (counters.begin()++)->first; // Second valid counter UID
uint32_t length = 8;
@@ -3011,8 +2851,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketMult
WriteUint16(data.get(), 6, counterUidB);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter
- // Capture thread
+ Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter
+ // Capture thread
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -3033,8 +2873,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketMult
}
receivedPackets.insert(receivedPackets.end(), writtenData.begin(), writtenData.end());
expectedPackets -= boost::numeric_cast<int>(writtenData.size());
- }
- while (expectedPackets > 0);
+ } while (expectedPackets > 0);
BOOST_TEST(!receivedPackets.empty());
// The size of the expected Periodic Counter Selection packet (echos the sent one)
@@ -3057,29 +2896,29 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceDisconnect)
// Reset the profiling service to the uninitialized state
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
ProfilingService& profilingService = ProfilingService::Instance();
profilingService.ResetExternalProfilingOptions(options, true);
// Try to disconnect the profiling service while in the "Uninitialised" state
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
profilingService.Disconnect();
- BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised); // The state should not change
+ BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised); // The state should not change
// Try to disconnect the profiling service while in the "NotConnected" state
- profilingService.Update(); // Initialize the counter directory
+ profilingService.Update(); // Initialize the counter directory
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected);
profilingService.Disconnect();
- BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected); // The state should not change
+ BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected); // The state should not change
// Try to disconnect the profiling service while in the "WaitingForAck" state
- profilingService.Update(); // Create the profiling connection
+ profilingService.Update(); // Create the profiling connection
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::WaitingForAck);
profilingService.Disconnect();
- BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::WaitingForAck); // The state should not change
+ BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::WaitingForAck); // The state should not change
// Try to disconnect the profiling service while in the "Active" state
- profilingService.Update(); // Start the command handler and the send thread
+ profilingService.Update(); // Start the command handler and the send thread
// Wait for the Stream Metadata packet the be sent
// (we are not testing the connection acknowledgement here so it will be ignored by this test)
@@ -3097,7 +2936,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceDisconnect)
BOOST_CHECK(mockProfilingConnection->IsOpen());
profilingService.Disconnect();
- BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected); // The state should have changed
+ BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected); // The state should have changed
// Check that the profiling connection has been reset
mockProfilingConnection = helper.GetMockProfilingConnection();
@@ -3115,17 +2954,17 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPerJobCounterSelectionPacket)
// Reset the profiling service to the uninitialized state
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
ProfilingService& profilingService = ProfilingService::Instance();
profilingService.ResetExternalProfilingOptions(options, true);
// Bring the profiling service to the "Active" state
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
- profilingService.Update(); // Initialize the counter directory
+ profilingService.Update(); // Initialize the counter directory
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected);
- profilingService.Update(); // Create the profiling connection
+ profilingService.Update(); // Create the profiling connection
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::WaitingForAck);
- profilingService.Update(); // Start the command handler and the send thread
+ profilingService.Update(); // Start the command handler and the send thread
// Wait for the Stream Metadata packet the be sent
// (we are not testing the connection acknowledgement here so it will be ignored by this test)
@@ -3152,11 +2991,10 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPerJobCounterSelectionPacket)
// 0:7 [8] reserved: Reserved, value 0b00000000
uint32_t packetFamily = 0;
uint32_t packetId = 5;
- uint32_t header = ((packetFamily & 0x0000003F) << 26) |
- ((packetId & 0x000003FF) << 16);
+ uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Per-Job Counter Selection packet
- Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters
+ Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -3181,7 +3019,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPerJobCounterSelectionPacket)
BOOST_AUTO_TEST_CASE(CheckConfigureProfilingServiceOn)
{
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
ProfilingService& profilingService = ProfilingService::Instance();
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
profilingService.ConfigureProfilingService(options);
diff --git a/tests/profiling/gatordmock/DirectoryCaptureCommandHandler.hpp b/tests/profiling/gatordmock/DirectoryCaptureCommandHandler.hpp
deleted file mode 100644
index 4cf96be741..0000000000
--- a/tests/profiling/gatordmock/DirectoryCaptureCommandHandler.hpp
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-#include "CounterDirectory.hpp"
-#include "GatordMockService.hpp"
-#include "MockUtils.hpp"
-
-
-#include "Packet.hpp"
-#include "CommandHandlerFunctor.hpp"
-#include "SendCounterPacket.hpp"
-#include "IPeriodicCounterCapture.hpp"
-
-
-#include <vector>
-#include <thread>
-#include <functional>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-class DirectoryCaptureCommandHandler : public profiling::CommandHandlerFunctor
-{
-
-public:
-
- DirectoryCaptureCommandHandler(uint32_t familyId,
- uint32_t packetId,
- uint32_t version,
- bool quietOperation = false)
- : CommandHandlerFunctor(familyId, packetId, version)
- , m_QuietOperation(quietOperation)
- , m_CounterDirectoryCount(0)
- {}
-
- void operator()(const armnn::profiling::Packet &packet) override;
-
- CounterDirectory GetCounterDirectory() const;
- uint32_t GetCounterDirectoryCount() const;
-
-private:
- void ParseData(const armnn::profiling::Packet &packet);
-
- std::vector<CategoryRecord> ReadCategoryRecords(const unsigned char *const data,
- uint32_t offset,
- std::vector<uint32_t> categoryOffsets);
-
- std::vector<CounterSetRecord> ReadCounterSetRecords(const unsigned char *const data,
- uint32_t offset,
- std::vector<uint32_t> eventRecordsOffsets);
-
- std::vector<DeviceRecord> ReadDeviceRecords(const unsigned char *const data,
- uint32_t offset,
- std::vector<uint32_t> eventRecordsOffsets);
-
- std::vector<EventRecord> ReadEventRecords(const unsigned char *const data,
- uint32_t offset,
- std::vector<uint32_t> eventRecordsOffsets);
-
- CounterDirectory m_CounterDirectory;
-
- bool m_QuietOperation;
- std::atomic<uint32_t> m_CounterDirectoryCount;
-};
-
-} // namespace gatordmock
-
-} // namespace armnn
diff --git a/tests/profiling/gatordmock/GatordMockMain.cpp b/tests/profiling/gatordmock/GatordMockMain.cpp
index 9dac6d976e..5f15db9002 100644
--- a/tests/profiling/gatordmock/GatordMockMain.cpp
+++ b/tests/profiling/gatordmock/GatordMockMain.cpp
@@ -35,8 +35,8 @@ int main(int argc, char* argv[])
armnn::gatordmock::PeriodicCounterCaptureCommandHandler counterCaptureCommandHandler(
1, 0, packetVersionResolver.ResolvePacketVersion(1, 0).GetEncodedValue());
- armnn::gatordmock::DirectoryCaptureCommandHandler directoryCaptureCommandHandler(
- 0, 2, packetVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue());
+ armnn::profiling::DirectoryCaptureCommandHandler directoryCaptureCommandHandler(
+ 0, 2, packetVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue(), false);
// Register different derived functors
registry.RegisterFunctor(&periodicCounterSelectionResponseHandler);
diff --git a/tests/profiling/gatordmock/GatordMockService.cpp b/tests/profiling/gatordmock/GatordMockService.cpp
index 5e9f8203d1..46f6547b41 100644
--- a/tests/profiling/gatordmock/GatordMockService.cpp
+++ b/tests/profiling/gatordmock/GatordMockService.cpp
@@ -6,8 +6,8 @@
#include "GatordMockService.hpp"
#include <CommandHandlerRegistry.hpp>
-#include "../../src/profiling/PacketVersionResolver.hpp"
-#include "../../src/profiling/ProfilingUtils.hpp"
+#include <PacketVersionResolver.hpp>
+#include <ProfilingUtils.hpp>
#include <cerrno>
#include <fcntl.h>
@@ -231,12 +231,12 @@ void GatordMockService::ReceiveLoop(GatordMockService& mockService)
{
// In this case we ignore timeouts and and keep trying to receive.
}
- catch (const armnn::InvalidArgumentException &e)
+ catch (const armnn::InvalidArgumentException& e)
{
// We couldn't find a functor to handle the packet?
std::cerr << "Packet received that could not be processed: " << e.what() << std::endl;
}
- catch (const armnn::RuntimeException &e)
+ catch (const armnn::RuntimeException& e)
{
// A runtime exception occurred which means we must exit the loop.
std::cerr << "Receive thread closing: " << e.what() << std::endl;
@@ -331,15 +331,14 @@ armnn::profiling::Packet GatordMockService::ReceivePacket()
std::cout << "Processing packet ID= " << packetRx.GetPacketId() << " Length=" << packetRx.GetLength()
<< std::endl;
}
- // Pass packet into the handler registry
- m_PacketsReceivedCount.operator++(std::memory_order::memory_order_release);
- m_HandlerRegistry
- .GetFunctor(packetRx.GetPacketFamily(),
- packetRx.GetPacketId(),
- packetVersionResolver.ResolvePacketVersion(packetRx.GetPacketFamily(),
- packetRx.GetPacketId()).GetEncodedValue())
- ->operator()(packetRx);
+ profiling::Version version =
+ packetVersionResolver.ResolvePacketVersion(packetRx.GetPacketFamily(), packetRx.GetPacketId());
+
+ profiling::CommandHandlerFunctor* commandHandlerFunctor =
+ m_HandlerRegistry.GetFunctor(packetRx.GetPacketFamily(), packetRx.GetPacketId(), version.GetEncodedValue());
+ BOOST_ASSERT(commandHandlerFunctor);
+ commandHandlerFunctor->operator()(packetRx);
return packetRx;
}
diff --git a/tests/profiling/gatordmock/MockUtils.cpp b/tests/profiling/gatordmock/MockUtils.cpp
deleted file mode 100644
index bdbffc9253..0000000000
--- a/tests/profiling/gatordmock/MockUtils.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "MockUtils.hpp"
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-std::string CentreAlignFormatting(const std::string& stringToPass, const int spacingWidth)
-{
- std::stringstream outputStream, centrePadding;
- int padding = spacingWidth - static_cast<int>(stringToPass.size());
-
- for (int i = 0; i < padding / 2; ++i)
- {
- centrePadding << " ";
- }
-
- outputStream << centrePadding.str() << stringToPass << centrePadding.str();
-
- if (padding > 0 && padding %2 != 0)
- {
- outputStream << " ";
- }
-
- return outputStream.str();
-}
-
-std::string GetStringNameFromBuffer(const unsigned char* const data, uint32_t offset)
-{
- std::string deviceName;
- u_char nextChar = profiling::ReadUint8(data, offset);
-
- while (IsValidChar(nextChar))
- {
- deviceName += static_cast<char>(nextChar);
- offset ++;
- nextChar = profiling::ReadUint8(data, offset);
- }
-
- return deviceName;
-}
-
-bool IsValidChar(unsigned char c)
-{
- // Check that the given character has ASCII 7-bit encoding, alpha-numeric, whitespace, and underscore only
- return c < 128 && (std::isalnum(c) || c == '_' || c == ' ');
-}
-
-} // gatordmock
-
-} // armnn
diff --git a/tests/profiling/gatordmock/MockUtils.hpp b/tests/profiling/gatordmock/MockUtils.hpp
deleted file mode 100644
index 78bd867b0f..0000000000
--- a/tests/profiling/gatordmock/MockUtils.hpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-#include <EncodeVersion.hpp>
-#include <ProfilingUtils.hpp>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-std::string CentreAlignFormatting(const std::string& stringToPass, const int spacingWidth);
-
-std::string GetStringNameFromBuffer(const unsigned char *const data, uint32_t offset);
-
-bool IsValidChar(unsigned char c);
-
-} // gatordmock
-
-} // armnn
diff --git a/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp b/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp
index 893351463f..9dd7064c90 100644
--- a/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp
+++ b/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp
@@ -3,7 +3,6 @@
// SPDX-License-Identifier: MIT
//
-#include "MockUtils.hpp"
#include "PeriodicCounterCaptureCommandHandler.hpp"
#include <ProfilingUtils.hpp>
@@ -94,24 +93,24 @@ void PeriodicCounterCaptureCommandHandler::operator()(const profiling::Packet& p
valueString.append(", ");
}
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_CounterCaptureValues.m_Timestamp), 10));
+ body.append(profiling::CentreAlignFormatting(std::to_string(m_CounterCaptureValues.m_Timestamp), 10));
body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_CurrentPeriodValue), 13));
+ body.append(profiling::CentreAlignFormatting(std::to_string(m_CurrentPeriodValue), 13));
body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(uidString, 10));
+ body.append(profiling::CentreAlignFormatting(uidString, 10));
body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(valueString, 10));
+ body.append(profiling::CentreAlignFormatting(valueString, 10));
body.append("\n");
if (!m_HeaderPrinted)
{
- header.append(gatordmock::CentreAlignFormatting(" Timestamp", 11));
+ header.append(profiling::CentreAlignFormatting(" Timestamp", 11));
header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Period (us)", 13));
+ header.append(profiling::CentreAlignFormatting("Period (us)", 13));
header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("UID's", static_cast<int>(uidString.size())));
+ header.append(profiling::CentreAlignFormatting("UID's", static_cast<int>(uidString.size())));
header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Values", 10));
+ header.append(profiling::CentreAlignFormatting("Values", 10));
header.append("\n");
std::cout << header;
diff --git a/tests/profiling/gatordmock/tests/GatordMockTests.cpp b/tests/profiling/gatordmock/tests/GatordMockTests.cpp
index eb827bec69..1440f90905 100644
--- a/tests/profiling/gatordmock/tests/GatordMockTests.cpp
+++ b/tests/profiling/gatordmock/tests/GatordMockTests.cpp
@@ -5,9 +5,9 @@
#include "../GatordMockService.hpp"
#include "../PeriodicCounterCaptureCommandHandler.hpp"
-#include "../DirectoryCaptureCommandHandler.hpp"
#include <CommandHandlerRegistry.hpp>
+#include <DirectoryCaptureCommandHandler.hpp>
#include <ProfilingService.hpp>
#include <test/SendCounterPacketTests.hpp>
@@ -87,8 +87,7 @@ BOOST_AUTO_TEST_CASE(CounterCaptureHandlingTest)
profiling::Packet packet1(headerWord1, dataLength, uniqueData1);
profiling::Packet packet2(headerWord1, dataLength, uniqueData2);
- gatordmock::PeriodicCounterCaptureCommandHandler commandHandler
- (0, 4, headerWord1, true);
+ gatordmock::PeriodicCounterCaptureCommandHandler commandHandler(0, 4, headerWord1, true);
// Simulate two separate packets coming in to calculate period
commandHandler(packet1);
@@ -108,7 +107,7 @@ BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd)
// performance data.
//These variables are used to wait for the profiling service
- u_int32_t timeout = 2000;
+ u_int32_t timeout = 2000;
u_int32_t sleepTime = 50;
u_int32_t timeSlept = 0;
@@ -118,11 +117,11 @@ BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd)
profiling::CommandHandlerRegistry registry;
// Update with derived functors
- gatordmock::PeriodicCounterCaptureCommandHandler counterCaptureCommandHandler
- (0, 4, packetVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(), true);
+ gatordmock::PeriodicCounterCaptureCommandHandler counterCaptureCommandHandler(
+ 0, 4, packetVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(), true);
- gatordmock::DirectoryCaptureCommandHandler directoryCaptureCommandHandler
- (0, 2, packetVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue(), true);
+ profiling::DirectoryCaptureCommandHandler directoryCaptureCommandHandler(
+ 0, 2, packetVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue(), true);
// Register different derived functors
registry.RegisterFunctor(&counterCaptureCommandHandler);
@@ -183,10 +182,9 @@ BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd)
}
mockService.LaunchReceivingThread();
- mockService.SendRequestCounterDir();
-
+ // As part of the default startup of the profiling service a counter directory packet will be sent.
timeSlept = 0;
- while (directoryCaptureCommandHandler.GetCounterDirectoryCount() == 0)
+ while (!directoryCaptureCommandHandler.ParsedCounterDirectory())
{
if (timeSlept >= timeout)
{
@@ -196,81 +194,85 @@ BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd)
timeSlept += sleepTime;
}
- const profiling::ICounterDirectory& serviceCounterDirectory = profilingService.GetCounterDirectory();
- gatordmock::CounterDirectory mockCounterDirectory = directoryCaptureCommandHandler.GetCounterDirectory();
+ const profiling::ICounterDirectory& serviceCounterDirectory = profilingService.GetCounterDirectory();
+ const profiling::ICounterDirectory& receivedCounterDirectory = directoryCaptureCommandHandler.GetCounterDirectory();
- BOOST_ASSERT(serviceCounterDirectory.GetDeviceCount() == mockCounterDirectory.m_DeviceRecords.size());
- BOOST_ASSERT(serviceCounterDirectory.GetCounterSetCount() == mockCounterDirectory.m_CounterSets.size());
- BOOST_ASSERT(serviceCounterDirectory.GetCategoryCount() == mockCounterDirectory.m_Categories.size());
+ // Compare thre basics of the counter directory from the service and the one we received over the wire.
+ BOOST_ASSERT(serviceCounterDirectory.GetDeviceCount() == receivedCounterDirectory.GetDeviceCount());
+ BOOST_ASSERT(serviceCounterDirectory.GetCounterSetCount() == receivedCounterDirectory.GetCounterSetCount());
+ BOOST_ASSERT(serviceCounterDirectory.GetCategoryCount() == receivedCounterDirectory.GetCategoryCount());
+ BOOST_ASSERT(serviceCounterDirectory.GetCounterCount() == receivedCounterDirectory.GetCounterCount());
- const profiling::Devices& serviceDevices = serviceCounterDirectory.GetDevices();
+ receivedCounterDirectory.GetDeviceCount();
+ serviceCounterDirectory.GetDeviceCount();
- uint32_t deviceIndex = 0;
+ const profiling::Devices& serviceDevices = serviceCounterDirectory.GetDevices();
for (auto& device : serviceDevices)
{
- BOOST_ASSERT(device.second->m_Name.size() ==
- mockCounterDirectory.m_DeviceRecords[deviceIndex].m_DeviceName.size());
-
- BOOST_CHECK(device.second->m_Name == mockCounterDirectory.m_DeviceRecords[deviceIndex].m_DeviceName);
- BOOST_CHECK(device.second->m_Uid == mockCounterDirectory.m_DeviceRecords[deviceIndex].m_DeviceUid);
- BOOST_CHECK(device.second->m_Cores == mockCounterDirectory.m_DeviceRecords[deviceIndex].m_DeviceCores);
- deviceIndex++;
+ // Find the same device in the received counter directory.
+ auto foundDevice = receivedCounterDirectory.GetDevices().find(device.second->m_Uid);
+ BOOST_CHECK(foundDevice != receivedCounterDirectory.GetDevices().end());
+ BOOST_CHECK(device.second->m_Name.compare((*foundDevice).second->m_Name) == 0);
+ BOOST_CHECK(device.second->m_Cores == (*foundDevice).second->m_Cores);
}
- const profiling::CounterSets & serviceCounterSets = serviceCounterDirectory.GetCounterSets();
- uint32_t counterSetIndex = 0;
+ const profiling::CounterSets& serviceCounterSets = serviceCounterDirectory.GetCounterSets();
for (auto& counterSet : serviceCounterSets)
{
- BOOST_ASSERT(counterSet.second->m_Name.size() ==
- mockCounterDirectory.m_CounterSets[counterSetIndex].m_CounterSetName.size());
-
- BOOST_CHECK(counterSet.second->m_Name == mockCounterDirectory.m_CounterSets[counterSetIndex].m_CounterSetName);
- BOOST_CHECK(counterSet.second->m_Uid == mockCounterDirectory.m_CounterSets[counterSetIndex].m_CounterSetUid);
- BOOST_CHECK(counterSet.second->m_Count ==
- mockCounterDirectory.m_CounterSets[counterSetIndex].m_CounterSetCount);
- counterSetIndex++;
+ // Find the same counter set in the received counter directory.
+ auto foundCounterSet = receivedCounterDirectory.GetCounterSets().find(counterSet.second->m_Uid);
+ BOOST_CHECK(foundCounterSet != receivedCounterDirectory.GetCounterSets().end());
+ BOOST_CHECK(counterSet.second->m_Name.compare((*foundCounterSet).second->m_Name) == 0);
+ BOOST_CHECK(counterSet.second->m_Count == (*foundCounterSet).second->m_Count);
}
const profiling::Categories& serviceCategories = serviceCounterDirectory.GetCategories();
- const std::vector<gatordmock::CategoryRecord> mockCategories = mockCounterDirectory.m_Categories;
-
- uint32_t categoryIndex = 0;
for (auto& category : serviceCategories)
{
- BOOST_ASSERT(category->m_Name.size() == mockCategories[categoryIndex].m_CategoryName.size());
-
- BOOST_CHECK(category->m_Name == mockCategories[categoryIndex].m_CategoryName);
- BOOST_CHECK(category->m_CounterSetUid == mockCategories[categoryIndex].m_CounterSet);
- BOOST_CHECK(category->m_DeviceUid == mockCategories[categoryIndex].m_DeviceUid);
-
- const std::vector<gatordmock::EventRecord> events = mockCategories[categoryIndex].m_EventRecords;
- uint32_t eventIndex = 0;
- for (uint16_t counterUid : category->m_Counters)
+ for (auto& receivedCategory : receivedCounterDirectory.GetCategories())
{
- const profiling::Counter* counter = serviceCounterDirectory.GetCounter(counterUid);
-
- BOOST_CHECK(counterUid == events[eventIndex].m_CounterUid);
-
- BOOST_ASSERT(counter->m_Name.size() == events[eventIndex].m_CounterName.size());
- BOOST_ASSERT(counter->m_Units.size() == events[eventIndex].m_CounterUnits.size());
- BOOST_ASSERT(counter->m_Description.size() == events[eventIndex].m_CounterDescription.size());
-
- BOOST_CHECK(counter->m_Name == events[eventIndex].m_CounterName);
- BOOST_CHECK(counter->m_Units == events[eventIndex].m_CounterUnits);
- BOOST_CHECK(counter->m_Description == events[eventIndex].m_CounterDescription);
-
- BOOST_CHECK(counter->m_CounterSetUid == events[eventIndex].m_CounterSetUid);
- BOOST_CHECK(counter->m_DeviceUid == events[eventIndex].m_DeviceUid);
- BOOST_CHECK(counter->m_Uid == events[eventIndex].m_CounterUid);
-
- BOOST_CHECK(counter->m_Multiplier == events[eventIndex].m_CounterMultiplier);
- BOOST_CHECK(counter->m_MaxCounterUid == events[eventIndex].m_MaxCounterUid);
- BOOST_CHECK(counter->m_Interpolation == events[eventIndex].m_CounterInterpolation);
- BOOST_CHECK(counter->m_Class == events[eventIndex].m_CounterClass);
-
- eventIndex++;
+ if (receivedCategory->m_Name.compare(category->m_Name) == 0)
+ {
+ // We've found the matching category.
+ BOOST_CHECK(category->m_DeviceUid == receivedCategory->m_DeviceUid);
+ BOOST_CHECK(category->m_CounterSetUid == receivedCategory->m_CounterSetUid);
+ // Now look at the interiors of the counters. Start by sorting them.
+ std::sort(category->m_Counters.begin(), category->m_Counters.end());
+ std::sort(receivedCategory->m_Counters.begin(), receivedCategory->m_Counters.end());
+ // When comparing uid's here we need to translate them.
+ std::function<bool(const uint16_t&, const uint16_t&)> comparator =
+ [&directoryCaptureCommandHandler](const uint16_t& first, const uint16_t& second) {
+ uint16_t translated = directoryCaptureCommandHandler.TranslateUIDCopyToOriginal(second);
+ if (translated == first)
+ {
+ return true;
+ }
+ return false;
+ };
+ // Then let vector == do the work.
+ BOOST_CHECK(std::equal(category->m_Counters.begin(), category->m_Counters.end(),
+ receivedCategory->m_Counters.begin(), comparator));
+ break;
+ }
}
- categoryIndex++;
+ }
+
+ // Finally check the content of the counters.
+ const profiling::Counters& receivedCounters = receivedCounterDirectory.GetCounters();
+ for (auto& receivedCounter : receivedCounters)
+ {
+ // Translate the Uid and find the corresponding counter in the original counter directory.
+ // Note we can't check m_MaxCounterUid here as it will likely differ between the two counter directories.
+ uint16_t translated = directoryCaptureCommandHandler.TranslateUIDCopyToOriginal(receivedCounter.first);
+ const profiling::Counter* serviceCounter = serviceCounterDirectory.GetCounter(translated);
+ BOOST_CHECK(serviceCounter->m_DeviceUid == receivedCounter.second->m_DeviceUid);
+ BOOST_CHECK(serviceCounter->m_Name.compare(receivedCounter.second->m_Name) == 0);
+ BOOST_CHECK(serviceCounter->m_CounterSetUid == receivedCounter.second->m_CounterSetUid);
+ BOOST_CHECK(serviceCounter->m_Multiplier == receivedCounter.second->m_Multiplier);
+ BOOST_CHECK(serviceCounter->m_Interpolation == receivedCounter.second->m_Interpolation);
+ BOOST_CHECK(serviceCounter->m_Class == receivedCounter.second->m_Class);
+ BOOST_CHECK(serviceCounter->m_Units.compare(receivedCounter.second->m_Units) == 0);
+ BOOST_CHECK(serviceCounter->m_Description.compare(receivedCounter.second->m_Description) == 0);
}
mockService.WaitForReceivingThread();