From f9db3efe5ce2b989b59c47056e1b84b32d2f1100 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Tue, 8 Mar 2022 21:23:44 +0000 Subject: IVGCVSW-6821 Remove dependency on armnn::Exception classes from the Profiling code Change-Id: Id46a9a0576091df21b2af5b472f1ca5c6335e8a3 Signed-off-by: Jim Flynn --- include/armnn/Exceptions.hpp | 6 -- profiling/common/include/ProfilingException.hpp | 20 ++++- .../ActivateTimelineReportingCommandHandler.cpp | 19 +++-- src/profiling/CommandHandler.cpp | 6 +- .../ConnectionAcknowledgedCommandHandler.cpp | 23 +++--- src/profiling/CounterDirectory.cpp | 91 +++++++++++----------- src/profiling/CounterIdMap.cpp | 8 +- .../DeactivateTimelineReportingCommandHandler.cpp | 21 ++--- src/profiling/FileOnlyProfilingConnection.cpp | 3 +- src/profiling/PacketBuffer.cpp | 6 +- .../PerJobCounterSelectionCommandHandler.cpp | 17 ++-- src/profiling/PeriodicCounterCapture.cpp | 4 +- .../PeriodicCounterSelectionCommandHandler.cpp | 18 ++--- .../ProfilingConnectionDumpToFileDecorator.cpp | 6 +- src/profiling/ProfilingConnectionFactory.cpp | 2 +- src/profiling/ProfilingService.cpp | 12 +-- src/profiling/ProfilingStateMachine.cpp | 4 +- src/profiling/ProfilingUtils.cpp | 6 +- src/profiling/ProfilingUtils.hpp | 8 +- .../RequestCounterDirectoryCommandHandler.cpp | 18 ++--- src/profiling/SendCounterPacket.cpp | 24 +++--- src/profiling/SendCounterPacket.hpp | 2 +- src/profiling/SendThread.cpp | 7 +- src/profiling/SendTimelinePacket.cpp | 8 +- src/profiling/SendTimelinePacket.hpp | 16 ++-- src/profiling/TimelineUtilityMethods.cpp | 24 +++--- src/profiling/test/BufferTests.cpp | 8 +- ...ProfilingConnectionDumpToFileDecoratorTests.cpp | 4 +- src/profiling/test/ProfilingMocks.hpp | 6 +- src/profiling/test/ProfilingTests.cpp | 65 +++++++++------- src/profiling/test/ProfilingTests.hpp | 6 +- src/profiling/test/SendCounterPacketTests.cpp | 16 ++-- src/profiling/test/SendCounterPacketTests.hpp | 2 +- src/profiling/test/SendTimelinePacketTests.cpp | 2 +- src/profiling/test/TestTimelinePacketHandler.cpp | 6 +- src/profiling/test/TimelineUtilityMethodsTests.cpp | 2 +- src/timelineDecoder/JSONTimelineDecoder.cpp | 5 +- 37 files changed, 260 insertions(+), 241 deletions(-) diff --git a/include/armnn/Exceptions.hpp b/include/armnn/Exceptions.hpp index 980b57449d..19b7f87e5a 100644 --- a/include/armnn/Exceptions.hpp +++ b/include/armnn/Exceptions.hpp @@ -137,12 +137,6 @@ class TimeoutException : public Exception using Exception::Exception; }; -class BackendProfilingException : public Exception -{ -public: - using Exception::Exception; -}; - class PolymorphicDowncastException : public Exception { public: diff --git a/profiling/common/include/ProfilingException.hpp b/profiling/common/include/ProfilingException.hpp index abdc0dc025..82b724aaa0 100644 --- a/profiling/common/include/ProfilingException.hpp +++ b/profiling/common/include/ProfilingException.hpp @@ -64,7 +64,13 @@ private: std::string m_Message; }; -class TimeoutException : public ProfilingException +class BackendProfilingException : public ProfilingException +{ +public: + using ProfilingException::ProfilingException; +}; + +class BufferExhaustion : public ProfilingException { public: using ProfilingException::ProfilingException; @@ -76,6 +82,18 @@ public: using ProfilingException::ProfilingException; }; +class TimeoutException : public ProfilingException +{ +public: + using ProfilingException::ProfilingException; +}; + +class UnimplementedException : public ProfilingException +{ +public: + using ProfilingException::ProfilingException; +}; + } // namespace pipe } // namespace arm diff --git a/src/profiling/ActivateTimelineReportingCommandHandler.cpp b/src/profiling/ActivateTimelineReportingCommandHandler.cpp index 940b823978..bc814f0278 100644 --- a/src/profiling/ActivateTimelineReportingCommandHandler.cpp +++ b/src/profiling/ActivateTimelineReportingCommandHandler.cpp @@ -8,7 +8,8 @@ #include #include -#include +#include + #include namespace arm @@ -23,8 +24,9 @@ void ActivateTimelineReportingCommandHandler::operator()(const arm::pipe::Packet if (!m_ReportStructure.has_value()) { - throw armnn::Exception(std::string("Profiling Service constructor must be initialised with an " - "IReportStructure argument in order to run timeline reporting")); + throw arm::pipe::ProfilingException(std::string( + "Profiling Service constructor must be initialised with an " + "IReportStructure argument in order to run timeline reporting")); } switch ( currentState ) @@ -32,13 +34,14 @@ void ActivateTimelineReportingCommandHandler::operator()(const arm::pipe::Packet case ProfilingState::Uninitialised: case ProfilingState::NotConnected: case ProfilingState::WaitingForAck: - throw armnn::RuntimeException(fmt::format( + throw arm::pipe::ProfilingException(fmt::format( "Activate Timeline Reporting Command Handler invoked while in a wrong state: {}", GetProfilingStateName(currentState))); case ProfilingState::Active: if ( !( packet.GetPacketFamily() == 0u && packet.GetPacketId() == 6u )) { - throw armnn::Exception(std::string("Expected Packet family = 0, id = 6 but received family =") + throw arm::pipe::ProfilingException(std::string( + "Expected Packet family = 0, id = 6 but received family =") + std::to_string(packet.GetPacketFamily()) + " id = " + std::to_string(packet.GetPacketId())); } @@ -61,11 +64,11 @@ void ActivateTimelineReportingCommandHandler::operator()(const arm::pipe::Packet break; default: - throw armnn::RuntimeException(fmt::format("Unknown profiling service state: {}", - static_cast(currentState))); + throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", + static_cast(currentState))); } } } // namespace pipe -} // namespace arm \ No newline at end of file +} // namespace arm diff --git a/src/profiling/CommandHandler.cpp b/src/profiling/CommandHandler.cpp index f709b2826c..0cacf22536 100644 --- a/src/profiling/CommandHandler.cpp +++ b/src/profiling/CommandHandler.cpp @@ -65,7 +65,7 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection) ARMNN_ASSERT(commandHandlerFunctor); commandHandlerFunctor->operator()(packet); } - catch (const armnn::TimeoutException&) + catch (const arm::pipe::TimeoutException&) { if (m_StopAfterTimeout.load()) { @@ -85,10 +85,10 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection) m_KeepRunning.store(false); } } - catch (const armnn::Exception& e) + catch (...) { // Log the error and continue - ARMNN_LOG(warning) << "An error has occurred when handling a command: " << e.what(); + ARMNN_LOG(warning) << "An unknown error has occurred when handling a command"; // Did we get here because the socket failed? if ( !profilingConnection.IsOpen() ) { diff --git a/src/profiling/ConnectionAcknowledgedCommandHandler.cpp b/src/profiling/ConnectionAcknowledgedCommandHandler.cpp index a3dabd53f5..70c260b043 100644 --- a/src/profiling/ConnectionAcknowledgedCommandHandler.cpp +++ b/src/profiling/ConnectionAcknowledgedCommandHandler.cpp @@ -6,7 +6,7 @@ #include "ConnectionAcknowledgedCommandHandler.hpp" #include "TimelineUtilityMethods.hpp" -#include +#include #include @@ -23,17 +23,17 @@ void ConnectionAcknowledgedCommandHandler::operator()(const arm::pipe::Packet& p { case ProfilingState::Uninitialised: case ProfilingState::NotConnected: - throw armnn::RuntimeException(fmt::format("Connection Acknowledged Command Handler invoked while in an " - "wrong state: {}", - GetProfilingStateName(currentState))); + throw arm::pipe::ProfilingException(fmt::format("Connection Acknowledged Command Handler invoked while in an " + "wrong state: {}", + GetProfilingStateName(currentState))); case ProfilingState::WaitingForAck: // Process the packet if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 1u)) { - throw armnn::InvalidArgumentException(fmt::format("Expected Packet family = 0, id = 1 but " - "received family = {}, id = {}", - packet.GetPacketFamily(), - packet.GetPacketId())); + throw arm::pipe::InvalidArgumentException(fmt::format("Expected Packet family = 0, id = 1 but " + "received family = {}, id = {}", + packet.GetPacketFamily(), + packet.GetPacketId())); } // Once a Connection Acknowledged packet has been received, move to the Active state immediately @@ -54,7 +54,7 @@ void ConnectionAcknowledgedCommandHandler::operator()(const arm::pipe::Packet& p // Enable profiling on the backend and assert that it returns true if(!backendContext.second->EnableProfiling(true)) { - throw armnn::BackendProfilingException( + throw arm::pipe::BackendProfilingException( "Unable to enable profiling on Backend Id: " + backendContext.first); } } @@ -67,12 +67,11 @@ void ConnectionAcknowledgedCommandHandler::operator()(const arm::pipe::Packet& p case ProfilingState::Active: return; // NOP default: - throw armnn::RuntimeException(fmt::format("Unknown profiling service state: {}", - static_cast(currentState))); + throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", + static_cast(currentState))); } } } // namespace pipe } // namespace arm - diff --git a/src/profiling/CounterDirectory.cpp b/src/profiling/CounterDirectory.cpp index ba4ca1cc35..11dc3803dd 100644 --- a/src/profiling/CounterDirectory.cpp +++ b/src/profiling/CounterDirectory.cpp @@ -25,14 +25,15 @@ const Category* CounterDirectory::RegisterCategory(const std::string& categoryNa if (categoryName.empty() || !arm::pipe::IsValidSwTraceString(categoryName)) { - throw InvalidArgumentException("Trying to register a category with an invalid name"); + throw arm::pipe::InvalidArgumentException("Trying to register a category with an invalid name"); } // Check that the given category is not already registered if (IsCategoryRegistered(categoryName)) { - throw InvalidArgumentException(fmt::format("Trying to register a category already registered (\"{}\")", - categoryName)); + throw arm::pipe::InvalidArgumentException(fmt::format( + "Trying to register a category already registered (\"{}\")", + categoryName)); } // Create the category @@ -57,14 +58,15 @@ const Device* CounterDirectory::RegisterDevice(const std::string& deviceName, if (deviceName.empty() || !arm::pipe::IsValidSwTraceString(deviceName)) { - throw InvalidArgumentException("Trying to register a device with an invalid name"); + throw arm::pipe::InvalidArgumentException("Trying to register a device with an invalid name"); } // Check that a device with the given name is not already registered if (IsDeviceRegistered(deviceName)) { - throw InvalidArgumentException(fmt::format("Trying to register a device already registered (\"{}\")", - deviceName)); + throw arm::pipe::InvalidArgumentException(fmt::format( + "Trying to register a device already registered (\"{}\")", + deviceName)); } // Check that a category with the given (optional) parent category name is already registered @@ -74,22 +76,22 @@ const Device* CounterDirectory::RegisterDevice(const std::string& deviceName, const std::string& parentCategoryNameValue = parentCategoryName.value(); if (parentCategoryNameValue.empty()) { - throw InvalidArgumentException( - fmt::format("Trying to connect a device (name: \"{}\") to an invalid " - "parent category (name: \"{}\")", - deviceName, - parentCategoryNameValue)); + throw arm::pipe::InvalidArgumentException( + fmt::format("Trying to connect a device (name: \"{}\") to an invalid " + "parent category (name: \"{}\")", + deviceName, + parentCategoryNameValue)); } // Check that the given parent category is already registered auto categoryIt = FindCategory(parentCategoryNameValue); if (categoryIt == m_Categories.end()) { - throw InvalidArgumentException( - fmt::format("Trying to connect a device (name: \"{}\") to a parent category that " - "is not registered (name: \"{}\")", - deviceName, - parentCategoryNameValue)); + throw arm::pipe::InvalidArgumentException( + fmt::format("Trying to connect a device (name: \"{}\") to a parent category that " + "is not registered (name: \"{}\")", + deviceName, + parentCategoryNameValue)); } } @@ -118,15 +120,14 @@ const CounterSet* CounterDirectory::RegisterCounterSet(const std::string& counte if (counterSetName.empty() || !arm::pipe::IsValidSwTraceString(counterSetName)) { - throw InvalidArgumentException("Trying to register a counter set with an invalid name"); + throw arm::pipe::InvalidArgumentException("Trying to register a counter set with an invalid name"); } // Check that a counter set with the given name is not already registered if (IsCounterSetRegistered(counterSetName)) { - throw InvalidArgumentException( - fmt::format("Trying to register a counter set already registered (\"{}\")", - counterSetName)); + throw arm::pipe::InvalidArgumentException( + fmt::format("Trying to register a counter set already registered (\"{}\")", counterSetName)); } // Peek the next UID, do not get an actual valid UID just now as we don't want to waste a good UID in case @@ -140,8 +141,8 @@ const CounterSet* CounterDirectory::RegisterCounterSet(const std::string& counte const std::string& parentCategoryNameValue = parentCategoryName.value(); if (parentCategoryNameValue.empty()) { - throw InvalidArgumentException( - fmt::format("Trying to connect a counter set (UID: {}) to an invalid " + throw arm::pipe::InvalidArgumentException( + fmt::format("Trying to connect a counter set (UID: {}) to an invalid " "parent category (name: \"{}\")", counterSetUidPeek, parentCategoryNameValue)); @@ -151,11 +152,11 @@ const CounterSet* CounterDirectory::RegisterCounterSet(const std::string& counte auto it = FindCategory(parentCategoryNameValue); if (it == m_Categories.end()) { - throw InvalidArgumentException( - fmt::format("Trying to connect a counter set (UID: {}) to a parent category " - "that is not registered (name: \"{}\")", - counterSetUidPeek, - parentCategoryNameValue)); + throw arm::pipe::InvalidArgumentException( + fmt::format("Trying to connect a counter set (UID: {}) to a parent category " + "that is not registered (name: \"{}\")", + counterSetUidPeek, + parentCategoryNameValue)); } } @@ -194,55 +195,55 @@ const Counter* CounterDirectory::RegisterCounter(const std::string& /*backendId* if (parentCategoryName.empty() || !arm::pipe::IsValidSwTraceString(parentCategoryName)) { - throw InvalidArgumentException("Trying to register a counter with an invalid parent category name"); + throw arm::pipe::InvalidArgumentException("Trying to register a counter with an invalid parent category name"); } // Check that the given class is valid if (counterClass != 0 && counterClass != 1) { - throw InvalidArgumentException("Trying to register a counter with an invalid class"); + throw arm::pipe::InvalidArgumentException("Trying to register a counter with an invalid class"); } // Check that the given interpolation is valid if (interpolation != 0 && interpolation != 1) { - throw InvalidArgumentException("Trying to register a counter with an invalid interpolation"); + throw arm::pipe::InvalidArgumentException("Trying to register a counter with an invalid interpolation"); } // Check that the given multiplier is valid if (multiplier == .0f) { - throw InvalidArgumentException("Trying to register a counter with an invalid multiplier"); + throw arm::pipe::InvalidArgumentException("Trying to register a counter with an invalid multiplier"); } // Check that the given name is valid if (name.empty() || !arm::pipe::IsValidSwTraceString(name)) { - throw InvalidArgumentException("Trying to register a counter with an invalid name"); + throw arm::pipe::InvalidArgumentException("Trying to register a counter with an invalid name"); } // Check that the given description is valid if (description.empty() || !arm::pipe::IsValidSwTraceString(description)) { - throw InvalidArgumentException("Trying to register a counter with an invalid description"); + throw arm::pipe::InvalidArgumentException("Trying to register a counter with an invalid description"); } // Check that the given units are valid if (units.has_value() && !arm::pipe::IsValidSwTraceString(units.value())) { - throw InvalidArgumentException("Trying to register a counter with a invalid units"); + throw arm::pipe::InvalidArgumentException("Trying to register a counter with a invalid units"); } // Check that the given parent category is registered auto categoryIt = FindCategory(parentCategoryName); if (categoryIt == m_Categories.end()) { - throw InvalidArgumentException( - fmt::format("Trying to connect a counter to a category that is not registered (name: \"{}\")", - parentCategoryName)); + throw arm::pipe::InvalidArgumentException( + fmt::format("Trying to connect a counter to a category that is not registered (name: \"{}\")", + parentCategoryName)); } // Get the parent category @@ -258,11 +259,11 @@ const Counter* CounterDirectory::RegisterCounter(const std::string& /*backendId* if (parentCategoryCounter->m_Name == name) { - throw InvalidArgumentException( - fmt::format("Trying to register a counter to category \"{}\" with a name that " - "is already used within that category (name: \"{}\")", - parentCategoryName, - name)); + throw arm::pipe::InvalidArgumentException( + fmt::format("Trying to register a counter to category \"{}\" with a name that " + "is already used within that category (name: \"{}\")", + parentCategoryName, + name)); } } @@ -524,9 +525,9 @@ uint16_t CounterDirectory::GetNumberOfCores(const armnn::Optional& num auto deviceIt = FindDevice(deviceUid); if (deviceIt == m_Devices.end()) { - throw InvalidArgumentException( - fmt::format("Trying to connect a counter to a device that is not registered (device UID {})", - deviceUid)); + throw arm::pipe::InvalidArgumentException( + fmt::format("Trying to connect a counter to a device that is not registered (device UID {})", + deviceUid)); } // Get the associated device diff --git a/src/profiling/CounterIdMap.cpp b/src/profiling/CounterIdMap.cpp index bff8e0660e..80b63a36eb 100644 --- a/src/profiling/CounterIdMap.cpp +++ b/src/profiling/CounterIdMap.cpp @@ -3,7 +3,9 @@ // SPDX-License-Identifier: MIT // #include "CounterIdMap.hpp" -#include + +#include + #include namespace arm @@ -34,7 +36,7 @@ uint16_t CounterIdMap::GetGlobalId(uint16_t backendCounterId, const std::string& { std::stringstream ss; ss << "No Backend Counter [" << backendIdPair.second << ":" << backendIdPair.first << "] registered"; - throw armnn::Exception(ss.str()); + throw arm::pipe::ProfilingException(ss.str()); } return it->second; } @@ -46,7 +48,7 @@ const std::pair& CounterIdMap::GetBackendId(uint16_t glob { std::stringstream ss; ss << "No Global Counter ID [" << globalCounterId << "] registered"; - throw armnn::Exception(ss.str()); + throw arm::pipe::ProfilingException(ss.str()); } return it->second; } diff --git a/src/profiling/DeactivateTimelineReportingCommandHandler.cpp b/src/profiling/DeactivateTimelineReportingCommandHandler.cpp index d9aa7fda45..6c6a0451db 100644 --- a/src/profiling/DeactivateTimelineReportingCommandHandler.cpp +++ b/src/profiling/DeactivateTimelineReportingCommandHandler.cpp @@ -5,7 +5,8 @@ #include "DeactivateTimelineReportingCommandHandler.hpp" -#include +#include + #include @@ -24,15 +25,16 @@ void DeactivateTimelineReportingCommandHandler::operator()(const arm::pipe::Pack case ProfilingState::Uninitialised: case ProfilingState::NotConnected: case ProfilingState::WaitingForAck: - throw armnn::RuntimeException(fmt::format( - "Deactivate Timeline Reporting Command Handler invoked while in a wrong state: {}", - GetProfilingStateName(currentState))); + throw arm::pipe::ProfilingException(fmt::format( + "Deactivate Timeline Reporting Command Handler invoked while in a wrong state: {}", + GetProfilingStateName(currentState))); case ProfilingState::Active: if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 7u)) { - throw armnn::Exception(std::string("Expected Packet family = 0, id = 7 but received family =") - + std::to_string(packet.GetPacketFamily()) - +" id = " + std::to_string(packet.GetPacketId())); + throw arm::pipe::ProfilingException(std::string( + "Expected Packet family = 0, id = 7 but received family =") + + std::to_string(packet.GetPacketFamily()) + + " id = " + std::to_string(packet.GetPacketId())); } m_TimelineReporting.store(false); @@ -42,12 +44,11 @@ void DeactivateTimelineReportingCommandHandler::operator()(const arm::pipe::Pack break; default: - throw armnn::RuntimeException(fmt::format("Unknown profiling service state: {}", - static_cast(currentState))); + throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", + static_cast(currentState))); } } } // namespace pipe } // namespace arm - diff --git a/src/profiling/FileOnlyProfilingConnection.cpp b/src/profiling/FileOnlyProfilingConnection.cpp index ee9b8b1701..23bb4857a6 100644 --- a/src/profiling/FileOnlyProfilingConnection.cpp +++ b/src/profiling/FileOnlyProfilingConnection.cpp @@ -5,7 +5,6 @@ #include "FileOnlyProfilingConnection.hpp" -#include #include #include #include @@ -145,7 +144,7 @@ arm::pipe::Packet FileOnlyProfilingConnection::ReadPacket(uint32_t timeout) void FileOnlyProfilingConnection::Fail(const std::string& errorMessage) { Close(); - throw armnn::RuntimeException(errorMessage); + throw arm::pipe::ProfilingException(errorMessage); } /// Adds a local packet handler to the FileOnlyProfilingConnection. Invoking this will start diff --git a/src/profiling/PacketBuffer.cpp b/src/profiling/PacketBuffer.cpp index fa3e9582f4..3b5fd3570b 100644 --- a/src/profiling/PacketBuffer.cpp +++ b/src/profiling/PacketBuffer.cpp @@ -5,7 +5,7 @@ #include "PacketBuffer.hpp" -#include +#include namespace arm { @@ -39,8 +39,8 @@ void PacketBuffer::Commit(unsigned int size) { if (size > m_MaxSize) { - throw armnn::RuntimeException("Cannot commit [" + std::to_string(size) + - "] bytes which is more than the maximum size of the buffer [" + std::to_string(m_MaxSize) + "]"); + throw arm::pipe::ProfilingException("Cannot commit [" + std::to_string(size) + + "] bytes which is more than the maximum size of the buffer [" + std::to_string(m_MaxSize) + "]"); } m_Size = size; } diff --git a/src/profiling/PerJobCounterSelectionCommandHandler.cpp b/src/profiling/PerJobCounterSelectionCommandHandler.cpp index c90b6c837c..2d2d2bd80d 100644 --- a/src/profiling/PerJobCounterSelectionCommandHandler.cpp +++ b/src/profiling/PerJobCounterSelectionCommandHandler.cpp @@ -4,7 +4,8 @@ // #include "PerJobCounterSelectionCommandHandler.hpp" -#include + +#include #include @@ -22,25 +23,25 @@ void PerJobCounterSelectionCommandHandler::operator()(const arm::pipe::Packet& p case ProfilingState::Uninitialised: case ProfilingState::NotConnected: case ProfilingState::WaitingForAck: - throw armnn::RuntimeException(fmt::format( + throw arm::pipe::ProfilingException(fmt::format( "Per-Job Counter Selection Command Handler invoked while in an incorrect state: {}", GetProfilingStateName(currentState))); case ProfilingState::Active: // Process the packet if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 5u)) { - throw armnn::InvalidArgumentException(fmt::format("Expected Packet family = 0, id = 5 but " - "received family = {}, id = {}", - packet.GetPacketFamily(), - packet.GetPacketId())); + throw arm::pipe::InvalidArgumentException(fmt::format("Expected Packet family = 0, id = 5 but " + "received family = {}, id = {}", + packet.GetPacketFamily(), + packet.GetPacketId())); } // Silently drop the packet break; default: - throw armnn::RuntimeException(fmt::format("Unknown profiling service state: {}", - static_cast(currentState))); + throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", + static_cast(currentState))); } } diff --git a/src/profiling/PeriodicCounterCapture.cpp b/src/profiling/PeriodicCounterCapture.cpp index dd6d394d62..650043d7bd 100644 --- a/src/profiling/PeriodicCounterCapture.cpp +++ b/src/profiling/PeriodicCounterCapture.cpp @@ -105,7 +105,7 @@ void PeriodicCounterCapture::Capture(IReadCounterValues& readCounterValues) { counterValue = readCounterValues.GetDeltaCounterValue(requestedId); } - catch (const armnn::Exception& e) + catch (const arm::pipe::ProfilingException& e) { // Report the error and continue ARMNN_LOG(warning) << "An error has occurred when getting a counter value: " @@ -136,4 +136,4 @@ void PeriodicCounterCapture::Capture(IReadCounterValues& readCounterValues) } // namespace pipe -} // namespace arm \ No newline at end of file +} // namespace arm diff --git a/src/profiling/PeriodicCounterSelectionCommandHandler.cpp b/src/profiling/PeriodicCounterSelectionCommandHandler.cpp index 49928bf222..014500cc45 100644 --- a/src/profiling/PeriodicCounterSelectionCommandHandler.cpp +++ b/src/profiling/PeriodicCounterSelectionCommandHandler.cpp @@ -65,18 +65,18 @@ void PeriodicCounterSelectionCommandHandler::operator()(const arm::pipe::Packet& case ProfilingState::Uninitialised: case ProfilingState::NotConnected: case ProfilingState::WaitingForAck: - throw armnn::RuntimeException(fmt::format("Periodic Counter Selection Command Handler invoked while in " - "an wrong state: {}", - GetProfilingStateName(currentState))); + throw arm::pipe::ProfilingException(fmt::format("Periodic Counter Selection Command Handler invoked while in " + "an wrong state: {}", + GetProfilingStateName(currentState))); case ProfilingState::Active: { // Process the packet if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 4u)) { - throw armnn::InvalidArgumentException(fmt::format("Expected Packet family = 0, id = 4 but " - "received family = {}, id = {}", - packet.GetPacketFamily(), - packet.GetPacketId())); + throw arm::pipe::InvalidArgumentException(fmt::format("Expected Packet family = 0, id = 4 but " + "received family = {}, id = {}", + packet.GetPacketFamily(), + packet.GetPacketId())); } // Parse the packet to get the capture period and counter UIDs @@ -161,8 +161,8 @@ void PeriodicCounterSelectionCommandHandler::operator()(const arm::pipe::Packet& break; } default: - throw armnn::RuntimeException(fmt::format("Unknown profiling service state: {}", - static_cast(currentState))); + throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", + static_cast(currentState))); } } diff --git a/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp b/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp index fff26d435b..a0c5bc29dd 100644 --- a/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp +++ b/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp @@ -5,8 +5,8 @@ #include "ProfilingConnectionDumpToFileDecorator.hpp" -#include #include +#include #include @@ -26,7 +26,7 @@ ProfilingConnectionDumpToFileDecorator::ProfilingConnectionDumpToFileDecorator( { if (!m_Connection) { - throw InvalidArgumentException("Connection cannot be nullptr"); + throw arm::pipe::InvalidArgumentException("Connection cannot be nullptr"); } } @@ -154,7 +154,7 @@ bool ProfilingConnectionDumpToFileDecorator::DumpOutgoingToFile(const unsigned c void ProfilingConnectionDumpToFileDecorator::Fail(const std::string& errorMessage) { Close(); - throw armnn::RuntimeException(errorMessage); + throw arm::pipe::ProfilingException(errorMessage); } } // namespace pipe diff --git a/src/profiling/ProfilingConnectionFactory.cpp b/src/profiling/ProfilingConnectionFactory.cpp index 93ecff2e99..0b34a02ae2 100644 --- a/src/profiling/ProfilingConnectionFactory.cpp +++ b/src/profiling/ProfilingConnectionFactory.cpp @@ -21,7 +21,7 @@ std::unique_ptr ProfilingConnectionFactory::GetProfilingCo // Before proceed to create the IProfilingConnection, check if the file format is supported if (!(options.m_FileFormat == "binary")) { - throw armnn::UnimplementedException("Unsupported profiling file format, only binary is supported"); + throw arm::pipe::UnimplementedException("Unsupported profiling file format, only binary is supported"); } // We can create 3 different types of IProfilingConnection. diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp index 97db6e9a04..f187b398a1 100644 --- a/src/profiling/ProfilingService.cpp +++ b/src/profiling/ProfilingService.cpp @@ -129,7 +129,7 @@ void ProfilingService::Update() ARMNN_ASSERT(m_ProfilingConnectionFactory); m_ProfilingConnection = m_ProfilingConnectionFactory->GetProfilingConnection(m_Options); } - catch (const armnn::Exception& e) + catch (const arm::pipe::ProfilingException& e) { ARMNN_LOG(warning) << "An error has occurred when creating the profiling connection: " << e.what(); @@ -167,8 +167,8 @@ void ProfilingService::Update() break; default: - throw armnn::RuntimeException(fmt::format("Unknown profiling service state: {}", - static_cast(currentState))); + throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", + static_cast(currentState))); } } @@ -187,8 +187,8 @@ void ProfilingService::Disconnect() break; default: - throw armnn::RuntimeException(fmt::format("Unknown profiling service state: {}", - static_cast(currentState))); + throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", + static_cast(currentState))); } } @@ -381,7 +381,7 @@ inline void ProfilingService::CheckCounterUid(uint16_t counterUid) const { if (!IsCounterRegistered(counterUid)) { - throw InvalidArgumentException(fmt::format("Counter UID {} is not registered", counterUid)); + throw arm::pipe::InvalidArgumentException(fmt::format("Counter UID {} is not registered", counterUid)); } } diff --git a/src/profiling/ProfilingStateMachine.cpp b/src/profiling/ProfilingStateMachine.cpp index a53b978b63..e002c052b9 100644 --- a/src/profiling/ProfilingStateMachine.cpp +++ b/src/profiling/ProfilingStateMachine.cpp @@ -5,7 +5,7 @@ #include "ProfilingStateMachine.hpp" -#include +#include #include @@ -23,7 +23,7 @@ void ThrowStateTransitionException(ProfilingState expectedState, ProfilingState std::stringstream ss; ss << "Cannot transition from state [" << GetProfilingStateName(expectedState) << "] " << "to state [" << GetProfilingStateName(newState) << "]"; - throw armnn::RuntimeException(ss.str()); + throw arm::pipe::ProfilingException(ss.str()); } } // Anonymous namespace diff --git a/src/profiling/ProfilingUtils.cpp b/src/profiling/ProfilingUtils.cpp index 36578684ca..d827500a3c 100644 --- a/src/profiling/ProfilingUtils.cpp +++ b/src/profiling/ProfilingUtils.cpp @@ -39,7 +39,7 @@ void ThrowIfCantGenerateNextUid(uint16_t uid, uint16_t cores = 0) // running multiple parallel workloads and will not provide multiple streams of data for each event) if (uid == std::numeric_limits::max()) { - throw armnn::RuntimeException("Generating the next UID for profiling would result in an overflow"); + throw arm::pipe::ProfilingException("Generating the next UID for profiling would result in an overflow"); } break; default: // cores > 1 @@ -47,7 +47,7 @@ void ThrowIfCantGenerateNextUid(uint16_t uid, uint16_t cores = 0) // allowed value for a counter UID is consequently: uint16_t_max - cores + 1 if (uid >= std::numeric_limits::max() - cores + 1) { - throw armnn::RuntimeException("Generating the next UID for profiling would result in an overflow"); + throw arm::pipe::ProfilingException("Generating the next UID for profiling would result in an overflow"); } break; } @@ -419,7 +419,7 @@ TimelinePacketStatus WriteTimelineRelationshipBinary(ProfilingRelationshipType r relationshipTypeUint = 3; break; default: - throw InvalidArgumentException("Unknown relationship type given."); + throw arm::pipe::InvalidArgumentException("Unknown relationship type given."); } // Write the timeline binary payload to the buffer diff --git a/src/profiling/ProfilingUtils.hpp b/src/profiling/ProfilingUtils.hpp index e37e109094..893f6abf6c 100644 --- a/src/profiling/ProfilingUtils.hpp +++ b/src/profiling/ProfilingUtils.hpp @@ -5,7 +5,8 @@ #pragma once -#include +#include + #include #include @@ -141,11 +142,6 @@ std::string CentreAlignFormatting(const std::string& stringToPass, const int spa void PrintCounterDirectory(ICounterDirectory& counterDirectory); -class BufferExhaustion : public armnn::Exception -{ - using Exception::Exception; -}; - uint64_t GetTimestamp(); arm::pipe::Packet ReceivePacket(const unsigned char* buffer, uint32_t length); diff --git a/src/profiling/RequestCounterDirectoryCommandHandler.cpp b/src/profiling/RequestCounterDirectoryCommandHandler.cpp index 601f8541ff..cf07c45030 100644 --- a/src/profiling/RequestCounterDirectoryCommandHandler.cpp +++ b/src/profiling/RequestCounterDirectoryCommandHandler.cpp @@ -21,17 +21,17 @@ void RequestCounterDirectoryCommandHandler::operator()(const arm::pipe::Packet& case ProfilingState::Uninitialised: case ProfilingState::NotConnected: case ProfilingState::WaitingForAck: - throw armnn::RuntimeException(fmt::format("Request Counter Directory Comand Handler invoked while in an " - "wrong state: {}", - GetProfilingStateName(currentState))); + throw arm::pipe::ProfilingException(fmt::format("Request Counter Directory Comand Handler invoked while in an " + "wrong state: {}", + GetProfilingStateName(currentState))); case ProfilingState::Active: // Process the packet if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 3u)) { - throw armnn::InvalidArgumentException(fmt::format("Expected Packet family = 0, id = 3 but " - "received family = {}, id = {}", - packet.GetPacketFamily(), - packet.GetPacketId())); + throw arm::pipe::InvalidArgumentException(fmt::format("Expected Packet family = 0, id = 3 but " + "received family = {}, id = {}", + packet.GetPacketFamily(), + packet.GetPacketId())); } // Send all the packet required for the handshake with the external profiling service @@ -40,8 +40,8 @@ void RequestCounterDirectoryCommandHandler::operator()(const arm::pipe::Packet& break; default: - throw armnn::RuntimeException(fmt::format("Unknown profiling service state: {}", - static_cast(currentState))); + throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", + static_cast(currentState))); } } diff --git a/src/profiling/SendCounterPacket.cpp b/src/profiling/SendCounterPacket.cpp index 38417e8ecd..c91a02acce 100644 --- a/src/profiling/SendCounterPacket.cpp +++ b/src/profiling/SendCounterPacket.cpp @@ -4,15 +4,17 @@ // #include "SendCounterPacket.hpp" + +#include #include +#include +#include -#include #include #include + #include #include -#include -#include #include @@ -88,7 +90,7 @@ void SendCounterPacket::SendStreamMetaDataPacket() if (writeBuffer == nullptr || reserved < totalSize) { - CancelOperationAndThrow( + CancelOperationAndThrow( writeBuffer, fmt::format("No space left in buffer. Unable to reserve ({}) bytes.", totalSize)); } @@ -164,7 +166,7 @@ void SendCounterPacket::SendStreamMetaDataPacket() } catch(...) { - CancelOperationAndThrow(writeBuffer, "Error processing packet."); + CancelOperationAndThrow(writeBuffer, "Error processing packet."); } m_BufferManager.Commit(writeBuffer, totalSize, false); @@ -584,7 +586,7 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun std::string errorMessage; if (!CreateDeviceRecord(device, deviceRecord, errorMessage)) { - CancelOperationAndThrow(errorMessage); + CancelOperationAndThrow(errorMessage); } // Update the total size in words of the device records @@ -619,7 +621,7 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun std::string errorMessage; if (!CreateCounterSetRecord(counterSet, counterSetRecord, errorMessage)) { - CancelOperationAndThrow(errorMessage); + CancelOperationAndThrow(errorMessage); } // Update the total size in words of the counter set records @@ -654,7 +656,7 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun std::string errorMessage; if (!CreateCategoryRecord(category, counterDirectory.GetCounters(), categoryRecord, errorMessage)) { - CancelOperationAndThrow(errorMessage); + CancelOperationAndThrow(errorMessage); } // Update the total size in words of the category records @@ -807,7 +809,7 @@ void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& coun if (writeBuffer == nullptr || reserved < totalSize) { - CancelOperationAndThrow( + CancelOperationAndThrow( writeBuffer, fmt::format("No space left in buffer. Unable to reserve ({}) bytes.", totalSize)); } @@ -844,7 +846,7 @@ void SendCounterPacket::SendPeriodicCounterCapturePacket(uint64_t timestamp, con if (writeBuffer == nullptr || reserved < totalSize) { - CancelOperationAndThrow( + CancelOperationAndThrow( writeBuffer, fmt::format("No space left in buffer. Unable to reserve ({}) bytes.", totalSize)); } @@ -893,7 +895,7 @@ void SendCounterPacket::SendPeriodicCounterSelectionPacket(uint32_t capturePerio if (writeBuffer == nullptr || reserved < totalSize) { - CancelOperationAndThrow( + CancelOperationAndThrow( writeBuffer, fmt::format("No space left in buffer. Unable to reserve ({}) bytes.", totalSize)); } diff --git a/src/profiling/SendCounterPacket.hpp b/src/profiling/SendCounterPacket.hpp index db893c026a..f8fd757944 100644 --- a/src/profiling/SendCounterPacket.hpp +++ b/src/profiling/SendCounterPacket.hpp @@ -51,7 +51,7 @@ private: template void CancelOperationAndThrow(IPacketBufferPtr& writerBuffer, const std::string& errorMessage) { - if (std::is_same::value) + if (std::is_same::value) { m_BufferManager.FlushReadList(); } diff --git a/src/profiling/SendThread.cpp b/src/profiling/SendThread.cpp index 41385c5cc8..e932eba3e9 100644 --- a/src/profiling/SendThread.cpp +++ b/src/profiling/SendThread.cpp @@ -6,10 +6,11 @@ #include "SendThread.hpp" #include "ProfilingUtils.hpp" -#include #include #include +#include + #include #include @@ -128,8 +129,8 @@ void SendThread::Send(IProfilingConnection& profilingConnection) // An exception should be thrown here, save it to be rethrown later from the main thread so that // it can be caught by the consumer m_SendThreadException = - std::make_exception_ptr(armnn::RuntimeException("The send thread should not be running with the " - "profiling service not yet initialized or connected")); + std::make_exception_ptr(arm::pipe::ProfilingException( + "The send thread should not be running with the profiling service not yet initialized or connected")); return; case ProfilingState::WaitingForAck: diff --git a/src/profiling/SendTimelinePacket.cpp b/src/profiling/SendTimelinePacket.cpp index e44e5aa37c..62d1530490 100644 --- a/src/profiling/SendTimelinePacket.cpp +++ b/src/profiling/SendTimelinePacket.cpp @@ -66,11 +66,11 @@ void SendTimelinePacket::ReserveBuffer() // Check if there is enough space in the buffer if (m_WriteBuffer == nullptr) { - throw BufferExhaustion("No free buffers left", CHECK_LOCATION()); + throw arm::pipe::BufferExhaustion("No free buffers left", LOCATION()); } if (reserved < m_Offset) { - throw BufferExhaustion("Reserved space too small for use", CHECK_LOCATION()); + throw arm::pipe::BufferExhaustion("Reserved space too small for use", LOCATION()); } if (m_DirectoryPackage) @@ -144,7 +144,7 @@ void SendTimelinePacket::SendTimelineMessageDirectoryPackage() numberOfBytesWritten); if (result != TimelinePacketStatus::Ok) { - throw armnn::RuntimeException("Error processing TimelineMessageDirectoryPackage", CHECK_LOCATION()); + throw arm::pipe::ProfilingException("Error processing TimelineMessageDirectoryPackage", LOCATION()); } // Commit the message @@ -154,7 +154,7 @@ void SendTimelinePacket::SendTimelineMessageDirectoryPackage() } catch (...) { - throw armnn::RuntimeException("Error processing TimelineMessageDirectoryPackage", CHECK_LOCATION()); + throw arm::pipe::ProfilingException("Error processing TimelineMessageDirectoryPackage", LOCATION()); } } diff --git a/src/profiling/SendTimelinePacket.hpp b/src/profiling/SendTimelinePacket.hpp index f915dafea7..fe8c5d45e2 100644 --- a/src/profiling/SendTimelinePacket.hpp +++ b/src/profiling/SendTimelinePacket.hpp @@ -97,8 +97,8 @@ void SendTimelinePacket::ForwardWriteBinaryFunction(Func& func, Params&& ... par continue; case TimelinePacketStatus::Error: - throw armnn::RuntimeException("Error processing while sending TimelineBinaryPacket", CHECK_LOCATION - ()); + throw arm::pipe::ProfilingException("Error processing while sending TimelineBinaryPacket", + LOCATION()); default: m_Offset += numberOfBytesWritten; @@ -107,23 +107,19 @@ void SendTimelinePacket::ForwardWriteBinaryFunction(Func& func, Params&& ... par } } } - catch (const armnn::RuntimeException& ex) - { - // don't swallow in the catch all block - throw ex; - } - catch (const BufferExhaustion& ex) + catch (const arm::pipe::BufferExhaustion& ex) { // ditto throw ex; } - catch (const armnn::Exception& ex) + catch (const arm::pipe::ProfilingException& ex) { + // don't swallow in the catch all block throw ex; } catch ( ... ) { - throw armnn::RuntimeException("Unknown Exception thrown while sending TimelineBinaryPacket", CHECK_LOCATION()); + throw arm::pipe::ProfilingException("Unknown Exception thrown while sending TimelineBinaryPacket", LOCATION()); } } diff --git a/src/profiling/TimelineUtilityMethods.cpp b/src/profiling/TimelineUtilityMethods.cpp index fea8ed7ae0..1bfbc96df4 100644 --- a/src/profiling/TimelineUtilityMethods.cpp +++ b/src/profiling/TimelineUtilityMethods.cpp @@ -104,13 +104,13 @@ ProfilingDynamicGuid TimelineUtilityMethods::CreateNamedTypedEntity(const std::s // Check that the entity name is valid if (name.empty()) { - throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); + throw arm::pipe::InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); } // Check that the entity type is valid if (type.empty()) { - throw InvalidArgumentException("Invalid entity type, the entity type cannot be empty"); + throw arm::pipe::InvalidArgumentException("Invalid entity type, the entity type cannot be empty"); } // Generate dynamic GUID of the entity @@ -128,13 +128,13 @@ void TimelineUtilityMethods::CreateNamedTypedEntity(ProfilingGuid entityGuid, // Check that the entity name is valid if (name.empty()) { - throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); + throw arm::pipe::InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); } // Check that the entity type is valid if (type.empty()) { - throw InvalidArgumentException("Invalid entity type, the entity type cannot be empty"); + throw arm::pipe::InvalidArgumentException("Invalid entity type, the entity type cannot be empty"); } // Send Entity Binary Packet of the entity to the external profiling service @@ -154,7 +154,7 @@ void TimelineUtilityMethods::CreateNamedTypedEntity(ProfilingGuid entityGuid, // Check that the entity name is valid if (name.empty()) { - throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); + throw arm::pipe::InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); } // Send Entity Binary Packet of the entity to the external profiling service @@ -173,7 +173,7 @@ ProfilingStaticGuid TimelineUtilityMethods::DeclareLabel(const std::string& labe if (labelName.empty()) { // The label name is invalid - throw InvalidArgumentException("Invalid label name, the label name cannot be empty"); + throw arm::pipe::InvalidArgumentException("Invalid label name, the label name cannot be empty"); } // Generate a static GUID for the given label name @@ -193,7 +193,7 @@ void TimelineUtilityMethods::MarkEntityWithLabel(ProfilingGuid entityGuid, if (labelName.empty()) { // The label name is invalid - throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); + throw arm::pipe::InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); } // Declare a label with the label's name, this call throws in case of error @@ -242,14 +242,14 @@ ProfilingDynamicGuid TimelineUtilityMethods::CreateNamedTypedChildEntity(Profili if (entityName.empty()) { // The entity name is invalid - throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); + throw arm::pipe::InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); } // Check that the entity type is valid if (entityType.empty()) { // The entity type is invalid - throw InvalidArgumentException("Invalid entity type, the entity type cannot be empty"); + throw arm::pipe::InvalidArgumentException("Invalid entity type, the entity type cannot be empty"); } // Create a named type entity from the given name and type, this call throws in case of error @@ -277,14 +277,14 @@ void TimelineUtilityMethods::CreateNamedTypedChildEntity(ProfilingGuid childEnti if (entityName.empty()) { // The entity name is invalid - throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); + throw arm::pipe::InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); } // Check that the entity type is valid if (entityType.empty()) { // The entity type is invalid - throw InvalidArgumentException("Invalid entity type, the entity type cannot be empty"); + throw arm::pipe::InvalidArgumentException("Invalid entity type, the entity type cannot be empty"); } // Create a named type entity from the given guid, name and type, this call throws in case of error @@ -310,7 +310,7 @@ void TimelineUtilityMethods::CreateNamedTypedChildEntity(ProfilingGuid childEnti if (entityName.empty()) { // The entity name is invalid - throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); + throw arm::pipe::InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); } // Create a named type entity from the given guid, name and type, this call throws in case of error diff --git a/src/profiling/test/BufferTests.cpp b/src/profiling/test/BufferTests.cpp index c4714d6ad4..943cfd5f31 100644 --- a/src/profiling/test/BufferTests.cpp +++ b/src/profiling/test/BufferTests.cpp @@ -9,8 +9,6 @@ #include -#include - #include using namespace arm::pipe; @@ -113,7 +111,7 @@ TEST_CASE("PacketBufferCommitErrorTest") IPacketBufferPtr packetBuffer = std::make_unique(8); // Cannot commit data bigger than the max size of the buffer - CHECK_THROWS_AS(packetBuffer->Commit(16);, armnn::RuntimeException); + CHECK_THROWS_AS(packetBuffer->Commit(16);, arm::pipe::ProfilingException); } TEST_CASE("BufferReserveTest") @@ -384,7 +382,7 @@ TEST_CASE("ReadSwTraceMessageExceptionTest0") unsigned int uint32_t_size = sizeof(uint32_t); unsigned int offset = uint32_t_size; CHECK_THROWS_AS(ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()), - ProfilingException); + arm::pipe::ProfilingException); } @@ -406,7 +404,7 @@ TEST_CASE("ReadSwTraceMessageExceptionTest1") unsigned int uint32_t_size = sizeof(uint32_t); unsigned int offset = uint32_t_size; CHECK_THROWS_AS(ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()), - ProfilingException); + arm::pipe::ProfilingException); } diff --git a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp index 3c4800a361..fb8c97265b 100644 --- a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp +++ b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp @@ -82,7 +82,7 @@ TEST_CASE("DumpIncomingInvalidFile") options.m_IncomingCaptureFile = "/"; options.m_OutgoingCaptureFile = ""; ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), options, false); - CHECK_THROWS_AS(decorator.ReadPacket(0), armnn::RuntimeException); + CHECK_THROWS_AS(decorator.ReadPacket(0), arm::pipe::ProfilingException); } TEST_CASE("DumpIncomingInvalidFileIgnoreErrors") @@ -126,7 +126,7 @@ TEST_CASE("DumpOutgoingInvalidFile") options.m_IncomingCaptureFile = ""; options.m_OutgoingCaptureFile = "/"; ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), options, false); - CHECK_THROWS_AS(decorator.WritePacket(g_DataPtr, g_DataLength), armnn::RuntimeException); + CHECK_THROWS_AS(decorator.WritePacket(g_DataPtr, g_DataLength), arm::pipe::ProfilingException); } TEST_CASE("DumpOutgoingInvalidFileIgnoreErrors") diff --git a/src/profiling/test/ProfilingMocks.hpp b/src/profiling/test/ProfilingMocks.hpp index ca11ae4348..b9ba9315ee 100644 --- a/src/profiling/test/ProfilingMocks.hpp +++ b/src/profiling/test/ProfilingMocks.hpp @@ -13,13 +13,13 @@ #include #include -#include #include #include #include #include #include +#include #include #include @@ -294,8 +294,8 @@ public: reservedSize = 0; if (requestedSize > m_MaxBufferSize) { - throw armnn::InvalidArgumentException("The maximum buffer size that can be requested is [" + - std::to_string(m_MaxBufferSize) + "] bytes"); + throw arm::pipe::InvalidArgumentException("The maximum buffer size that can be requested is [" + + std::to_string(m_MaxBufferSize) + "] bytes"); } reservedSize = requestedSize; return std::make_unique(requestedSize); diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index 128e1f15d2..0389377fe5 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -512,29 +512,29 @@ TEST_CASE("CheckProfilingStateMachine") CHECK(profilingState8.GetCurrentState() == ProfilingState::Active); ProfilingStateMachine profilingState9(ProfilingState::Uninitialised); - CHECK_THROWS_AS(profilingState9.TransitionToState(ProfilingState::WaitingForAck), armnn::Exception); + CHECK_THROWS_AS(profilingState9.TransitionToState(ProfilingState::WaitingForAck), arm::pipe::ProfilingException); ProfilingStateMachine profilingState10(ProfilingState::Uninitialised); - CHECK_THROWS_AS(profilingState10.TransitionToState(ProfilingState::Active), armnn::Exception); + CHECK_THROWS_AS(profilingState10.TransitionToState(ProfilingState::Active), arm::pipe::ProfilingException); ProfilingStateMachine profilingState11(ProfilingState::NotConnected); - CHECK_THROWS_AS(profilingState11.TransitionToState(ProfilingState::Uninitialised), armnn::Exception); + CHECK_THROWS_AS(profilingState11.TransitionToState(ProfilingState::Uninitialised), arm::pipe::ProfilingException); ProfilingStateMachine profilingState12(ProfilingState::NotConnected); - CHECK_THROWS_AS(profilingState12.TransitionToState(ProfilingState::Active), armnn::Exception); + CHECK_THROWS_AS(profilingState12.TransitionToState(ProfilingState::Active), arm::pipe::ProfilingException); ProfilingStateMachine profilingState13(ProfilingState::WaitingForAck); - CHECK_THROWS_AS(profilingState13.TransitionToState(ProfilingState::Uninitialised), armnn::Exception); + CHECK_THROWS_AS(profilingState13.TransitionToState(ProfilingState::Uninitialised), arm::pipe::ProfilingException); ProfilingStateMachine profilingState14(ProfilingState::WaitingForAck); profilingState14.TransitionToState(ProfilingState::NotConnected); CHECK(profilingState14.GetCurrentState() == ProfilingState::NotConnected); ProfilingStateMachine profilingState15(ProfilingState::Active); - CHECK_THROWS_AS(profilingState15.TransitionToState(ProfilingState::Uninitialised), armnn::Exception); + CHECK_THROWS_AS(profilingState15.TransitionToState(ProfilingState::Uninitialised), arm::pipe::ProfilingException); ProfilingStateMachine profilingState16(ProfilingState::Active); - CHECK_THROWS_AS(profilingState16.TransitionToState(ProfilingState::WaitingForAck), armnn::Exception); + CHECK_THROWS_AS(profilingState16.TransitionToState(ProfilingState::WaitingForAck), arm::pipe::ProfilingException); ProfilingStateMachine profilingState17(ProfilingState::Uninitialised); @@ -998,7 +998,8 @@ TEST_CASE("CheckCounterDirectoryRegisterDevice") // Register a device with the name of a device already registered const Device* deviceSameName = nullptr; - CHECK_THROWS_AS(deviceSameName = counterDirectory.RegisterDevice(deviceName), arm::pipe::InvalidArgumentException); + CHECK_THROWS_AS(deviceSameName = counterDirectory.RegisterDevice(deviceName), + arm::pipe::InvalidArgumentException); CHECK(counterDirectory.GetDeviceCount() == 1); CHECK(!deviceSameName); @@ -1831,11 +1832,11 @@ TEST_CASE("CounterSelectionCommandHandlerParseData") readCounterValues, sendCounterPacket, profilingStateMachine); profilingStateMachine.TransitionToState(ProfilingState::Uninitialised); - CHECK_THROWS_AS(commandHandler(packetA), armnn::RuntimeException); + CHECK_THROWS_AS(commandHandler(packetA), arm::pipe::ProfilingException); profilingStateMachine.TransitionToState(ProfilingState::NotConnected); - CHECK_THROWS_AS(commandHandler(packetA), armnn::RuntimeException); + CHECK_THROWS_AS(commandHandler(packetA), arm::pipe::ProfilingException); profilingStateMachine.TransitionToState(ProfilingState::WaitingForAck); - CHECK_THROWS_AS(commandHandler(packetA), armnn::RuntimeException); + CHECK_THROWS_AS(commandHandler(packetA), arm::pipe::ProfilingException); profilingStateMachine.TransitionToState(ProfilingState::Active); CHECK_NOTHROW(commandHandler(packetA)); @@ -1959,15 +1960,18 @@ TEST_CASE("CheckTimelineActivationAndDeactivation") arm::pipe::Packet ActivateTimelineReportingPacket(packetHeader1); // Length == 0 CHECK_THROWS_AS( - activateTimelineReportingCommandHandler.operator()(ActivateTimelineReportingPacket), armnn::Exception); + activateTimelineReportingCommandHandler.operator()(ActivateTimelineReportingPacket), + arm::pipe::ProfilingException); stateMachine.TransitionToState(ProfilingState::NotConnected); CHECK_THROWS_AS( - activateTimelineReportingCommandHandler.operator()(ActivateTimelineReportingPacket), armnn::Exception); + activateTimelineReportingCommandHandler.operator()(ActivateTimelineReportingPacket), + arm::pipe::ProfilingException); stateMachine.TransitionToState(ProfilingState::WaitingForAck); CHECK_THROWS_AS( - activateTimelineReportingCommandHandler.operator()(ActivateTimelineReportingPacket), armnn::Exception); + activateTimelineReportingCommandHandler.operator()(ActivateTimelineReportingPacket), + arm::pipe::ProfilingException); stateMachine.TransitionToState(ProfilingState::Active); activateTimelineReportingCommandHandler.operator()(ActivateTimelineReportingPacket); @@ -1992,15 +1996,18 @@ TEST_CASE("CheckTimelineActivationAndDeactivation") stateMachine.Reset(); CHECK_THROWS_AS( - deactivateTimelineReportingCommandHandler.operator()(deactivateTimelineReportingPacket), armnn::Exception); + deactivateTimelineReportingCommandHandler.operator()(deactivateTimelineReportingPacket), + arm::pipe::ProfilingException); stateMachine.TransitionToState(ProfilingState::NotConnected); CHECK_THROWS_AS( - deactivateTimelineReportingCommandHandler.operator()(deactivateTimelineReportingPacket), armnn::Exception); + deactivateTimelineReportingCommandHandler.operator()(deactivateTimelineReportingPacket), + arm::pipe::ProfilingException); stateMachine.TransitionToState(ProfilingState::WaitingForAck); CHECK_THROWS_AS( - deactivateTimelineReportingCommandHandler.operator()(deactivateTimelineReportingPacket), armnn::Exception); + deactivateTimelineReportingCommandHandler.operator()(deactivateTimelineReportingPacket), + arm::pipe::ProfilingException); stateMachine.TransitionToState(ProfilingState::Active); deactivateTimelineReportingCommandHandler.operator()(deactivateTimelineReportingPacket); @@ -2076,12 +2083,12 @@ TEST_CASE("CheckConnectionAcknowledged") mockProfilingServiceStatus); // command handler received packet on ProfilingState::Uninitialised - CHECK_THROWS_AS(commandHandler(packetA), armnn::Exception); + CHECK_THROWS_AS(commandHandler(packetA), arm::pipe::ProfilingException); profilingState.TransitionToState(ProfilingState::NotConnected); CHECK(profilingState.GetCurrentState() == ProfilingState::NotConnected); // command handler received packet on ProfilingState::NotConnected - CHECK_THROWS_AS(commandHandler(packetA), armnn::Exception); + CHECK_THROWS_AS(commandHandler(packetA), arm::pipe::ProfilingException); profilingState.TransitionToState(ProfilingState::WaitingForAck); CHECK(profilingState.GetCurrentState() == ProfilingState::WaitingForAck); @@ -2106,7 +2113,7 @@ TEST_CASE("CheckConnectionAcknowledged") sendTimelinePacket, profilingState, mockProfilingServiceStatus); - CHECK_THROWS_AS(differentCommandHandler(packetB), armnn::Exception); + CHECK_THROWS_AS(differentCommandHandler(packetB), arm::pipe::ProfilingException); } TEST_CASE("CheckSocketConnectionException") @@ -2438,13 +2445,13 @@ TEST_CASE("RequestCounterDirectoryCommandHandlerTest1") arm::pipe::Packet wrongPacket(wrongHeader); profilingStateMachine.TransitionToState(ProfilingState::Uninitialised); - CHECK_THROWS_AS(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state + CHECK_THROWS_AS(commandHandler(wrongPacket), arm::pipe::ProfilingException); // Wrong profiling state profilingStateMachine.TransitionToState(ProfilingState::NotConnected); - CHECK_THROWS_AS(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state + CHECK_THROWS_AS(commandHandler(wrongPacket), arm::pipe::ProfilingException); // Wrong profiling state profilingStateMachine.TransitionToState(ProfilingState::WaitingForAck); - CHECK_THROWS_AS(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state + CHECK_THROWS_AS(commandHandler(wrongPacket), arm::pipe::ProfilingException); // Wrong profiling state profilingStateMachine.TransitionToState(ProfilingState::Active); - CHECK_THROWS_AS(commandHandler(wrongPacket), armnn::InvalidArgumentException); // Wrong packet + CHECK_THROWS_AS(commandHandler(wrongPacket), arm::pipe::InvalidArgumentException); // Wrong packet const uint32_t rightHeader = (packetId & 0x000003FF) << 16; @@ -2505,11 +2512,11 @@ TEST_CASE("RequestCounterDirectoryCommandHandlerTest2") "categoryA", 1, 1, 3.0f, "counterB", "descB"); profilingStateMachine.TransitionToState(ProfilingState::Uninitialised); - CHECK_THROWS_AS(commandHandler(packet), armnn::RuntimeException); // Wrong profiling state + CHECK_THROWS_AS(commandHandler(packet), arm::pipe::ProfilingException); // Wrong profiling state profilingStateMachine.TransitionToState(ProfilingState::NotConnected); - CHECK_THROWS_AS(commandHandler(packet), armnn::RuntimeException); // Wrong profiling state + CHECK_THROWS_AS(commandHandler(packet), arm::pipe::ProfilingException); // Wrong profiling state profilingStateMachine.TransitionToState(ProfilingState::WaitingForAck); - CHECK_THROWS_AS(commandHandler(packet), armnn::RuntimeException); // Wrong profiling state + CHECK_THROWS_AS(commandHandler(packet), arm::pipe::ProfilingException); // Wrong profiling state profilingStateMachine.TransitionToState(ProfilingState::Active); CHECK_NOTHROW(commandHandler(packet)); @@ -3409,8 +3416,8 @@ TEST_CASE("CheckProfilingServiceBadPeriodicCounterSelectionPacket") TEST_CASE("CheckCounterIdMap") { CounterIdMap counterIdMap; - CHECK_THROWS_AS(counterIdMap.GetBackendId(0), armnn::Exception); - CHECK_THROWS_AS(counterIdMap.GetGlobalId(0, armnn::profiling::BACKEND_ID), armnn::Exception); + CHECK_THROWS_AS(counterIdMap.GetBackendId(0), arm::pipe::ProfilingException); + CHECK_THROWS_AS(counterIdMap.GetGlobalId(0, armnn::profiling::BACKEND_ID), arm::pipe::ProfilingException); uint16_t globalCounterIds = 0; diff --git a/src/profiling/test/ProfilingTests.hpp b/src/profiling/test/ProfilingTests.hpp index e1590bd4d9..ed3e03db77 100644 --- a/src/profiling/test/ProfilingTests.hpp +++ b/src/profiling/test/ProfilingTests.hpp @@ -96,7 +96,7 @@ public: else { std::this_thread::sleep_for(std::chrono::milliseconds(timeout)); - throw armnn::TimeoutException("Simulate a timeout error\n"); + throw arm::pipe::TimeoutException("Simulate a timeout error\n"); } } @@ -117,7 +117,7 @@ public: { std::this_thread::sleep_for(std::chrono::milliseconds(timeout)); ++m_ReadRequests; - throw armnn::TimeoutException("Simulate a timeout error\n"); + throw arm::pipe::TimeoutException("Simulate a timeout error\n"); } return arm::pipe::Packet(65536); @@ -143,7 +143,7 @@ public: { armnn::IgnoreUnused(timeout); ++m_ReadRequests; - throw armnn::Exception("Simulate a non-timeout error"); + throw arm::pipe::ProfilingException("Simulate a non-timeout error"); } int ReadCalledCount() diff --git a/src/profiling/test/SendCounterPacketTests.cpp b/src/profiling/test/SendCounterPacketTests.cpp index 1380b42d37..cfcd64b98f 100644 --- a/src/profiling/test/SendCounterPacketTests.cpp +++ b/src/profiling/test/SendCounterPacketTests.cpp @@ -14,11 +14,11 @@ #include #include -#include #include #include #include +#include #include @@ -1673,7 +1673,7 @@ TEST_CASE("SendCounterDirectoryPacketTest3") // Buffer with enough space MockBufferManager mockBuffer(1024); SendCounterPacket sendCounterPacket(mockBuffer); - CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), armnn::RuntimeException); + CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), arm::pipe::ProfilingException); } TEST_CASE("SendCounterDirectoryPacketTest4") @@ -1691,7 +1691,7 @@ TEST_CASE("SendCounterDirectoryPacketTest4") // Buffer with enough space MockBufferManager mockBuffer(1024); SendCounterPacket sendCounterPacket(mockBuffer); - CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), armnn::RuntimeException); + CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), arm::pipe::ProfilingException); } TEST_CASE("SendCounterDirectoryPacketTest5") @@ -1709,7 +1709,7 @@ TEST_CASE("SendCounterDirectoryPacketTest5") // Buffer with enough space MockBufferManager mockBuffer(1024); SendCounterPacket sendCounterPacket(mockBuffer); - CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), armnn::RuntimeException); + CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), arm::pipe::ProfilingException); } TEST_CASE("SendCounterDirectoryPacketTest6") @@ -1741,7 +1741,7 @@ TEST_CASE("SendCounterDirectoryPacketTest6") // Buffer with enough space MockBufferManager mockBuffer(1024); SendCounterPacket sendCounterPacket(mockBuffer); - CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), armnn::RuntimeException); + CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), arm::pipe::ProfilingException); } TEST_CASE("SendCounterDirectoryPacketTest7") @@ -1790,7 +1790,7 @@ TEST_CASE("SendCounterDirectoryPacketTest7") // Buffer with enough space MockBufferManager mockBuffer(1024); SendCounterPacket sendCounterPacket(mockBuffer); - CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), armnn::RuntimeException); + CHECK_THROWS_AS(sendCounterPacket.SendCounterDirectoryPacket(counterDirectory), arm::pipe::ProfilingException); } TEST_CASE("SendThreadTest0") @@ -2263,7 +2263,7 @@ TEST_CASE("SendThreadSendStreamMetadataPacket1") sendThread.Start(mockProfilingConnection); // The profiling state is set to "Uninitialized", so the send thread should throw an exception - CHECK_THROWS_AS(sendThread.Stop(), armnn::RuntimeException); + CHECK_THROWS_AS(sendThread.Stop(), arm::pipe::ProfilingException); } TEST_CASE("SendThreadSendStreamMetadataPacket2") @@ -2278,7 +2278,7 @@ TEST_CASE("SendThreadSendStreamMetadataPacket2") sendThread.Start(mockProfilingConnection); // The profiling state is set to "NotConnected", so the send thread should throw an exception - CHECK_THROWS_AS(sendThread.Stop(), armnn::RuntimeException); + CHECK_THROWS_AS(sendThread.Stop(), arm::pipe::ProfilingException); } TEST_CASE("SendThreadSendStreamMetadataPacket3") diff --git a/src/profiling/test/SendCounterPacketTests.hpp b/src/profiling/test/SendCounterPacketTests.hpp index 4dec67d335..bae08b231e 100644 --- a/src/profiling/test/SendCounterPacketTests.hpp +++ b/src/profiling/test/SendCounterPacketTests.hpp @@ -10,13 +10,13 @@ #include #include -#include #include #include #include #include #include + #include #include #include diff --git a/src/profiling/test/SendTimelinePacketTests.cpp b/src/profiling/test/SendTimelinePacketTests.cpp index 76fa9c1657..eb6a2627b4 100644 --- a/src/profiling/test/SendTimelinePacketTests.cpp +++ b/src/profiling/test/SendTimelinePacketTests.cpp @@ -399,7 +399,7 @@ TEST_CASE("SendTimelinePacketTests2") std::unique_ptr sendTimelinePacket = timelinePacketWriterFactory.GetSendTimelinePacket(); CHECK_THROWS_AS(sendTimelinePacket->SendTimelineMessageDirectoryPackage(), - armnn::RuntimeException); + arm::pipe::ProfilingException); } TEST_CASE("SendTimelinePacketTests3") diff --git a/src/profiling/test/TestTimelinePacketHandler.cpp b/src/profiling/test/TestTimelinePacketHandler.cpp index d38c1751cb..46f0549bba 100644 --- a/src/profiling/test/TestTimelinePacketHandler.cpp +++ b/src/profiling/test/TestTimelinePacketHandler.cpp @@ -39,7 +39,7 @@ void TestTimelinePacketHandler::HandlePacket(const arm::pipe::Packet& packet) { std::stringstream ss; ss << "Received a packet with unknown header [" << packet.GetHeader() << "]"; - throw armnn::Exception(ss.str()); + throw arm::pipe::ProfilingException(ss.str()); } } @@ -63,7 +63,7 @@ void TestTimelinePacketHandler::WaitOnInferenceCompletion(unsigned int timeout) std::chrono::duration elapsed = finish - start; std::stringstream ss; ss << "Timed out waiting on inference completion for " << elapsed.count() << " ms"; - throw armnn::TimeoutException(ss.str()); + throw arm::pipe::TimeoutException(ss.str()); } return; } @@ -138,4 +138,4 @@ arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateRelati } // namespace pipe -} // namespace arm \ No newline at end of file +} // namespace arm diff --git a/src/profiling/test/TimelineUtilityMethodsTests.cpp b/src/profiling/test/TimelineUtilityMethodsTests.cpp index 0833eb4376..422bc1389d 100644 --- a/src/profiling/test/TimelineUtilityMethodsTests.cpp +++ b/src/profiling/test/TimelineUtilityMethodsTests.cpp @@ -306,7 +306,7 @@ TEST_CASE("DeclareLabelTest") CHECK_THROWS_AS(timelineUtilityMethods.DeclareLabel(""), arm::pipe::InvalidArgumentException); // Try declaring an invalid (wrong SWTrace format) label - CHECK_THROWS_AS(timelineUtilityMethods.DeclareLabel("inv@lid lab€l"), RuntimeException); + CHECK_THROWS_AS(timelineUtilityMethods.DeclareLabel("inv@lid lab€l"), arm::pipe::ProfilingException); // Declare a valid label const std::string labelName = "valid label"; diff --git a/src/timelineDecoder/JSONTimelineDecoder.cpp b/src/timelineDecoder/JSONTimelineDecoder.cpp index 0eafe493aa..baf541b066 100644 --- a/src/timelineDecoder/JSONTimelineDecoder.cpp +++ b/src/timelineDecoder/JSONTimelineDecoder.cpp @@ -302,7 +302,8 @@ std::string JSONTimelineDecoder::GetWorkloadExecutionJSONString(const JSONTimeli { if(entity.childEntities.size() < 2) { - throw Exception("Workload Execution Entity Packet does not have the expected Event packets attached"); + throw arm::pipe::ProfilingException( + "Workload Execution Entity Packet does not have the expected Event packets attached"); } JSONEntity jsonEventOne = entity.childEntities[0]; JSONEntity jsonEventTwo = entity.childEntities[1]; @@ -395,4 +396,4 @@ std::string JSONTimelineDecoder::JSONEntity::GetType() } } -} \ No newline at end of file +} -- cgit v1.2.1