From 371b70e39390618cbd791b441adcf3923964b8df Mon Sep 17 00:00:00 2001 From: Matthew Sloyan Date: Fri, 11 Sep 2020 10:14:57 +0100 Subject: IVGCVSW-5301 Remove all boost::numeric_cast from armnn/src/profiling * Replaced with armnn/utility/NumericCast.hpp Signed-off-by: Matthew Sloyan Change-Id: I14e89c00cd1dd607315113d5b8ca56c2e9f6c363 --- src/profiling/FileOnlyProfilingConnection.cpp | 1 - src/profiling/ICounterDirectory.hpp | 2 - .../PeriodicCounterSelectionCommandHandler.cpp | 7 +- .../ProfilingConnectionDumpToFileDecorator.cpp | 7 +- src/profiling/ProfilingService.cpp | 4 +- src/profiling/ProfilingUtils.cpp | 14 ++-- src/profiling/ProfilingUtils.hpp | 4 +- src/profiling/SendCounterPacket.cpp | 75 ++++++++++------------ src/profiling/SendThread.cpp | 7 +- .../test/FileOnlyProfilingDecoratorTests.cpp | 1 - ...ProfilingConnectionDumpToFileDecoratorTests.cpp | 4 +- src/profiling/test/ProfilingMocks.hpp | 11 ++-- src/profiling/test/ProfilingTestUtils.cpp | 12 ++-- src/profiling/test/ProfilingTests.cpp | 27 +++----- .../test/RequestCountersPacketHandler.cpp | 6 +- src/profiling/test/SendCounterPacketTests.cpp | 26 ++++---- src/profiling/test/SendCounterPacketTests.hpp | 3 +- src/profiling/test/TimelinePacketTests.cpp | 43 +++++++------ 18 files changed, 119 insertions(+), 135 deletions(-) diff --git a/src/profiling/FileOnlyProfilingConnection.cpp b/src/profiling/FileOnlyProfilingConnection.cpp index 24f2cc7ede..a21ec2ff02 100644 --- a/src/profiling/FileOnlyProfilingConnection.cpp +++ b/src/profiling/FileOnlyProfilingConnection.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include diff --git a/src/profiling/ICounterDirectory.hpp b/src/profiling/ICounterDirectory.hpp index b19f7d306d..4492f854bf 100644 --- a/src/profiling/ICounterDirectory.hpp +++ b/src/profiling/ICounterDirectory.hpp @@ -13,8 +13,6 @@ #include #include -#include - namespace armnn { diff --git a/src/profiling/PeriodicCounterSelectionCommandHandler.cpp b/src/profiling/PeriodicCounterSelectionCommandHandler.cpp index 1b10643fca..e622123296 100644 --- a/src/profiling/PeriodicCounterSelectionCommandHandler.cpp +++ b/src/profiling/PeriodicCounterSelectionCommandHandler.cpp @@ -7,7 +7,8 @@ #include "ProfilingUtils.hpp" #include -#include +#include + #include #include @@ -21,8 +22,8 @@ namespace profiling void PeriodicCounterSelectionCommandHandler::ParseData(const arm::pipe::Packet& packet, CaptureData& captureData) { std::vector counterIds; - uint32_t sizeOfUint32 = boost::numeric_cast(sizeof(uint32_t)); - uint32_t sizeOfUint16 = boost::numeric_cast(sizeof(uint16_t)); + uint32_t sizeOfUint32 = armnn::numeric_cast(sizeof(uint32_t)); + uint32_t sizeOfUint16 = armnn::numeric_cast(sizeof(uint16_t)); uint32_t offset = 0; if (packet.GetLength() < 4) diff --git a/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp b/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp index 5768566178..84aae9d39f 100644 --- a/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp +++ b/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp @@ -6,11 +6,10 @@ #include "ProfilingConnectionDumpToFileDecorator.hpp" #include +#include #include -#include - namespace armnn { @@ -110,7 +109,7 @@ void ProfilingConnectionDumpToFileDecorator::DumpIncomingToFile(const arm::pipe: m_IncomingDumpFileStream.write(reinterpret_cast(&header), sizeof header); m_IncomingDumpFileStream.write(reinterpret_cast(&packetLength), sizeof packetLength); m_IncomingDumpFileStream.write(reinterpret_cast(packet.GetData()), - boost::numeric_cast(packetLength)); + armnn::numeric_cast(packetLength)); success &= m_IncomingDumpFileStream.good(); if (!(success || m_IgnoreFileErrors)) @@ -142,7 +141,7 @@ bool ProfilingConnectionDumpToFileDecorator::DumpOutgoingToFile(const unsigned c // attempt to write binary data m_OutgoingDumpFileStream.write(reinterpret_cast(buffer), - boost::numeric_cast(length)); + armnn::numeric_cast(length)); success &= m_OutgoingDumpFileStream.good(); if (!(success || m_IgnoreFileErrors)) { diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp index b673993846..3521fc0884 100644 --- a/src/profiling/ProfilingService.cpp +++ b/src/profiling/ProfilingService.cpp @@ -7,6 +7,8 @@ #include #include +#include + #include #include @@ -426,7 +428,7 @@ void ProfilingService::InitializeCounterValue(uint16_t counterUid) // Increase the size of the counter index if necessary if (counterUid >= m_CounterIndex.size()) { - m_CounterIndex.resize(boost::numeric_cast(counterUid) + 1); + m_CounterIndex.resize(armnn::numeric_cast(counterUid) + 1); } // Create a new atomic counter and add it to the list diff --git a/src/profiling/ProfilingUtils.cpp b/src/profiling/ProfilingUtils.cpp index 4767f3e746..f00f15667b 100644 --- a/src/profiling/ProfilingUtils.cpp +++ b/src/profiling/ProfilingUtils.cpp @@ -338,7 +338,7 @@ TimelinePacketStatus WriteTimelineLabelBinaryPacket(uint64_t profilingGuid, } // Calculate the size of the SWTrace string label (in bytes) - unsigned int swTraceLabelSize = boost::numeric_cast(swTraceLabel.size()) * uint32_t_size; + unsigned int swTraceLabelSize = armnn::numeric_cast(swTraceLabel.size()) * uint32_t_size; // Calculate the length of the data (in bytes) unsigned int timelineLabelPacketDataLength = uint32_t_size + // decl_Id @@ -541,7 +541,7 @@ TimelinePacketStatus WriteTimelineMessageDirectoryPackage(unsigned char* buffer, uint32_t declId = 0; try { - declId = boost::numeric_cast(std::stoul(directoryComponent[0])); + declId = armnn::numeric_cast(std::stoul(directoryComponent[0])); } catch (const std::exception&) { @@ -565,7 +565,7 @@ TimelinePacketStatus WriteTimelineMessageDirectoryPackage(unsigned char* buffer, } unsigned int dataLength = 3 * uint8_t_size + // Stream header (3 bytes) - boost::numeric_cast(swTraceBuffer.size()) * + armnn::numeric_cast(swTraceBuffer.size()) * uint32_t_size; // Trace directory (5 messages) // Calculate the timeline directory binary packet size (in bytes) @@ -579,7 +579,7 @@ TimelinePacketStatus WriteTimelineMessageDirectoryPackage(unsigned char* buffer, } // Create packet header - auto packetHeader = CreateTimelinePacketHeader(1, 0, 0, 0, 0, boost::numeric_cast(dataLength)); + auto packetHeader = CreateTimelinePacketHeader(1, 0, 0, 0, 0, armnn::numeric_cast(dataLength)); // Initialize the offset for writing in the buffer unsigned int offset = 0; @@ -592,8 +592,8 @@ TimelinePacketStatus WriteTimelineMessageDirectoryPackage(unsigned char* buffer, // Write the stream header uint8_t streamVersion = 4; - uint8_t pointerBytes = boost::numeric_cast(uint64_t_size); // All GUIDs are uint64_t - uint8_t threadIdBytes = boost::numeric_cast(ThreadIdSize); + uint8_t pointerBytes = armnn::numeric_cast(uint64_t_size); // All GUIDs are uint64_t + uint8_t threadIdBytes = armnn::numeric_cast(ThreadIdSize); switch (threadIdBytes) { case 4: // Typically Windows and Android @@ -610,7 +610,7 @@ TimelinePacketStatus WriteTimelineMessageDirectoryPackage(unsigned char* buffer, offset += uint8_t_size; // Write the SWTrace directory - uint32_t numberOfDeclarations = boost::numeric_cast(timelineDirectoryMessages.size()); + uint32_t numberOfDeclarations = armnn::numeric_cast(timelineDirectoryMessages.size()); WriteUint32(buffer, offset, numberOfDeclarations); // Number of declarations offset += uint32_t_size; for (uint32_t i : swTraceBuffer) diff --git a/src/profiling/ProfilingUtils.hpp b/src/profiling/ProfilingUtils.hpp index 79fa6c7bb0..b9c8327b0d 100644 --- a/src/profiling/ProfilingUtils.hpp +++ b/src/profiling/ProfilingUtils.hpp @@ -8,13 +8,13 @@ #include #include +#include + #include "ICounterDirectory.hpp" #include "IPacketBuffer.hpp" #include -#include - #include #include #include diff --git a/src/profiling/SendCounterPacket.cpp b/src/profiling/SendCounterPacket.cpp index 79123f0c5e..121ced9241 100644 --- a/src/profiling/SendCounterPacket.cpp +++ b/src/profiling/SendCounterPacket.cpp @@ -10,11 +10,11 @@ #include #include #include +#include #include #include #include -#include #include @@ -24,8 +24,6 @@ namespace armnn namespace profiling { -using boost::numeric_cast; - void SendCounterPacket::SendStreamMetaDataPacket() { const std::string info(GetSoftwareInfo()); @@ -33,10 +31,10 @@ void SendCounterPacket::SendStreamMetaDataPacket() const std::string softwareVersion(GetSoftwareVersion()); const std::string processName = GetProcessName().substr(0, 60); - const uint32_t infoSize = numeric_cast(info.size()) + 1; - const uint32_t hardwareVersionSize = numeric_cast(hardwareVersion.size()) + 1; - const uint32_t softwareVersionSize = numeric_cast(softwareVersion.size()) + 1; - const uint32_t processNameSize = numeric_cast(processName.size()) + 1; + const uint32_t infoSize = armnn::numeric_cast(info.size()) + 1; + const uint32_t hardwareVersionSize = armnn::numeric_cast(hardwareVersion.size()) + 1; + const uint32_t softwareVersionSize = armnn::numeric_cast(softwareVersion.size()) + 1; + const uint32_t processNameSize = armnn::numeric_cast(processName.size()) + 1; const uint32_t sizeUint32 = sizeof(uint32_t); @@ -75,11 +73,12 @@ void SendCounterPacket::SendStreamMetaDataPacket() packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 1), arm::pipe::EncodeVersion(1, 0, 0))); packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 0), arm::pipe::EncodeVersion(1, 0, 0))); packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 1), arm::pipe::EncodeVersion(1, 0, 0))); - uint32_t numberOfVersions = numeric_cast(packetVersions.size()); - uint32_t packetVersionSize = numeric_cast(numberOfVersions * 2 * sizeUint32); + uint32_t numberOfVersions = armnn::numeric_cast(packetVersions.size()); + uint32_t packetVersionSize = armnn::numeric_cast(numberOfVersions * 2 * sizeUint32); - const uint32_t payloadSize = numeric_cast(infoSize + hardwareVersionSize + softwareVersionSize + - processNameSize + packetVersionCountSize + packetVersionSize); + const uint32_t payloadSize = armnn::numeric_cast(infoSize + hardwareVersionSize + + softwareVersionSize + processNameSize + + packetVersionCountSize + packetVersionSize); const uint32_t totalSize = headerSize + bodySize + payloadSize; uint32_t offset = 0; @@ -112,7 +111,7 @@ void SendCounterPacket::SendStreamMetaDataPacket() WriteUint32(writeBuffer, offset, MAX_METADATA_PACKET_LENGTH); // max_data_length offset += sizeUint32; int pid = armnnUtils::Processes::GetCurrentId(); - WriteUint32(writeBuffer, offset, numeric_cast(pid)); // pid + WriteUint32(writeBuffer, offset, armnn::numeric_cast(pid)); // pid offset += sizeUint32; uint32_t poolOffset = bodySize; WriteUint32(writeBuffer, offset, poolOffset); // offset_info @@ -176,8 +175,6 @@ bool SendCounterPacket::CreateCategoryRecord(const CategoryPtr& category, CategoryRecord& categoryRecord, std::string& errorMessage) { - using namespace boost::numeric; - ARMNN_ASSERT(category); const std::string& categoryName = category->m_Name; @@ -236,8 +233,8 @@ bool SendCounterPacket::CreateCategoryRecord(const CategoryPtr& category, std::vector eventRecords(counterCount); std::vector eventRecordOffsets(counterCount, 0); size_t eventRecordsSize = 0; - uint32_t eventRecordsOffset = - numeric_cast((eventRecords.size() + categoryNameBuffer.size()) * uint32_t_size); + uint32_t eventRecordsOffset = armnn::numeric_cast( + (eventRecords.size() + categoryNameBuffer.size()) * uint32_t_size); for (size_t counterIndex = 0, eventRecordIndex = 0, eventRecordOffsetIndex = 0; counterIndex < counterCount; counterIndex++, eventRecordIndex++, eventRecordOffsetIndex++) @@ -257,12 +254,13 @@ bool SendCounterPacket::CreateCategoryRecord(const CategoryPtr& category, // Add the event record offset to the event pointer table offset field eventRecordOffsets[eventRecordOffsetIndex] = eventRecordsOffset; - eventRecordsOffset += numeric_cast(eventRecord.size() * uint32_t_size); + eventRecordsOffset += armnn::numeric_cast(eventRecord.size() * uint32_t_size); } // Category record word 3: // 0:31 [32] name_offset (offset from the beginning of the category data pool to the name field) - const uint32_t categoryRecordWord3 = numeric_cast((3u + eventRecordOffsets.size()) * uint32_t_size); + const uint32_t categoryRecordWord3 = armnn::numeric_cast( + (3u + eventRecordOffsets.size()) * uint32_t_size); // Calculate the size in words of the category record const size_t categoryRecordSize = 3u +// The size of the fixed part (device + counter_set + event_count + @@ -399,8 +397,6 @@ bool SendCounterPacket::CreateEventRecord(const CounterPtr& counter, EventRecord& eventRecord, std::string& errorMessage) { - using namespace boost::numeric; - ARMNN_ASSERT(counter); uint16_t counterUid = counter->m_Uid; @@ -499,7 +495,7 @@ bool SendCounterPacket::CreateEventRecord(const CounterPtr& counter, // The size of the description buffer in bytes const uint32_t eventRecordWord7 = includeUnits ? eventRecordWord6 + - numeric_cast(counterDescriptionBuffer.size() + armnn::numeric_cast(counterDescriptionBuffer.size() * uint32_t_size) : 0; @@ -553,8 +549,6 @@ bool SendCounterPacket::CreateEventRecord(const CounterPtr& counter, void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& counterDirectory) { - using namespace boost::numeric; - // Get the amount of data that needs to be put into the packet const uint16_t categoryCount = counterDirectory.GetCategoryCount(); const uint16_t deviceCount = counterDirectory.GetDeviceCount(); @@ -581,9 +575,9 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun size_t deviceIndex = 0; size_t deviceRecordOffsetIndex = 0; - pointerTableOffset = numeric_cast(deviceCount * uint32_t_size + - counterSetCount * uint32_t_size + - categoryCount * uint32_t_size); + pointerTableOffset = armnn::numeric_cast(deviceCount * uint32_t_size + + counterSetCount * uint32_t_size + + categoryCount * uint32_t_size); for (auto it = devices.begin(); it != devices.end(); it++) { const DevicePtr& device = it->second; @@ -600,7 +594,7 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun // Add the device record offset to the device records pointer table offset field deviceRecordOffsets[deviceRecordOffsetIndex] = pointerTableOffset; - pointerTableOffset += numeric_cast(deviceRecord.size() * uint32_t_size); + pointerTableOffset += armnn::numeric_cast(deviceRecord.size() * uint32_t_size); deviceIndex++; deviceRecordOffsetIndex++; @@ -618,7 +612,7 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun size_t counterSetIndex = 0; size_t counterSetRecordOffsetIndex = 0; - pointerTableOffset -= numeric_cast(deviceCount * uint32_t_size); + pointerTableOffset -= armnn::numeric_cast(deviceCount * uint32_t_size); for (auto it = counterSets.begin(); it != counterSets.end(); it++) { const CounterSetPtr& counterSet = it->second; @@ -635,7 +629,7 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun // Add the counter set record offset to the counter set records pointer table offset field counterSetRecordOffsets[counterSetRecordOffsetIndex] = pointerTableOffset; - pointerTableOffset += numeric_cast(counterSetRecord.size() * uint32_t_size); + pointerTableOffset += armnn::numeric_cast(counterSetRecord.size() * uint32_t_size); counterSetIndex++; counterSetRecordOffsetIndex++; @@ -653,7 +647,7 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun size_t categoryIndex = 0; size_t categoryRecordOffsetIndex = 0; - pointerTableOffset -= numeric_cast(counterSetCount * uint32_t_size); + pointerTableOffset -= armnn::numeric_cast(counterSetCount * uint32_t_size); for (auto it = categories.begin(); it != categories.end(); it++) { const CategoryPtr& category = *it; @@ -670,7 +664,7 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun // Add the category record offset to the category records pointer table offset field categoryRecordOffsets[categoryRecordOffsetIndex] = pointerTableOffset; - pointerTableOffset += numeric_cast(categoryRecord.size() * uint32_t_size); + pointerTableOffset += armnn::numeric_cast(categoryRecord.size() * uint32_t_size); categoryIndex++; categoryRecordOffsetIndex++; @@ -708,7 +702,8 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun // Packet header word 1: // 0:31 [32] data_length: length of data, in bytes - uint32_t packetHeaderWord1 = numeric_cast(counterDirectoryPacketDataLength * uint32_t_size); + uint32_t packetHeaderWord1 = armnn::numeric_cast( + counterDirectoryPacketDataLength * uint32_t_size); // Create the packet header uint32_t packetHeader[2] @@ -739,9 +734,9 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun // Body header word 3: // 0:31 [32] counter_set_pointer_table_offset: offset to the counter_set_pointer_table - const uint32_t bodyHeaderWord3 = - numeric_cast(deviceRecordOffsets.size() * uint32_t_size // The size of the - + bodyHeaderSizeBytes); // device records pointer table + const uint32_t bodyHeaderWord3 = armnn::numeric_cast(deviceRecordOffsets.size() * + uint32_t_size + // The size of the + bodyHeaderSizeBytes); // device records pointer table // Body header word 4: // 16:31 [16] categories_count: number of entries in the categories_pointer_table @@ -751,7 +746,7 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun // Body header word 3: // 0:31 [32] categories_pointer_table_offset: offset to the categories_pointer_table const uint32_t bodyHeaderWord5 = - numeric_cast( + armnn::numeric_cast( deviceRecordOffsets.size() * uint32_t_size + // The size of the device records counterSetRecordOffsets.size() * uint32_t_size // pointer table, plus the size of + bodyHeaderSizeBytes); // the counter set pointer table @@ -806,7 +801,7 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun ARMNN_NO_CONVERSION_WARN_END // Calculate the total size in bytes of the counter directory packet - uint32_t totalSize = numeric_cast(counterDirectoryPacketSize * uint32_t_size); + uint32_t totalSize = armnn::numeric_cast(counterDirectoryPacketSize * uint32_t_size); // Reserve space in the buffer for the packet uint32_t reserved = 0; @@ -826,7 +821,7 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun for (uint32_t counterDirectoryPacketWord : counterDirectoryPacket) { WriteUint32(writeBuffer, offset, counterDirectoryPacketWord); - offset += numeric_cast(uint32_t_size); + offset += armnn::numeric_cast(uint32_t_size); } m_BufferManager.Commit(writeBuffer, totalSize); @@ -842,7 +837,7 @@ void SendCounterPacket::SendPeriodicCounterCapturePacket(uint64_t timestamp, con uint32_t packetClass = 0; uint32_t packetType = 0; uint32_t headerSize = 2 * uint32_t_size; - uint32_t bodySize = uint64_t_size + numeric_cast(values.size()) * (uint16_t_size + uint32_t_size); + uint32_t bodySize = uint64_t_size + armnn::numeric_cast(values.size()) * (uint16_t_size + uint32_t_size); uint32_t totalSize = headerSize + bodySize; uint32_t offset = 0; uint32_t reserved = 0; @@ -891,7 +886,7 @@ void SendCounterPacket::SendPeriodicCounterSelectionPacket(uint32_t capturePerio uint32_t packetFamily = 0; uint32_t packetId = 4; uint32_t headerSize = 2 * uint32_t_size; - uint32_t bodySize = uint32_t_size + numeric_cast(selectedCounterIds.size()) * uint16_t_size; + uint32_t bodySize = uint32_t_size + armnn::numeric_cast(selectedCounterIds.size()) * uint16_t_size; uint32_t totalSize = headerSize + bodySize; uint32_t offset = 0; uint32_t reserved = 0; diff --git a/src/profiling/SendThread.cpp b/src/profiling/SendThread.cpp index 86e6c05a02..16ef2399f7 100644 --- a/src/profiling/SendThread.cpp +++ b/src/profiling/SendThread.cpp @@ -8,10 +8,11 @@ #include #include +#include + #include #include -#include #include @@ -21,8 +22,6 @@ namespace armnn namespace profiling { -using boost::numeric_cast; - SendThread::SendThread(armnn::profiling::ProfilingStateMachine& profilingStateMachine, armnn::profiling::IBufferManager& buffer, armnn::profiling::ISendCounterPacket& sendCounterPacket, @@ -235,7 +234,7 @@ void SendThread::FlushBuffer(IProfilingConnection& profilingConnection, bool not if (profilingConnection.IsOpen()) { // Write a packet to the profiling connection. Silently ignore any write error and continue - profilingConnection.WritePacket(readBuffer, boost::numeric_cast(readBufferSize)); + profilingConnection.WritePacket(readBuffer, armnn::numeric_cast(readBufferSize)); // Set the flag that indicates whether at least a packet has been sent packetsSent = true; diff --git a/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp b/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp index f9df633a1c..943650a8f1 100644 --- a/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp +++ b/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp @@ -11,7 +11,6 @@ #include #include "TestTimelinePacketHandler.hpp" -#include #include #include diff --git a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp index d6700bc41a..0feed4138f 100644 --- a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp +++ b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp @@ -7,11 +7,11 @@ #include #include #include +#include #include #include -#include #include using namespace armnn::profiling; @@ -20,7 +20,7 @@ namespace { const std::vector g_Data = { 'd', 'u', 'm', 'm', 'y' }; -const uint32_t g_DataLength = boost::numeric_cast(g_Data.size()); +const uint32_t g_DataLength = armnn::numeric_cast(g_Data.size()); const unsigned char* g_DataPtr = reinterpret_cast(g_Data.data()); class DummyProfilingConnection : public IProfilingConnection diff --git a/src/profiling/test/ProfilingMocks.hpp b/src/profiling/test/ProfilingMocks.hpp index 8bcf27a8d1..19d79e25e7 100644 --- a/src/profiling/test/ProfilingMocks.hpp +++ b/src/profiling/test/ProfilingMocks.hpp @@ -19,8 +19,7 @@ #include #include #include - -#include +#include #include #include @@ -571,10 +570,10 @@ public: } // Getters for counts - uint16_t GetCategoryCount() const override { return boost::numeric_cast(m_Categories.size()); } - uint16_t GetDeviceCount() const override { return boost::numeric_cast(m_Devices.size()); } - uint16_t GetCounterSetCount() const override { return boost::numeric_cast(m_CounterSets.size()); } - uint16_t GetCounterCount() const override { return boost::numeric_cast(m_Counters.size()); } + uint16_t GetCategoryCount() const override { return armnn::numeric_cast(m_Categories.size()); } + uint16_t GetDeviceCount() const override { return armnn::numeric_cast(m_Devices.size()); } + uint16_t GetCounterSetCount() const override { return armnn::numeric_cast(m_CounterSets.size()); } + uint16_t GetCounterCount() const override { return armnn::numeric_cast(m_Counters.size()); } // Getters for collections const Categories& GetCategories() const override { return m_Categories; } diff --git a/src/profiling/test/ProfilingTestUtils.cpp b/src/profiling/test/ProfilingTestUtils.cpp index 8050eaa508..09639bfae7 100644 --- a/src/profiling/test/ProfilingTestUtils.cpp +++ b/src/profiling/test/ProfilingTestUtils.cpp @@ -7,6 +7,8 @@ #include "ProfilingUtils.hpp" #include +#include + #include #include #include @@ -20,10 +22,10 @@ uint32_t GetStreamMetaDataPacketSize() { uint32_t sizeUint32 = sizeof(uint32_t); uint32_t payloadSize = 0; - payloadSize += boost::numeric_cast(GetSoftwareInfo().size()) + 1; - payloadSize += boost::numeric_cast(GetHardwareVersion().size()) + 1; - payloadSize += boost::numeric_cast(GetSoftwareVersion().size()) + 1; - payloadSize += boost::numeric_cast(GetProcessName().size()) + 1; + payloadSize += armnn::numeric_cast(GetSoftwareInfo().size()) + 1; + payloadSize += armnn::numeric_cast(GetHardwareVersion().size()) + 1; + payloadSize += armnn::numeric_cast(GetSoftwareVersion().size()) + 1; + payloadSize += armnn::numeric_cast(GetProcessName().size()) + 1; // Add packetVersionEntries payloadSize += 13 * 2 * sizeUint32; @@ -105,7 +107,7 @@ ProfilingGuid VerifyTimelineLabelBinaryPacketData(Optional guid, // Utils unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); - unsigned int label_size = boost::numeric_cast(label.size()); + unsigned int label_size = armnn::numeric_cast(label.size()); // Check the decl id uint32_t eventClassDeclId = ReadUint32(readableData, offset); diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index f616442df0..b06d3b0bc6 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -33,14 +33,13 @@ #include #include +#include #include #include #include #include -#include - #include #include #include @@ -1750,8 +1749,6 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter) BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData) { - using boost::numeric_cast; - ProfilingStateMachine profilingStateMachine; class TestCaptureThread : public IPeriodicCounterCapture @@ -1798,8 +1795,8 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData) SendCounterPacket sendCounterPacket(mockBuffer); SendThread sendThread(profilingStateMachine, mockBuffer, sendCounterPacket); - uint32_t sizeOfUint32 = numeric_cast(sizeof(uint32_t)); - uint32_t sizeOfUint16 = numeric_cast(sizeof(uint16_t)); + uint32_t sizeOfUint32 = armnn::numeric_cast(sizeof(uint32_t)); + uint32_t sizeOfUint16 = armnn::numeric_cast(sizeof(uint16_t)); // Data with period and counters uint32_t period1 = armnn::LOWEST_CAPTURE_PERIOD; @@ -2024,14 +2021,12 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceNotActive) BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged) { - using boost::numeric_cast; - const uint32_t packetFamilyId = 0; const uint32_t connectionPacketId = 0x10000; const uint32_t version = 1; - uint32_t sizeOfUint32 = numeric_cast(sizeof(uint32_t)); - uint32_t sizeOfUint16 = numeric_cast(sizeof(uint16_t)); + uint32_t sizeOfUint32 = armnn::numeric_cast(sizeof(uint32_t)); + uint32_t sizeOfUint16 = armnn::numeric_cast(sizeof(uint16_t)); // Data with period and counters uint32_t period1 = 10; @@ -2407,8 +2402,6 @@ BOOST_AUTO_TEST_CASE(CheckPeriodicCounterCaptureThread) BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1) { - using boost::numeric_cast; - const uint32_t familyId = 0; const uint32_t packetId = 3; const uint32_t version = 1; @@ -2453,7 +2446,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1) BOOST_TEST(header1Word1 == 24); // data length uint32_t bodyHeader1Word0 = ReadUint32(readBuffer1, 8); - uint16_t deviceRecordCount = numeric_cast(bodyHeader1Word0 >> 16); + uint16_t deviceRecordCount = armnn::numeric_cast(bodyHeader1Word0 >> 16); BOOST_TEST(deviceRecordCount == 0); // device_records_count auto readBuffer2 = mockBuffer2.GetReadableBuffer(); @@ -2469,8 +2462,6 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1) BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2) { - using boost::numeric_cast; - const uint32_t familyId = 0; const uint32_t packetId = 3; const uint32_t version = 1; @@ -2522,9 +2513,9 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2) const uint32_t bodyHeader1Word3 = ReadUint32(readBuffer1, 20); const uint32_t bodyHeader1Word4 = ReadUint32(readBuffer1, 24); const uint32_t bodyHeader1Word5 = ReadUint32(readBuffer1, 28); - const uint16_t deviceRecordCount = numeric_cast(bodyHeader1Word0 >> 16); - const uint16_t counterSetRecordCount = numeric_cast(bodyHeader1Word2 >> 16); - const uint16_t categoryRecordCount = numeric_cast(bodyHeader1Word4 >> 16); + const uint16_t deviceRecordCount = armnn::numeric_cast(bodyHeader1Word0 >> 16); + const uint16_t counterSetRecordCount = armnn::numeric_cast(bodyHeader1Word2 >> 16); + const uint16_t categoryRecordCount = armnn::numeric_cast(bodyHeader1Word4 >> 16); BOOST_TEST(deviceRecordCount == 1); // device_records_count BOOST_TEST(bodyHeader1Word1 == 0 + bodyHeaderSizeBytes); // device_records_pointer_table_offset BOOST_TEST(counterSetRecordCount == 1); // counter_set_count diff --git a/src/profiling/test/RequestCountersPacketHandler.cpp b/src/profiling/test/RequestCountersPacketHandler.cpp index 230c38857f..3ba50503a1 100644 --- a/src/profiling/test/RequestCountersPacketHandler.cpp +++ b/src/profiling/test/RequestCountersPacketHandler.cpp @@ -6,8 +6,10 @@ #include "RequestCountersPacketHandler.hpp" #include "DirectoryCaptureCommandHandler.hpp" -#include +#include + +#include #include namespace armnn @@ -53,7 +55,7 @@ void RequestCountersPacketHandler::SendCounterSelectionPacket() uint32_t uint32_t_size = sizeof(uint32_t); uint32_t offset = 0; - uint32_t bodySize = uint32_t_size + boost::numeric_cast(m_IdList.size()) * uint16_t_size; + uint32_t bodySize = uint32_t_size + armnn::numeric_cast(m_IdList.size()) * uint16_t_size; auto uniqueData = std::make_unique(bodySize); auto data = reinterpret_cast(uniqueData.get()); diff --git a/src/profiling/test/SendCounterPacketTests.cpp b/src/profiling/test/SendCounterPacketTests.cpp index 87cfb5bf58..950f8ffad0 100644 --- a/src/profiling/test/SendCounterPacketTests.cpp +++ b/src/profiling/test/SendCounterPacketTests.cpp @@ -20,9 +20,7 @@ #include - #include -#include #include @@ -289,9 +287,7 @@ BOOST_AUTO_TEST_CASE(SendPeriodicCounterCapturePacketTest) BOOST_AUTO_TEST_CASE(SendStreamMetaDataPacketTest) { - using boost::numeric_cast; - - uint32_t sizeUint32 = numeric_cast(sizeof(uint32_t)); + uint32_t sizeUint32 = armnn::numeric_cast(sizeof(uint32_t)); // Error no space left in buffer MockBufferManager mockBuffer1(10); @@ -302,10 +298,10 @@ BOOST_AUTO_TEST_CASE(SendStreamMetaDataPacketTest) std::string processName = GetProcessName().substr(0, 60); - uint32_t infoSize = numeric_cast(GetSoftwareInfo().size()) + 1; - uint32_t hardwareVersionSize = numeric_cast(GetHardwareVersion().size()) + 1; - uint32_t softwareVersionSize = numeric_cast(GetSoftwareVersion().size()) + 1; - uint32_t processNameSize = numeric_cast(processName.size()) + 1; + uint32_t infoSize = armnn::numeric_cast(GetSoftwareInfo().size()) + 1; + uint32_t hardwareVersionSize = armnn::numeric_cast(GetHardwareVersion().size()) + 1; + uint32_t softwareVersionSize = armnn::numeric_cast(GetSoftwareVersion().size()) + 1; + uint32_t processNameSize = armnn::numeric_cast(processName.size()) + 1; // Supported Packets // Packet Encoding version 1.0.0 @@ -352,9 +348,11 @@ BOOST_AUTO_TEST_CASE(SendStreamMetaDataPacketTest) BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0); // packet family BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 0); // packet id - uint32_t totalLength = numeric_cast(2 * sizeUint32 + 10 * sizeUint32 + infoSize + hardwareVersionSize + - softwareVersionSize + processNameSize + sizeUint32 + - 2 * packetEntries * sizeUint32); + uint32_t totalLength = armnn::numeric_cast(2 * sizeUint32 + + 10 * sizeUint32 + infoSize + + hardwareVersionSize + softwareVersionSize + + processNameSize + sizeUint32 + + 2 * packetEntries * sizeUint32); BOOST_TEST(headerWord1 == totalLength - (2 * sizeUint32)); // data length @@ -366,7 +364,7 @@ BOOST_AUTO_TEST_CASE(SendStreamMetaDataPacketTest) BOOST_TEST(ReadUint32(readBuffer2, offset) == MAX_METADATA_PACKET_LENGTH); // max_data_len offset += sizeUint32; int pid = armnnUtils::Processes::GetCurrentId(); - BOOST_TEST(ReadUint32(readBuffer2, offset) == numeric_cast(pid)); + BOOST_TEST(ReadUint32(readBuffer2, offset) == armnn::numeric_cast(pid)); offset += sizeUint32; uint32_t poolOffset = 10 * sizeUint32; BOOST_TEST(ReadUint32(readBuffer2, offset) == poolOffset); // offset_info @@ -942,7 +940,7 @@ BOOST_AUTO_TEST_CASE(CreateCategoryRecordTest) ARMNN_ASSERT(counter1); ARMNN_ASSERT(counter2); ARMNN_ASSERT(counter3); - uint16_t categoryEventCount = boost::numeric_cast(counters.size()); + uint16_t categoryEventCount = armnn::numeric_cast(counters.size()); // Create a category record SendCounterPacket::CategoryRecord categoryRecord; diff --git a/src/profiling/test/SendCounterPacketTests.hpp b/src/profiling/test/SendCounterPacketTests.hpp index ef8f63de0f..2eac395ecf 100644 --- a/src/profiling/test/SendCounterPacketTests.hpp +++ b/src/profiling/test/SendCounterPacketTests.hpp @@ -15,8 +15,7 @@ #include #include #include - -#include +#include #include #include diff --git a/src/profiling/test/TimelinePacketTests.cpp b/src/profiling/test/TimelinePacketTests.cpp index 4f056ce761..811918a3e3 100644 --- a/src/profiling/test/TimelinePacketTests.cpp +++ b/src/profiling/test/TimelinePacketTests.cpp @@ -6,10 +6,11 @@ #include #include +#include + #include #include -#include using namespace armnn::profiling; @@ -55,7 +56,7 @@ BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestBufferExhaustionFixedValue) TimelinePacketStatus result = WriteTimelineLabelBinaryPacket(profilingGuid, label, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); @@ -71,7 +72,7 @@ BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestInvalidLabel) TimelinePacketStatus result = WriteTimelineLabelBinaryPacket(profilingGuid, label, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Error); BOOST_CHECK(numberOfBytesWritten == 0); @@ -87,7 +88,7 @@ BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestSingleConstructionOfData) TimelinePacketStatus result = WriteTimelineLabelBinaryPacket(profilingGuid, label, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); BOOST_CHECK(numberOfBytesWritten == 28); @@ -178,7 +179,7 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketSmallBufferSizeTest) tailGuid, attributeGuid, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); @@ -201,7 +202,7 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketInvalidRelationTest) tailGuid, attributeGuid, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten), armnn::InvalidArgumentException); @@ -225,7 +226,7 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketTestDataConstruction) tailGuid, attributeGuid, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); BOOST_CHECK(numberOfBytesWritten == 40); @@ -282,7 +283,7 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketExecutionLinkTestDataConstruction tailGuid, attributeGuid, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); BOOST_CHECK(numberOfBytesWritten == 40); @@ -338,7 +339,7 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketDataLinkTestDataConstruction) tailGuid, attributeGuid, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); BOOST_CHECK(numberOfBytesWritten == 40); @@ -394,7 +395,7 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketLabelLinkTestDataConstruction) tailGuid, attributeGuid, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); BOOST_CHECK(numberOfBytesWritten == 40); @@ -460,7 +461,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction) std::vector buffer(512, 0); unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = WriteTimelineMessageDirectoryPackage(buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); @@ -527,7 +528,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction) // Check the ui_name std::vector swTraceString; arm::pipe::StringToSwTraceString(label, swTraceString); - offset += (boost::numeric_cast(swTraceString.size()) - 1) * uint32_t_size; + offset += (armnn::numeric_cast(swTraceString.size()) - 1) * uint32_t_size; uint32_t swTraceUINameLength = ReadUint32(buffer.data(), offset); BOOST_CHECK(swTraceUINameLength == 14); // ui_name length including the null-terminator @@ -539,7 +540,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction) // Check arg_types arm::pipe::StringToSwTraceString(label, swTraceString); - offset += (boost::numeric_cast(swTraceString.size()) - 1) * uint32_t_size; + offset += (armnn::numeric_cast(swTraceString.size()) - 1) * uint32_t_size; uint32_t swTraceArgTypesLength = ReadUint32(buffer.data(), offset); BOOST_CHECK(swTraceArgTypesLength == 3); // arg_types length including the null-terminator @@ -551,7 +552,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction) // Check arg_names arm::pipe::StringToSwTraceString(label, swTraceString); - offset += (boost::numeric_cast(swTraceString.size()) - 1) * uint32_t_size; + offset += (armnn::numeric_cast(swTraceString.size()) - 1) * uint32_t_size; uint32_t swTraceArgNamesLength = ReadUint32(buffer.data(), offset); BOOST_CHECK(swTraceArgNamesLength == 11); // arg_names length including the null-terminator @@ -563,7 +564,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction) // Check second message decl_id arm::pipe::StringToSwTraceString(label, swTraceString); - offset += (boost::numeric_cast(swTraceString.size()) - 1) * uint32_t_size; + offset += (armnn::numeric_cast(swTraceString.size()) - 1) * uint32_t_size; readDeclId = ReadUint32(buffer.data(), offset); BOOST_CHECK(readDeclId == 1); @@ -613,7 +614,7 @@ BOOST_AUTO_TEST_CASE(TimelineEntityPacketTestBufferExhaustedWithFixedBufferSize) unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = WriteTimelineEntityBinary(profilingGuid, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); @@ -627,7 +628,7 @@ BOOST_AUTO_TEST_CASE(TimelineEntityPacketTestFullConstructionOfData) unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = WriteTimelineEntityBinary(profilingGuid, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); BOOST_CHECK(numberOfBytesWritten == 12); @@ -685,7 +686,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventClassTestBufferExhaustionFixedValue) TimelinePacketStatus result = WriteTimelineEventClassBinary(profilingGuid, profilingNameGuid, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); @@ -701,7 +702,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventClassTestFullConstructionOfData) TimelinePacketStatus result = WriteTimelineEventClassBinary(profilingGuid, profilingNameGuid, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); BOOST_CHECK(numberOfBytesWritten == 20); @@ -770,7 +771,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTestBufferExhaustionFixedValue) threadId, profilingGuid, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); @@ -788,7 +789,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTestFullConstructionOfData) threadId, profilingGuid, buffer.data(), - boost::numeric_cast(buffer.size()), + armnn::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); -- cgit v1.2.1