aboutsummaryrefslogtreecommitdiff
path: root/src/profiling
diff options
context:
space:
mode:
authorJim Flynn <jim.flynn@arm.com>2020-07-20 16:57:44 +0100
committerJim Flynn <jim.flynn@arm.com>2020-07-29 15:35:15 +0100
commitbbfe603e5ae42317a2b67d713d00882bea341c88 (patch)
tree8d8a78d6836384fb92fb9741c865443624dfec68 /src/profiling
parenta9c2ce123a6a5a68728d040a0323c482bbe46903 (diff)
downloadarmnn-bbfe603e5ae42317a2b67d713d00882bea341c88.tar.gz
IVGCVSW-5166 Pull out the common and server side code into standalone libraries
Change-Id: I180f84c493a9b2be4b93b25d312ebdd9e71b1735 Signed-off-by: Jim Flynn <jim.flynn@arm.com>
Diffstat (limited to 'src/profiling')
-rw-r--r--src/profiling/ActivateTimelineReportingCommandHandler.cpp4
-rw-r--r--src/profiling/ActivateTimelineReportingCommandHandler.hpp10
-rw-r--r--src/profiling/CommandHandler.cpp27
-rw-r--r--src/profiling/CommandHandler.hpp15
-rw-r--r--src/profiling/CommandHandlerFunctor.cpp31
-rw-r--r--src/profiling/CommandHandlerFunctor.hpp45
-rw-r--r--src/profiling/CommandHandlerKey.cpp77
-rw-r--r--src/profiling/CommandHandlerKey.hpp41
-rw-r--r--src/profiling/CommandHandlerRegistry.cpp63
-rw-r--r--src/profiling/CommandHandlerRegistry.hpp49
-rw-r--r--src/profiling/ConnectionAcknowledgedCommandHandler.cpp2
-rw-r--r--src/profiling/ConnectionAcknowledgedCommandHandler.hpp9
-rw-r--r--src/profiling/CounterDirectory.cpp19
-rw-r--r--src/profiling/CounterDirectory.hpp12
-rw-r--r--src/profiling/DeactivateTimelineReportingCommandHandler.cpp4
-rw-r--r--src/profiling/DeactivateTimelineReportingCommandHandler.hpp11
-rw-r--r--src/profiling/DirectoryCaptureCommandHandler.cpp7
-rw-r--r--src/profiling/DirectoryCaptureCommandHandler.hpp11
-rw-r--r--src/profiling/EncodeVersion.hpp83
-rw-r--r--src/profiling/FileOnlyProfilingConnection.cpp32
-rw-r--r--src/profiling/FileOnlyProfilingConnection.hpp19
-rw-r--r--src/profiling/IProfilingConnection.hpp5
-rw-r--r--src/profiling/PacketVersionResolver.cpp73
-rw-r--r--src/profiling/PacketVersionResolver.hpp50
-rw-r--r--src/profiling/PerJobCounterSelectionCommandHandler.cpp15
-rw-r--r--src/profiling/PerJobCounterSelectionCommandHandler.hpp11
-rw-r--r--src/profiling/PeriodicCounterSelectionCommandHandler.cpp6
-rw-r--r--src/profiling/PeriodicCounterSelectionCommandHandler.hpp14
-rw-r--r--src/profiling/ProfilingConnectionDumpToFileDecorator.cpp8
-rw-r--r--src/profiling/ProfilingConnectionDumpToFileDecorator.hpp6
-rw-r--r--src/profiling/ProfilingConnectionFactory.cpp2
-rw-r--r--src/profiling/ProfilingConnectionFactory.hpp2
-rw-r--r--src/profiling/ProfilingService.cpp2
-rw-r--r--src/profiling/ProfilingService.hpp34
-rw-r--r--src/profiling/ProfilingUtils.cpp227
-rw-r--r--src/profiling/ProfilingUtils.hpp120
-rw-r--r--src/profiling/RequestCounterDirectoryCommandHandler.cpp2
-rw-r--r--src/profiling/RequestCounterDirectoryCommandHandler.hpp9
-rw-r--r--src/profiling/SendCounterPacket.cpp45
-rw-r--r--src/profiling/SendThread.cpp7
-rw-r--r--src/profiling/SocketProfilingConnection.cpp51
-rw-r--r--src/profiling/SocketProfilingConnection.hpp6
-rw-r--r--src/profiling/test/BufferTests.cpp10
-rw-r--r--src/profiling/test/PrintPacketHeaderHandler.cpp5
-rw-r--r--src/profiling/test/PrintPacketHeaderHandler.hpp7
-rw-r--r--src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp12
-rw-r--r--src/profiling/test/ProfilingMocks.hpp6
-rw-r--r--src/profiling/test/ProfilingTests.cpp361
-rw-r--r--src/profiling/test/ProfilingTests.hpp22
-rw-r--r--src/profiling/test/RequestCountersPacketHandler.cpp10
-rw-r--r--src/profiling/test/RequestCountersPacketHandler.hpp7
-rw-r--r--src/profiling/test/SendCounterPacketTests.cpp32
-rw-r--r--src/profiling/test/SendTimelinePacketTests.cpp28
-rw-r--r--src/profiling/test/TestTimelinePacketHandler.cpp35
-rw-r--r--src/profiling/test/TestTimelinePacketHandler.hpp21
-rw-r--r--src/profiling/test/TimelineModel.cpp54
-rw-r--r--src/profiling/test/TimelineModel.hpp34
-rw-r--r--src/profiling/test/TimelinePacketTests.cpp10
58 files changed, 590 insertions, 1330 deletions
diff --git a/src/profiling/ActivateTimelineReportingCommandHandler.cpp b/src/profiling/ActivateTimelineReportingCommandHandler.cpp
index d762efc277..614417c6de 100644
--- a/src/profiling/ActivateTimelineReportingCommandHandler.cpp
+++ b/src/profiling/ActivateTimelineReportingCommandHandler.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -15,7 +15,7 @@ namespace armnn
namespace profiling
{
-void ActivateTimelineReportingCommandHandler::operator()(const Packet& packet)
+void ActivateTimelineReportingCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ProfilingState currentState = m_StateMachine.GetCurrentState();
diff --git a/src/profiling/ActivateTimelineReportingCommandHandler.hpp b/src/profiling/ActivateTimelineReportingCommandHandler.hpp
index ff0e840170..a40115084b 100644
--- a/src/profiling/ActivateTimelineReportingCommandHandler.hpp
+++ b/src/profiling/ActivateTimelineReportingCommandHandler.hpp
@@ -1,11 +1,10 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include "CommandHandlerFunctor.hpp"
#include "ProfilingStateMachine.hpp"
#include "SendTimelinePacket.hpp"
#include "IReportStructure.hpp"
@@ -13,7 +12,8 @@
#include "armnn/Optional.hpp"
-#include <Packet.hpp>
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
namespace armnn
@@ -22,7 +22,7 @@ namespace armnn
namespace profiling
{
-class ActivateTimelineReportingCommandHandler : public CommandHandlerFunctor
+class ActivateTimelineReportingCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
ActivateTimelineReportingCommandHandler(uint32_t familyId,
@@ -41,7 +41,7 @@ public:
m_ReportStructure(reportStructure)
{}
- void operator()(const Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
private:
SendTimelinePacket& m_SendTimelinePacket;
diff --git a/src/profiling/CommandHandler.cpp b/src/profiling/CommandHandler.cpp
index cae7037327..9f536445e9 100644
--- a/src/profiling/CommandHandler.cpp
+++ b/src/profiling/CommandHandler.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -47,7 +47,7 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection)
{
try
{
- Packet packet = profilingConnection.ReadPacket(m_Timeout.load());
+ arm::pipe::Packet packet = profilingConnection.ReadPacket(m_Timeout.load());
if (packet.IsEmpty())
{
@@ -55,12 +55,12 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection)
continue;
}
- Version version = m_PacketVersionResolver.ResolvePacketVersion(packet.GetPacketFamily(),
- packet.GetPacketId());
+ arm::pipe::Version version = m_PacketVersionResolver.ResolvePacketVersion(packet.GetPacketFamily(),
+ packet.GetPacketId());
- CommandHandlerFunctor* commandHandlerFunctor =
- m_CommandHandlerRegistry.GetFunctor(packet.GetPacketFamily(),
- packet.GetPacketId(),
+ arm::pipe::CommandHandlerFunctor* commandHandlerFunctor =
+ m_CommandHandlerRegistry.GetFunctor(packet.GetPacketFamily(),
+ packet.GetPacketId(),
version.GetEncodedValue());
ARMNN_ASSERT(commandHandlerFunctor);
commandHandlerFunctor->operator()(packet);
@@ -72,6 +72,19 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection)
m_KeepRunning.store(false);
}
}
+ catch (const arm::pipe::ProfilingException& e)
+ {
+ // Log the error and continue
+ ARMNN_LOG(warning) << "An error has occurred when handling a command: " << e.what();
+ // Did we get here because the socket failed?
+ if ( !profilingConnection.IsOpen() )
+ {
+ // We're going to stop processing commands.
+ // This will leave the thread idle. There is no mechanism to restart the profiling service when the
+ // connection is lost.
+ m_KeepRunning.store(false);
+ }
+ }
catch (const Exception& e)
{
// Log the error and continue
diff --git a/src/profiling/CommandHandler.hpp b/src/profiling/CommandHandler.hpp
index 4bf820c5db..b2c9725a34 100644
--- a/src/profiling/CommandHandler.hpp
+++ b/src/profiling/CommandHandler.hpp
@@ -1,13 +1,14 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include "CommandHandlerRegistry.hpp"
#include "IProfilingConnection.hpp"
-#include "PacketVersionResolver.hpp"
+#include <common/include/PacketVersionResolver.hpp>
+
+#include <common/include/CommandHandlerRegistry.hpp>
#include <atomic>
#include <thread>
@@ -23,8 +24,8 @@ class CommandHandler
public:
CommandHandler(uint32_t timeout,
bool stopAfterTimeout,
- CommandHandlerRegistry& commandHandlerRegistry,
- PacketVersionResolver& packetVersionResolver)
+ arm::pipe::CommandHandlerRegistry& commandHandlerRegistry,
+ arm::pipe::PacketVersionResolver& packetVersionResolver)
: m_Timeout(timeout),
m_StopAfterTimeout(stopAfterTimeout),
m_IsRunning(false),
@@ -51,8 +52,8 @@ private:
std::atomic<bool> m_KeepRunning;
std::thread m_CommandThread;
- CommandHandlerRegistry& m_CommandHandlerRegistry;
- PacketVersionResolver& m_PacketVersionResolver;
+ arm::pipe::CommandHandlerRegistry& m_CommandHandlerRegistry;
+ arm::pipe::PacketVersionResolver& m_PacketVersionResolver;
};
} // namespace profiling
diff --git a/src/profiling/CommandHandlerFunctor.cpp b/src/profiling/CommandHandlerFunctor.cpp
deleted file mode 100644
index 7f836cba2f..0000000000
--- a/src/profiling/CommandHandlerFunctor.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "CommandHandlerFunctor.hpp"
-
-namespace armnn
-{
-
-namespace profiling
-{
-
-uint32_t CommandHandlerFunctor::GetFamilyId() const
-{
- return m_FamilyId;
-}
-
-uint32_t CommandHandlerFunctor::GetPacketId() const
-{
- return m_PacketId;
-}
-
-uint32_t CommandHandlerFunctor::GetVersion() const
-{
- return m_Version;
-}
-
-} // namespace profiling
-
-} // namespace armnn
diff --git a/src/profiling/CommandHandlerFunctor.hpp b/src/profiling/CommandHandlerFunctor.hpp
deleted file mode 100644
index 885a2f34b5..0000000000
--- a/src/profiling/CommandHandlerFunctor.hpp
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-#include <Packet.hpp>
-
-#include <armnn/utility/IgnoreUnused.hpp>
-
-#include <cstdint>
-
-namespace armnn
-{
-
-namespace profiling
-{
-
-class CommandHandlerFunctor
-{
-public:
- CommandHandlerFunctor(uint32_t familyId, uint32_t packetId, uint32_t version)
- : m_FamilyId(familyId),
- m_PacketId(packetId)
- , m_Version(version)
- {}
-
- uint32_t GetFamilyId() const;
- uint32_t GetPacketId() const;
- uint32_t GetVersion() const;
-
- virtual void operator()(const Packet& packet) = 0;
-
- virtual ~CommandHandlerFunctor() {}
-
-private:
- uint32_t m_FamilyId;
- uint32_t m_PacketId;
- uint32_t m_Version;
-};
-
-} // namespace profiling
-
-} // namespace armnn
diff --git a/src/profiling/CommandHandlerKey.cpp b/src/profiling/CommandHandlerKey.cpp
deleted file mode 100644
index 4d7e11a7e0..0000000000
--- a/src/profiling/CommandHandlerKey.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "CommandHandlerKey.hpp"
-
-namespace armnn
-{
-
-namespace profiling
-{
-
-uint32_t CommandHandlerKey::GetFamilyId() const
-{
- return m_FamilyId;
-}
-
-uint32_t CommandHandlerKey::GetPacketId() const
-{
- return m_PacketId;
-}
-
-uint32_t CommandHandlerKey::GetVersion() const
-{
- return m_Version;
-}
-
-bool CommandHandlerKey::operator<(const CommandHandlerKey& rhs) const
-{
- bool result = true;
- if (m_FamilyId == rhs.m_FamilyId)
- {
- if (m_PacketId == rhs.m_PacketId)
- {
- result = m_Version < rhs.m_Version;
- }
- else if (m_PacketId > rhs.m_PacketId)
- {
- result = false;
- }
- }
- else if (m_FamilyId > rhs.m_FamilyId)
- {
- result = false;
- }
- return result;
-}
-
-bool CommandHandlerKey::operator>(const CommandHandlerKey& rhs) const
-{
- return rhs < *this;
-}
-
-bool CommandHandlerKey::operator<=(const CommandHandlerKey& rhs) const
-{
- return !(*this > rhs);
-}
-
-bool CommandHandlerKey::operator>=(const CommandHandlerKey& rhs) const
-{
- return !(*this < rhs);
-}
-
-bool CommandHandlerKey::operator==(const CommandHandlerKey& rhs) const
-{
- return m_FamilyId == rhs.m_FamilyId && m_PacketId == rhs.m_PacketId && m_Version == rhs.m_Version;
-}
-
-bool CommandHandlerKey::operator!=(const CommandHandlerKey& rhs) const
-{
- return !(*this == rhs);
-}
-
-} // namespace profiling
-
-} // namespace armnn
diff --git a/src/profiling/CommandHandlerKey.hpp b/src/profiling/CommandHandlerKey.hpp
deleted file mode 100644
index 247f67925b..0000000000
--- a/src/profiling/CommandHandlerKey.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-#include <cstdint>
-
-namespace armnn
-{
-
-namespace profiling
-{
-
-class CommandHandlerKey
-{
-public:
- CommandHandlerKey(uint32_t familyId, uint32_t packetId, uint32_t version)
- : m_FamilyId(familyId), m_PacketId(packetId), m_Version(version) {};
-
- uint32_t GetFamilyId() const;
- uint32_t GetPacketId() const;
- uint32_t GetVersion() const;
-
- bool operator< (const CommandHandlerKey& rhs) const;
- bool operator> (const CommandHandlerKey& rhs) const;
- bool operator<=(const CommandHandlerKey& rhs) const;
- bool operator>=(const CommandHandlerKey& rhs) const;
- bool operator==(const CommandHandlerKey& rhs) const;
- bool operator!=(const CommandHandlerKey& rhs) const;
-
-private:
- uint32_t m_FamilyId;
- uint32_t m_PacketId;
- uint32_t m_Version;
-};
-
-} // namespace profiling
-
-} // namespace armnn
diff --git a/src/profiling/CommandHandlerRegistry.cpp b/src/profiling/CommandHandlerRegistry.cpp
deleted file mode 100644
index c2fef7a597..0000000000
--- a/src/profiling/CommandHandlerRegistry.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "CommandHandlerRegistry.hpp"
-
-#include <armnn/utility/Assert.hpp>
-
-#include <boost/format.hpp>
-
-namespace armnn
-{
-
-namespace profiling
-{
-
-void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor,
- uint32_t familyId,
- uint32_t packetId,
- uint32_t version)
-{
- ARMNN_ASSERT_MSG(functor, "Provided functor should not be a nullptr");
-
- CommandHandlerKey key(familyId, packetId, version);
- registry[key] = functor;
-}
-
-void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor)
-{
- ARMNN_ASSERT_MSG(functor, "Provided functor should not be a nullptr");
-
- RegisterFunctor(functor, functor->GetFamilyId(), functor->GetPacketId(), functor->GetVersion());
-}
-
-CommandHandlerFunctor* CommandHandlerRegistry::GetFunctor(uint32_t familyId,uint32_t packetId, uint32_t version) const
-{
- CommandHandlerKey key(familyId, packetId, version);
-
- // Check that the requested key exists
- if (registry.find(key) == registry.end())
- {
- throw armnn::InvalidArgumentException(
- boost::str(boost::format("Functor with requested PacketId=%1% and Version=%2% does not exist")
- % packetId
- % version));
- }
-
- CommandHandlerFunctor* commandHandlerFunctor = registry.at(key);
- if (commandHandlerFunctor == nullptr)
- {
- throw RuntimeException(
- boost::str(boost::format("Invalid functor registered for PacketId=%1% and Version=%2%")
- % packetId
- % version));
- }
-
- return commandHandlerFunctor;
-}
-
-} // namespace profiling
-
-} // namespace armnn
diff --git a/src/profiling/CommandHandlerRegistry.hpp b/src/profiling/CommandHandlerRegistry.hpp
deleted file mode 100644
index 43419deea4..0000000000
--- a/src/profiling/CommandHandlerRegistry.hpp
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-#include "CommandHandlerFunctor.hpp"
-#include "CommandHandlerKey.hpp"
-
-#include <boost/functional/hash.hpp>
-
-#include <unordered_map>
-
-namespace armnn
-{
-
-namespace profiling
-{
-
-struct CommandHandlerHash
-{
- std::size_t operator() (const CommandHandlerKey& commandHandlerKey) const
- {
- std::size_t seed = 0;
- boost::hash_combine(seed, commandHandlerKey.GetPacketId());
- boost::hash_combine(seed, commandHandlerKey.GetVersion());
- return seed;
- }
-};
-
-class CommandHandlerRegistry
-{
-public:
- CommandHandlerRegistry() = default;
-
- void RegisterFunctor(CommandHandlerFunctor* functor, uint32_t familyId, uint32_t packetId, uint32_t version);
-
- void RegisterFunctor(CommandHandlerFunctor* functor);
-
- CommandHandlerFunctor* GetFunctor(uint32_t familyId, uint32_t packetId, uint32_t version) const;
-
-private:
- std::unordered_map<CommandHandlerKey, CommandHandlerFunctor*, CommandHandlerHash> registry;
-};
-
-} // namespace profiling
-
-} // namespace armnn
diff --git a/src/profiling/ConnectionAcknowledgedCommandHandler.cpp b/src/profiling/ConnectionAcknowledgedCommandHandler.cpp
index ce2a36f9fb..7fa3785a43 100644
--- a/src/profiling/ConnectionAcknowledgedCommandHandler.cpp
+++ b/src/profiling/ConnectionAcknowledgedCommandHandler.cpp
@@ -16,7 +16,7 @@ namespace armnn
namespace profiling
{
-void ConnectionAcknowledgedCommandHandler::operator()(const Packet& packet)
+void ConnectionAcknowledgedCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ProfilingState currentState = m_StateMachine.GetCurrentState();
switch (currentState)
diff --git a/src/profiling/ConnectionAcknowledgedCommandHandler.hpp b/src/profiling/ConnectionAcknowledgedCommandHandler.hpp
index f65b23f457..0906f7f9f3 100644
--- a/src/profiling/ConnectionAcknowledgedCommandHandler.hpp
+++ b/src/profiling/ConnectionAcknowledgedCommandHandler.hpp
@@ -6,20 +6,21 @@
#pragma once
#include <armnn/backends/profiling/IBackendProfilingContext.hpp>
-#include "CommandHandlerFunctor.hpp"
#include "IProfilingServiceStatus.hpp"
#include "ISendCounterPacket.hpp"
#include "armnn/profiling/ISendTimelinePacket.hpp"
-#include <Packet.hpp>
#include "ProfilingStateMachine.hpp"
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
+
namespace armnn
{
namespace profiling
{
-class ConnectionAcknowledgedCommandHandler final : public CommandHandlerFunctor
+class ConnectionAcknowledgedCommandHandler final : public arm::pipe::CommandHandlerFunctor
{
typedef const std::unordered_map<BackendId, std::shared_ptr<armnn::profiling::IBackendProfilingContext>>&
@@ -44,7 +45,7 @@ public:
, m_BackendProfilingContext(backendProfilingContexts)
{}
- void operator()(const Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
void setTimelineEnabled(bool timelineEnabled)
{
diff --git a/src/profiling/CounterDirectory.cpp b/src/profiling/CounterDirectory.cpp
index ae1c49796c..e6356b82bd 100644
--- a/src/profiling/CounterDirectory.cpp
+++ b/src/profiling/CounterDirectory.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -7,10 +7,11 @@
#include "ProfilingUtils.hpp"
#include <armnn/Exceptions.hpp>
-#include <armnn/Conversion.hpp>
#include <armnn/utility/Assert.hpp>
#include <armnn/utility/IgnoreUnused.hpp>
+#include <common/include/SwTrace.hpp>
+
#include <boost/format.hpp>
namespace armnn
@@ -23,7 +24,7 @@ const Category* CounterDirectory::RegisterCategory(const std::string& categoryNa
{
// Check that the given category name is valid
if (categoryName.empty() ||
- !IsValidSwTraceString<SwTraceNameCharPolicy>(categoryName))
+ !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(categoryName))
{
throw InvalidArgumentException("Trying to register a category with an invalid name");
}
@@ -56,7 +57,7 @@ const Device* CounterDirectory::RegisterDevice(const std::string& deviceName,
{
// Check that the given device name is valid
if (deviceName.empty() ||
- !IsValidSwTraceString<SwTraceCharPolicy>(deviceName))
+ !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(deviceName))
{
throw InvalidArgumentException("Trying to register a device with an invalid name");
}
@@ -118,7 +119,7 @@ const CounterSet* CounterDirectory::RegisterCounterSet(const std::string& counte
{
// Check that the given counter set name is valid
if (counterSetName.empty() ||
- !IsValidSwTraceString<SwTraceNameCharPolicy>(counterSetName))
+ !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(counterSetName))
{
throw InvalidArgumentException("Trying to register a counter set with an invalid name");
}
@@ -196,7 +197,7 @@ const Counter* CounterDirectory::RegisterCounter(const BackendId& backendId,
// Check that the given parent category name is valid
if (parentCategoryName.empty() ||
- !IsValidSwTraceString<SwTraceNameCharPolicy>(parentCategoryName))
+ !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(parentCategoryName))
{
throw InvalidArgumentException("Trying to register a counter with an invalid parent category name");
}
@@ -221,21 +222,21 @@ const Counter* CounterDirectory::RegisterCounter(const BackendId& backendId,
// Check that the given name is valid
if (name.empty() ||
- !IsValidSwTraceString<SwTraceCharPolicy>(name))
+ !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(name))
{
throw InvalidArgumentException("Trying to register a counter with an invalid name");
}
// Check that the given description is valid
if (description.empty() ||
- !IsValidSwTraceString<SwTraceCharPolicy>(description))
+ !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(description))
{
throw InvalidArgumentException("Trying to register a counter with an invalid description");
}
// Check that the given units are valid
if (units.has_value()
- && !IsValidSwTraceString<SwTraceNameCharPolicy>(units.value()))
+ && !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(units.value()))
{
throw InvalidArgumentException("Trying to register a counter with a invalid units");
}
diff --git a/src/profiling/CounterDirectory.hpp b/src/profiling/CounterDirectory.hpp
index 6a73a76a0d..a6e788ee1f 100644
--- a/src/profiling/CounterDirectory.hpp
+++ b/src/profiling/CounterDirectory.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -12,7 +12,7 @@
#include <unordered_set>
#include <unordered_map>
-#include <boost/numeric/conversion/cast.hpp>
+#include <armnn/utility/NumericCast.hpp>
namespace armnn
{
@@ -48,10 +48,10 @@ public:
const Optional<uint16_t>& counterSetUid = EmptyOptional()) override;
// Getters for counts
- uint16_t GetCategoryCount() const override { return boost::numeric_cast<uint16_t>(m_Categories.size()); }
- uint16_t GetDeviceCount() const override { return boost::numeric_cast<uint16_t>(m_Devices.size()); }
- uint16_t GetCounterSetCount() const override { return boost::numeric_cast<uint16_t>(m_CounterSets.size()); }
- uint16_t GetCounterCount() const override { return boost::numeric_cast<uint16_t>(m_Counters.size()); }
+ uint16_t GetCategoryCount() const override { return armnn::numeric_cast<uint16_t>(m_Categories.size()); }
+ uint16_t GetDeviceCount() const override { return armnn::numeric_cast<uint16_t>(m_Devices.size()); }
+ uint16_t GetCounterSetCount() const override { return armnn::numeric_cast<uint16_t>(m_CounterSets.size()); }
+ uint16_t GetCounterCount() const override { return armnn::numeric_cast<uint16_t>(m_Counters.size()); }
// Getters for collections
const Categories& GetCategories() const override { return m_Categories; }
diff --git a/src/profiling/DeactivateTimelineReportingCommandHandler.cpp b/src/profiling/DeactivateTimelineReportingCommandHandler.cpp
index dbfb053b3d..bdee83b1c0 100644
--- a/src/profiling/DeactivateTimelineReportingCommandHandler.cpp
+++ b/src/profiling/DeactivateTimelineReportingCommandHandler.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -15,7 +15,7 @@ namespace armnn
namespace profiling
{
-void DeactivateTimelineReportingCommandHandler::operator()(const Packet& packet)
+void DeactivateTimelineReportingCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ProfilingState currentState = m_StateMachine.GetCurrentState();
diff --git a/src/profiling/DeactivateTimelineReportingCommandHandler.hpp b/src/profiling/DeactivateTimelineReportingCommandHandler.hpp
index e9d2180699..822e92c425 100644
--- a/src/profiling/DeactivateTimelineReportingCommandHandler.hpp
+++ b/src/profiling/DeactivateTimelineReportingCommandHandler.hpp
@@ -1,22 +1,23 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include "CommandHandlerFunctor.hpp"
-#include <Packet.hpp>
#include "ProfilingStateMachine.hpp"
#include "INotifyBackends.hpp"
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
+
namespace armnn
{
namespace profiling
{
-class DeactivateTimelineReportingCommandHandler : public CommandHandlerFunctor
+class DeactivateTimelineReportingCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
@@ -32,7 +33,7 @@ public:
, m_BackendNotifier(notifyBackends)
{}
- void operator()(const Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
private:
std::atomic<bool>& m_TimelineReporting;
diff --git a/src/profiling/DirectoryCaptureCommandHandler.cpp b/src/profiling/DirectoryCaptureCommandHandler.cpp
index e20f5402c6..60463a10c3 100644
--- a/src/profiling/DirectoryCaptureCommandHandler.cpp
+++ b/src/profiling/DirectoryCaptureCommandHandler.cpp
@@ -1,7 +1,8 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
+
#include "DirectoryCaptureCommandHandler.hpp"
#include <armnn/BackendId.hpp>
@@ -20,7 +21,7 @@ namespace profiling
uint32_t uint16_t_size = sizeof(uint16_t);
uint32_t uint32_t_size = sizeof(uint32_t);
-void DirectoryCaptureCommandHandler::ParseData(const armnn::profiling::Packet& packet)
+void DirectoryCaptureCommandHandler::ParseData(const arm::pipe::Packet& packet)
{
uint16_t categoryRecordCount;
uint16_t counterSetRecordCount;
@@ -296,7 +297,7 @@ std::vector<CounterDirectoryEventRecord> DirectoryCaptureCommandHandler::ReadEve
return eventRecords;
}
-void DirectoryCaptureCommandHandler::operator()(const profiling::Packet& packet)
+void DirectoryCaptureCommandHandler::operator()(const arm::pipe::Packet& packet)
{
if (!m_QuietOperation) // Are we supposed to print to stdout?
{
diff --git a/src/profiling/DirectoryCaptureCommandHandler.hpp b/src/profiling/DirectoryCaptureCommandHandler.hpp
index 6b25714168..90ae1d400d 100644
--- a/src/profiling/DirectoryCaptureCommandHandler.hpp
+++ b/src/profiling/DirectoryCaptureCommandHandler.hpp
@@ -1,13 +1,14 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include "CommandHandlerFunctor.hpp"
#include "CounterDirectory.hpp"
+#include <common/include/CommandHandlerFunctor.hpp>
+
#include <atomic>
namespace armnn
@@ -30,7 +31,7 @@ struct CounterDirectoryEventRecord
uint16_t m_MaxCounterUid;
};
-class DirectoryCaptureCommandHandler : public profiling::CommandHandlerFunctor
+class DirectoryCaptureCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
@@ -40,7 +41,7 @@ public:
, m_AlreadyParsed(false)
{}
- void operator()(const armnn::profiling::Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
const ICounterDirectory& GetCounterDirectory() const;
@@ -61,7 +62,7 @@ public:
}
private:
- void ParseData(const armnn::profiling::Packet& packet);
+ void ParseData(const arm::pipe::Packet& packet);
void ReadCategoryRecords(const unsigned char* data, uint32_t offset, std::vector<uint32_t> categoryOffsets);
diff --git a/src/profiling/EncodeVersion.hpp b/src/profiling/EncodeVersion.hpp
deleted file mode 100644
index f66f7278a5..0000000000
--- a/src/profiling/EncodeVersion.hpp
+++ /dev/null
@@ -1,83 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-#pragma once
-
-#include <cstdint>
-#include <string>
-#include <ostream>
-#include <sstream>
-
-namespace armnn
-{
-
-namespace profiling
-{
-
-constexpr inline uint32_t EncodeVersion(uint32_t major, uint32_t minor, uint32_t patch)
-{
- return (major << 22) | (minor << 12) | patch;
-}
-
-// Encodes a semantic version https://semver.org/ into a 32 bit integer in the following fashion
-//
-// bits 22:31 major: Unsigned 10-bit integer. Major component of the schema version number.
-// bits 12:21 minor: Unsigned 10-bit integer. Minor component of the schema version number.
-// bits 0:11 patch: Unsigned 12-bit integer. Patch component of the schema version number.
-//
-class Version
-{
-public:
- Version(uint32_t encodedValue)
- {
- m_Major = (encodedValue >> 22) & 1023;
- m_Minor = (encodedValue >> 12) & 1023;
- m_Patch = encodedValue & 4095;
- }
-
- Version(uint32_t major, uint32_t minor, uint32_t patch) :
- m_Major(major),
- m_Minor(minor),
- m_Patch(patch)
- {}
-
- uint32_t GetEncodedValue()
- {
- return EncodeVersion(m_Major, m_Minor, m_Patch);
- }
-
- uint32_t GetMajor() { return m_Major; }
- uint32_t GetMinor() { return m_Minor; }
- uint32_t GetPatch() { return m_Patch; }
-
- bool operator==(const Version& other) const
- {
- return m_Major == other.m_Major && m_Minor == other.m_Minor && m_Patch == other.m_Patch;
- }
-
- std::string ToString() const
- {
- constexpr char separator = '.';
-
- std::stringstream stringStream;
- stringStream << m_Major << separator << m_Minor << separator << m_Patch;
-
- return stringStream.str();
- }
-
-private:
- uint32_t m_Major;
- uint32_t m_Minor;
- uint32_t m_Patch;
-};
-
-inline std::ostream& operator<<(std::ostream& os, const Version& version)
-{
- os << version.ToString();
- return os;
-}
-
-} // namespace profiling
-
-} // namespace armnn
diff --git a/src/profiling/FileOnlyProfilingConnection.cpp b/src/profiling/FileOnlyProfilingConnection.cpp
index 1e26aaa472..24f2cc7ede 100644
--- a/src/profiling/FileOnlyProfilingConnection.cpp
+++ b/src/profiling/FileOnlyProfilingConnection.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -28,30 +28,30 @@ std::vector<uint32_t> StreamMetaDataProcessor::GetHeadersAccepted()
return headers;
}
-void StreamMetaDataProcessor::HandlePacket(const Packet& packet)
+void StreamMetaDataProcessor::HandlePacket(const arm::pipe::Packet& packet)
{
if (packet.GetHeader() != m_MetaDataPacketHeader)
{
- throw armnnProfiling::ProfilingException("StreamMetaDataProcessor can only handle Stream Meta Data Packets");
+ throw arm::pipe::ProfilingException("StreamMetaDataProcessor can only handle Stream Meta Data Packets");
}
// determine the endianness of the protocol
TargetEndianness endianness;
- if (ToUint32(packet.GetData(),TargetEndianness::BeWire) == armnnProfiling::PIPE_MAGIC)
+ if (ToUint32(packet.GetData(),TargetEndianness::BeWire) == arm::pipe::PIPE_MAGIC)
{
endianness = TargetEndianness::BeWire;
}
- else if (ToUint32(packet.GetData(), TargetEndianness::LeWire) == armnnProfiling::PIPE_MAGIC)
+ else if (ToUint32(packet.GetData(), TargetEndianness::LeWire) == arm::pipe::PIPE_MAGIC)
{
endianness = TargetEndianness::LeWire;
}
else
{
- throw armnnProfiling::ProfilingException("Protocol read error. Unable to read PIPE_MAGIC value.");
+ throw arm::pipe::ProfilingException("Protocol read error. Unable to read the PIPE_MAGIC value.");
}
m_FileOnlyProfilingConnection->SetEndianess(endianness);
// send back the acknowledgement
std::unique_ptr<unsigned char[]> uniqueNullPtr = nullptr;
- Packet returnPacket(0x10000, 0, uniqueNullPtr);
+ arm::pipe::Packet returnPacket(0x10000, 0, uniqueNullPtr);
m_FileOnlyProfilingConnection->ReturnPacket(returnPacket);
}
@@ -110,12 +110,12 @@ void FileOnlyProfilingConnection::Close()
bool FileOnlyProfilingConnection::WritePacket(const unsigned char* buffer, uint32_t length)
{
ARMNN_ASSERT(buffer);
- Packet packet = ReceivePacket(buffer, length);
+ arm::pipe::Packet packet = ReceivePacket(buffer, length);
ForwardPacketToHandlers(packet);
return true;
}
-void FileOnlyProfilingConnection::ReturnPacket(Packet& packet)
+void FileOnlyProfilingConnection::ReturnPacket(arm::pipe::Packet& packet)
{
{
std::lock_guard<std::mutex> lck(m_PacketAvailableMutex);
@@ -124,7 +124,7 @@ void FileOnlyProfilingConnection::ReturnPacket(Packet& packet)
m_ConditionPacketAvailable.notify_one();
}
-Packet FileOnlyProfilingConnection::ReadPacket(uint32_t timeout)
+arm::pipe::Packet FileOnlyProfilingConnection::ReadPacket(uint32_t timeout)
{
std::unique_lock<std::mutex> lck(m_PacketAvailableMutex);
@@ -134,11 +134,11 @@ Packet FileOnlyProfilingConnection::ReadPacket(uint32_t timeout)
std::chrono::milliseconds(timeout),
[&]{return !m_PacketQueue.empty();}))
{
- Packet empty;
+ arm::pipe::Packet empty;
return empty;
}
- Packet returnedPacket = std::move(m_PacketQueue.front());
+ arm::pipe::Packet returnedPacket = std::move(m_PacketQueue.front());
m_PacketQueue.pop();
return returnedPacket;
}
@@ -199,7 +199,7 @@ void FileOnlyProfilingConnection::StartProcessingThread()
m_LocalHandlersThread = std::thread(&FileOnlyProfilingConnection::ServiceLocalHandlers, this);
}
-void FileOnlyProfilingConnection::ForwardPacketToHandlers(Packet& packet)
+void FileOnlyProfilingConnection::ForwardPacketToHandlers(arm::pipe::Packet& packet)
{
if (m_PacketHandlers.empty())
{
@@ -224,7 +224,7 @@ void FileOnlyProfilingConnection::ServiceLocalHandlers()
{
do
{
- Packet returnedPacket;
+ arm::pipe::Packet returnedPacket;
bool readPacket = false;
{ // only lock while we are taking the packet off the incoming list
std::unique_lock<std::mutex> lck(m_ReadableMutex);
@@ -273,7 +273,7 @@ void FileOnlyProfilingConnection::ClearReadableList()
}
}
-void FileOnlyProfilingConnection::DispatchPacketToHandlers(const Packet& packet)
+void FileOnlyProfilingConnection::DispatchPacketToHandlers(const arm::pipe::Packet& packet)
{
for (auto& delegate : m_UniversalHandlers)
{
@@ -288,7 +288,7 @@ void FileOnlyProfilingConnection::DispatchPacketToHandlers(const Packet& packet)
{
delegate->HandlePacket(packet);
}
- catch (const armnnProfiling::ProfilingException& ex)
+ catch (const arm::pipe::ProfilingException& ex)
{
Fail(ex.what());
}
diff --git a/src/profiling/FileOnlyProfilingConnection.hpp b/src/profiling/FileOnlyProfilingConnection.hpp
index b19b983ebc..8bde0abdea 100644
--- a/src/profiling/FileOnlyProfilingConnection.hpp
+++ b/src/profiling/FileOnlyProfilingConnection.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -8,10 +8,11 @@
#include <armnn/profiling/ILocalPacketHandler.hpp>
#include "DirectoryCaptureCommandHandler.hpp"
#include "IProfilingConnection.hpp"
-#include <Packet.hpp>
#include "ProfilingUtils.hpp"
#include "Runtime.hpp"
+#include <common/include/Packet.hpp>
+
#include <atomic>
#include <condition_variable>
#include <fstream>
@@ -37,7 +38,7 @@ public:
std::vector<uint32_t> GetHeadersAccepted() override;
- void HandlePacket(const Packet& packet) override;
+ void HandlePacket(const arm::pipe::Packet& packet) override;
private:
FileOnlyProfilingConnection* m_FileOnlyProfilingConnection;
@@ -82,28 +83,28 @@ public:
bool WritePacket(const unsigned char* buffer, uint32_t length) override;
// Sending a packet back to ArmNN.
- Packet ReadPacket(uint32_t timeout) override;
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override;
void SetEndianess(const TargetEndianness& endianness) override //IInternalProfilingConnection
{
m_Endianness = endianness;
}
- void ReturnPacket(Packet& packet) override; //IInternalProfilingConnection
+ void ReturnPacket(arm::pipe::Packet& packet) override; //IInternalProfilingConnection
private:
void AddLocalPacketHandler(ILocalPacketHandlerSharedPtr localPacketHandler);
void StartProcessingThread();
void ClearReadableList();
- void DispatchPacketToHandlers(const Packet& packet);
+ void DispatchPacketToHandlers(const arm::pipe::Packet& packet);
void Fail(const std::string& errorMessage);
- void ForwardPacketToHandlers(Packet& packet);
+ void ForwardPacketToHandlers(arm::pipe::Packet& packet);
void ServiceLocalHandlers();
Runtime::CreationOptions::ExternalProfilingOptions m_Options;
- std::queue<Packet> m_PacketQueue;
+ std::queue<arm::pipe::Packet> m_PacketQueue;
TargetEndianness m_Endianness;
std::mutex m_PacketAvailableMutex;
@@ -114,7 +115,7 @@ private:
std::vector<ILocalPacketHandlerSharedPtr> m_UniversalHandlers;
// List of readable packets for the local packet handlers
- std::queue<Packet> m_ReadableList;
+ std::queue<arm::pipe::Packet> m_ReadableList;
// Mutex and condition variable for the readable packet list
std::mutex m_ReadableMutex;
std::condition_variable m_ConditionPacketReadable;
diff --git a/src/profiling/IProfilingConnection.hpp b/src/profiling/IProfilingConnection.hpp
index cf45a43ef3..7ed714c1a3 100644
--- a/src/profiling/IProfilingConnection.hpp
+++ b/src/profiling/IProfilingConnection.hpp
@@ -5,9 +5,10 @@
#pragma once
-#include <Packet.hpp>
#include <armnn/profiling/ILocalPacketHandler.hpp>
+#include <common/include/Packet.hpp>
+
#include <cstdint>
namespace armnn
@@ -27,7 +28,7 @@ public:
virtual bool WritePacket(const unsigned char* buffer, uint32_t length) = 0;
- virtual Packet ReadPacket(uint32_t timeout) = 0;
+ virtual arm::pipe::Packet ReadPacket(uint32_t timeout) = 0;
};
} // namespace profiling
diff --git a/src/profiling/PacketVersionResolver.cpp b/src/profiling/PacketVersionResolver.cpp
deleted file mode 100644
index 689abbb082..0000000000
--- a/src/profiling/PacketVersionResolver.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "PacketVersionResolver.hpp"
-
-#include <armnn/utility/IgnoreUnused.hpp>
-
-namespace armnn
-{
-
-namespace profiling
-{
-
-bool PacketKey::operator<(const PacketKey& rhs) const
-{
- bool result = true;
- if (m_FamilyId == rhs.m_FamilyId)
- {
- result = m_PacketId < rhs.m_PacketId;
- }
- else if (m_FamilyId > rhs.m_FamilyId)
- {
- result = false;
- }
- return result;
-}
-
-bool PacketKey::operator>(const PacketKey& rhs) const
-{
- return rhs < *this;
-}
-
-bool PacketKey::operator<=(const PacketKey& rhs) const
-{
- return !(*this > rhs);
-}
-
-bool PacketKey::operator>=(const PacketKey& rhs) const
-{
- return !(*this < rhs);
-}
-
-bool PacketKey::operator==(const PacketKey& rhs) const
-{
- return m_FamilyId == rhs.m_FamilyId && m_PacketId == rhs.m_PacketId;
-}
-
-bool PacketKey::operator!=(const PacketKey& rhs) const
-{
- return !(*this == rhs);
-}
-
-Version PacketVersionResolver::ResolvePacketVersion(uint32_t familyId, uint32_t packetId) const
-{
- const PacketKey packetKey(familyId, packetId);
-
- if( packetKey == ActivateTimeLinePacket )
- {
- return Version(1, 1, 0);
- }
- if( packetKey == DeactivateTimeLinePacket )
- {
- return Version(1, 1, 0);
- }
-
- return Version(1, 0, 0);
-}
-
-} // namespace profiling
-
-} // namespace armnn
diff --git a/src/profiling/PacketVersionResolver.hpp b/src/profiling/PacketVersionResolver.hpp
deleted file mode 100644
index 3112f5eac0..0000000000
--- a/src/profiling/PacketVersionResolver.hpp
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-#include "EncodeVersion.hpp"
-
-namespace armnn
-{
-
-namespace profiling
-{
-
-class PacketKey final
-{
-public:
- PacketKey(uint32_t familyId, uint32_t packetId) : m_FamilyId(familyId), m_PacketId(packetId) {}
-
- uint32_t GetFamilyId() { return m_FamilyId; }
- uint32_t GetPacketId() { return m_PacketId; }
-
- bool operator< (const PacketKey& rhs) const;
- bool operator> (const PacketKey& rhs) const;
- bool operator<=(const PacketKey& rhs) const;
- bool operator>=(const PacketKey& rhs) const;
- bool operator==(const PacketKey& rhs) const;
- bool operator!=(const PacketKey& rhs) const;
-
-private:
- uint32_t m_FamilyId;
- uint32_t m_PacketId;
-};
-
-static const PacketKey ActivateTimeLinePacket(0 , 6);
-static const PacketKey DeactivateTimeLinePacket(0 , 7);
-
-class PacketVersionResolver final
-{
-public:
- PacketVersionResolver() = default;
- ~PacketVersionResolver() = default;
-
- Version ResolvePacketVersion(uint32_t familyId, uint32_t packetId) const;
-};
-
-} // namespace profiling
-
-} // namespace armnn
diff --git a/src/profiling/PerJobCounterSelectionCommandHandler.cpp b/src/profiling/PerJobCounterSelectionCommandHandler.cpp
index 8892e1457d..fea8ee3e5b 100644
--- a/src/profiling/PerJobCounterSelectionCommandHandler.cpp
+++ b/src/profiling/PerJobCounterSelectionCommandHandler.cpp
@@ -1,9 +1,10 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "PerJobCounterSelectionCommandHandler.hpp"
+#include <armnn/Exceptions.hpp>
#include <boost/format.hpp>
@@ -13,7 +14,7 @@ namespace armnn
namespace profiling
{
-void PerJobCounterSelectionCommandHandler::operator()(const Packet& packet)
+void PerJobCounterSelectionCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ProfilingState currentState = m_StateMachine.GetCurrentState();
switch (currentState)
@@ -21,9 +22,9 @@ void PerJobCounterSelectionCommandHandler::operator()(const Packet& packet)
case ProfilingState::Uninitialised:
case ProfilingState::NotConnected:
case ProfilingState::WaitingForAck:
- throw RuntimeException(boost::str(boost::format("Per-Job Counter Selection Command Handler invoked while in "
- "an wrong state: %1%")
- % GetProfilingStateName(currentState)));
+ throw armnn::RuntimeException(boost::str(boost::format(
+ "Per-Job Counter Selection Command Handler invoked while in an incorrect state: %1%")
+ % GetProfilingStateName(currentState)));
case ProfilingState::Active:
// Process the packet
if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 5u))
@@ -38,8 +39,8 @@ void PerJobCounterSelectionCommandHandler::operator()(const Packet& packet)
break;
default:
- throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1%")
- % static_cast<int>(currentState)));
+ throw armnn::RuntimeException(boost::str(boost::format("Unknown profiling service state: %1%")
+ % static_cast<int>(currentState)));
}
}
diff --git a/src/profiling/PerJobCounterSelectionCommandHandler.hpp b/src/profiling/PerJobCounterSelectionCommandHandler.hpp
index daf10c6d95..eef8421900 100644
--- a/src/profiling/PerJobCounterSelectionCommandHandler.hpp
+++ b/src/profiling/PerJobCounterSelectionCommandHandler.hpp
@@ -1,21 +1,22 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include <Packet.hpp>
-#include "CommandHandlerFunctor.hpp"
#include "ProfilingStateMachine.hpp"
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
+
namespace armnn
{
namespace profiling
{
-class PerJobCounterSelectionCommandHandler : public CommandHandlerFunctor
+class PerJobCounterSelectionCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
@@ -27,7 +28,7 @@ public:
, m_StateMachine(profilingStateMachine)
{}
- void operator()(const Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
private:
const ProfilingStateMachine& m_StateMachine;
diff --git a/src/profiling/PeriodicCounterSelectionCommandHandler.cpp b/src/profiling/PeriodicCounterSelectionCommandHandler.cpp
index bd4fa0691c..1b10643fca 100644
--- a/src/profiling/PeriodicCounterSelectionCommandHandler.cpp
+++ b/src/profiling/PeriodicCounterSelectionCommandHandler.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -18,7 +18,7 @@ namespace armnn
namespace profiling
{
-void PeriodicCounterSelectionCommandHandler::ParseData(const Packet& packet, CaptureData& captureData)
+void PeriodicCounterSelectionCommandHandler::ParseData(const arm::pipe::Packet& packet, CaptureData& captureData)
{
std::vector<uint16_t> counterIds;
uint32_t sizeOfUint32 = boost::numeric_cast<uint32_t>(sizeof(uint32_t));
@@ -56,7 +56,7 @@ void PeriodicCounterSelectionCommandHandler::ParseData(const Packet& packet, Cap
captureData.SetCounterIds(counterIds);
}
-void PeriodicCounterSelectionCommandHandler::operator()(const Packet& packet)
+void PeriodicCounterSelectionCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ProfilingState currentState = m_StateMachine.GetCurrentState();
switch (currentState)
diff --git a/src/profiling/PeriodicCounterSelectionCommandHandler.hpp b/src/profiling/PeriodicCounterSelectionCommandHandler.hpp
index ac08cc58ec..ec67391b9c 100644
--- a/src/profiling/PeriodicCounterSelectionCommandHandler.hpp
+++ b/src/profiling/PeriodicCounterSelectionCommandHandler.hpp
@@ -1,13 +1,11 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include "CounterIdMap.hpp"
-#include <Packet.hpp>
-#include "CommandHandlerFunctor.hpp"
#include "Holder.hpp"
#include "ProfilingStateMachine.hpp"
#include "SendCounterPacket.hpp"
@@ -18,8 +16,10 @@
#include "armnn/Logging.hpp"
#include "armnn/BackendRegistry.hpp"
-#include <set>
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
+#include <set>
namespace armnn
{
@@ -28,7 +28,7 @@ namespace profiling
{
-class PeriodicCounterSelectionCommandHandler : public CommandHandlerFunctor
+class PeriodicCounterSelectionCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
@@ -60,7 +60,7 @@ public:
}
- void operator()(const Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
private:
@@ -90,7 +90,7 @@ private:
<< errorMsg.value();
}
}
- void ParseData(const Packet& packet, CaptureData& captureData);
+ void ParseData(const arm::pipe::Packet& packet, CaptureData& captureData);
std::set<armnn::BackendId> ProcessBackendCounterIds(const uint32_t capturePeriod,
const std::set<uint16_t> newCounterIds,
const std::set<uint16_t> unusedCounterIds);
diff --git a/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp b/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp
index d61911b54e..5768566178 100644
--- a/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp
+++ b/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -61,9 +61,9 @@ bool ProfilingConnectionDumpToFileDecorator::WritePacket(const unsigned char* bu
return success;
}
-Packet ProfilingConnectionDumpToFileDecorator::ReadPacket(uint32_t timeout)
+arm::pipe::Packet ProfilingConnectionDumpToFileDecorator::ReadPacket(uint32_t timeout)
{
- Packet packet = m_Connection->ReadPacket(timeout);
+ arm::pipe::Packet packet = m_Connection->ReadPacket(timeout);
if (!m_Options.m_IncomingCaptureFile.empty())
{
DumpIncomingToFile(packet);
@@ -90,7 +90,7 @@ bool ProfilingConnectionDumpToFileDecorator::OpenOutgoingDumpFile()
/// to write the data into the specified file.
/// @param packet data packet to write
/// @return nothing
-void ProfilingConnectionDumpToFileDecorator::DumpIncomingToFile(const Packet& packet)
+void ProfilingConnectionDumpToFileDecorator::DumpIncomingToFile(const arm::pipe::Packet& packet)
{
bool success = true;
if (!m_IncomingDumpFileStream.is_open())
diff --git a/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp b/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp
index 545c57f728..aedb28571e 100644
--- a/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp
+++ b/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -38,14 +38,14 @@ public:
bool WritePacket(const unsigned char* buffer, uint32_t length) override;
- Packet ReadPacket(uint32_t timeout) override;
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override;
private:
bool OpenIncomingDumpFile();
bool OpenOutgoingDumpFile();
- void DumpIncomingToFile(const Packet& packet);
+ void DumpIncomingToFile(const arm::pipe::Packet& packet);
bool DumpOutgoingToFile(const unsigned char* buffer, uint32_t length);
diff --git a/src/profiling/ProfilingConnectionFactory.cpp b/src/profiling/ProfilingConnectionFactory.cpp
index 7849b7e21e..96f7ed4b06 100644
--- a/src/profiling/ProfilingConnectionFactory.cpp
+++ b/src/profiling/ProfilingConnectionFactory.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/src/profiling/ProfilingConnectionFactory.hpp b/src/profiling/ProfilingConnectionFactory.hpp
index c6d4c6faf0..fa8b32f703 100644
--- a/src/profiling/ProfilingConnectionFactory.hpp
+++ b/src/profiling/ProfilingConnectionFactory.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp
index 8532c3efad..b673993846 100644
--- a/src/profiling/ProfilingService.cpp
+++ b/src/profiling/ProfilingService.cpp
@@ -148,7 +148,7 @@ void ProfilingService::Update()
ARMNN_LOG(warning) << "An error has occurred when creating the profiling connection: "
<< e.what();
}
- catch (const armnnProfiling::SocketConnectionException& e)
+ catch (const arm::pipe::SocketConnectionException& e)
{
ARMNN_LOG(warning) << "An error has occurred when creating the profiling connection ["
<< e.what() << "] on socket [" << e.GetSocketFd() << "].";
diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp
index 247b945813..1bc7c59808 100644
--- a/src/profiling/ProfilingService.hpp
+++ b/src/profiling/ProfilingService.hpp
@@ -31,6 +31,8 @@
#include "INotifyBackends.hpp"
#include <armnn/backends/profiling/IBackendProfilingContext.hpp>
+#include <list>
+
namespace armnn
{
@@ -236,22 +238,22 @@ private:
void CheckCounterUid(uint16_t counterUid) const;
// Profiling service components
- ExternalProfilingOptions m_Options;
- std::atomic<bool> m_TimelineReporting;
- CounterDirectory m_CounterDirectory;
- CounterIdMap m_CounterIdMap;
- IProfilingConnectionFactoryPtr m_ProfilingConnectionFactory;
- IProfilingConnectionPtr m_ProfilingConnection;
- ProfilingStateMachine m_StateMachine;
- CounterIndices m_CounterIndex;
- CounterValues m_CounterValues;
- CommandHandlerRegistry m_CommandHandlerRegistry;
- PacketVersionResolver m_PacketVersionResolver;
- CommandHandler m_CommandHandler;
- BufferManager m_BufferManager;
- SendCounterPacket m_SendCounterPacket;
- SendThread m_SendThread;
- SendTimelinePacket m_SendTimelinePacket;
+ ExternalProfilingOptions m_Options;
+ std::atomic<bool> m_TimelineReporting;
+ CounterDirectory m_CounterDirectory;
+ CounterIdMap m_CounterIdMap;
+ IProfilingConnectionFactoryPtr m_ProfilingConnectionFactory;
+ IProfilingConnectionPtr m_ProfilingConnection;
+ ProfilingStateMachine m_StateMachine;
+ CounterIndices m_CounterIndex;
+ CounterValues m_CounterValues;
+ arm::pipe::CommandHandlerRegistry m_CommandHandlerRegistry;
+ arm::pipe::PacketVersionResolver m_PacketVersionResolver;
+ CommandHandler m_CommandHandler;
+ BufferManager m_BufferManager;
+ SendCounterPacket m_SendCounterPacket;
+ SendThread m_SendThread;
+ SendTimelinePacket m_SendTimelinePacket;
Holder m_Holder;
diff --git a/src/profiling/ProfilingUtils.cpp b/src/profiling/ProfilingUtils.cpp
index 8c43a8cd3a..4767f3e746 100644
--- a/src/profiling/ProfilingUtils.cpp
+++ b/src/profiling/ProfilingUtils.cpp
@@ -5,7 +5,9 @@
#include "ProfilingUtils.hpp"
-#include "common/include/ProfilingException.hpp"
+#include <common/include/CommonProfilingUtils.hpp>
+#include <common/include/ProfilingException.hpp>
+#include <common/include/SwTrace.hpp>
#include <armnn/Version.hpp>
@@ -139,52 +141,27 @@ void WriteUint8(const IPacketBufferPtr& packetBuffer, unsigned int offset, uint8
void WriteBytes(unsigned char* buffer, unsigned int offset, const void* value, unsigned int valueSize)
{
- ARMNN_ASSERT(buffer);
- ARMNN_ASSERT(value);
-
- for (unsigned int i = 0; i < valueSize; i++, offset++)
- {
- buffer[offset] = *(reinterpret_cast<const unsigned char*>(value) + i);
- }
+ arm::pipe::WriteBytes(buffer, offset, value, valueSize);
}
void WriteUint64(unsigned char* buffer, unsigned int offset, uint64_t value)
{
- ARMNN_ASSERT(buffer);
-
- buffer[offset] = static_cast<unsigned char>(value & 0xFF);
- buffer[offset + 1] = static_cast<unsigned char>((value >> 8) & 0xFF);
- buffer[offset + 2] = static_cast<unsigned char>((value >> 16) & 0xFF);
- buffer[offset + 3] = static_cast<unsigned char>((value >> 24) & 0xFF);
- buffer[offset + 4] = static_cast<unsigned char>((value >> 32) & 0xFF);
- buffer[offset + 5] = static_cast<unsigned char>((value >> 40) & 0xFF);
- buffer[offset + 6] = static_cast<unsigned char>((value >> 48) & 0xFF);
- buffer[offset + 7] = static_cast<unsigned char>((value >> 56) & 0xFF);
+ arm::pipe::WriteUint64(buffer, offset, value);
}
void WriteUint32(unsigned char* buffer, unsigned int offset, uint32_t value)
{
- ARMNN_ASSERT(buffer);
-
- buffer[offset] = static_cast<unsigned char>(value & 0xFF);
- buffer[offset + 1] = static_cast<unsigned char>((value >> 8) & 0xFF);
- buffer[offset + 2] = static_cast<unsigned char>((value >> 16) & 0xFF);
- buffer[offset + 3] = static_cast<unsigned char>((value >> 24) & 0xFF);
+ arm::pipe::WriteUint32(buffer, offset, value);
}
void WriteUint16(unsigned char* buffer, unsigned int offset, uint16_t value)
{
- ARMNN_ASSERT(buffer);
-
- buffer[offset] = static_cast<unsigned char>(value & 0xFF);
- buffer[offset + 1] = static_cast<unsigned char>((value >> 8) & 0xFF);
+ arm::pipe::WriteUint16(buffer, offset, value);
}
void WriteUint8(unsigned char* buffer, unsigned int offset, uint8_t value)
{
- ARMNN_ASSERT(buffer);
-
- buffer[offset] = static_cast<unsigned char>(value);
+ arm::pipe::WriteUint8(buffer, offset, value);
}
void ReadBytes(const IPacketBufferPtr& packetBuffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
@@ -224,59 +201,27 @@ uint8_t ReadUint8(const IPacketBufferPtr& packetBuffer, unsigned int offset)
void ReadBytes(const unsigned char* buffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
{
- ARMNN_ASSERT(buffer);
- ARMNN_ASSERT(outValue);
-
- for (unsigned int i = 0; i < valueSize; i++, offset++)
- {
- outValue[i] = static_cast<uint8_t>(buffer[offset]);
- }
+ arm::pipe::ReadBytes(buffer, offset, valueSize, outValue);
}
uint64_t ReadUint64(const unsigned char* buffer, unsigned int offset)
{
- ARMNN_ASSERT(buffer);
-
- uint64_t value = 0;
- value = static_cast<uint64_t>(buffer[offset]);
- value |= static_cast<uint64_t>(buffer[offset + 1]) << 8;
- value |= static_cast<uint64_t>(buffer[offset + 2]) << 16;
- value |= static_cast<uint64_t>(buffer[offset + 3]) << 24;
- value |= static_cast<uint64_t>(buffer[offset + 4]) << 32;
- value |= static_cast<uint64_t>(buffer[offset + 5]) << 40;
- value |= static_cast<uint64_t>(buffer[offset + 6]) << 48;
- value |= static_cast<uint64_t>(buffer[offset + 7]) << 56;
-
- return value;
+ return arm::pipe::ReadUint64(buffer, offset);
}
uint32_t ReadUint32(const unsigned char* buffer, unsigned int offset)
{
- ARMNN_ASSERT(buffer);
-
- uint32_t value = 0;
- value = static_cast<uint32_t>(buffer[offset]);
- value |= static_cast<uint32_t>(buffer[offset + 1]) << 8;
- value |= static_cast<uint32_t>(buffer[offset + 2]) << 16;
- value |= static_cast<uint32_t>(buffer[offset + 3]) << 24;
- return value;
+ return arm::pipe::ReadUint32(buffer, offset);
}
uint16_t ReadUint16(const unsigned char* buffer, unsigned int offset)
{
- ARMNN_ASSERT(buffer);
-
- uint32_t value = 0;
- value = static_cast<uint32_t>(buffer[offset]);
- value |= static_cast<uint32_t>(buffer[offset + 1]) << 8;
- return static_cast<uint16_t>(value);
+ return arm::pipe::ReadUint16(buffer, offset);
}
uint8_t ReadUint8(const unsigned char* buffer, unsigned int offset)
{
- ARMNN_ASSERT(buffer);
-
- return buffer[offset];
+ return arm::pipe::ReadUint8(buffer, offset);
}
std::string GetSoftwareInfo()
@@ -303,113 +248,6 @@ std::string GetProcessName()
return name;
}
-// Calculate the actual length an SwString will be including the terminating null character
-// padding to bring it to the next uint32_t boundary but minus the leading uint32_t encoding
-// the size to allow the offset to be correctly updated when decoding a binary packet.
-uint32_t CalculateSizeOfPaddedSwString(const std::string& str)
-{
- std::vector<uint32_t> swTraceString;
- StringToSwTraceString<SwTraceCharPolicy>(str, swTraceString);
- unsigned int uint32_t_size = sizeof(uint32_t);
- uint32_t size = (boost::numeric_cast<uint32_t>(swTraceString.size()) - 1) * uint32_t_size;
- return size;
-}
-
-// Read TimelineMessageDirectoryPacket from given IPacketBuffer and offset
-SwTraceMessage ReadSwTraceMessage(const unsigned char* packetBuffer,
- unsigned int& offset,
- const unsigned int& packetLength)
-{
- ARMNN_ASSERT(packetBuffer);
-
- unsigned int uint32_t_size = sizeof(uint32_t);
-
- SwTraceMessage swTraceMessage;
-
- // Read the decl_id
- uint32_t readDeclId = ReadUint32(packetBuffer, offset);
- swTraceMessage.m_Id = readDeclId;
-
- // SWTrace "namestring" format
- // length of the string (first 4 bytes) + string + null terminator
-
- // Check the decl_name
- offset += uint32_t_size;
- uint32_t swTraceDeclNameLength = ReadUint32(packetBuffer, offset);
-
- if (swTraceDeclNameLength == 0 || swTraceDeclNameLength > packetLength)
- {
- throw RuntimeException("Error swTraceDeclNameLength is an invalid size", CHECK_LOCATION());
- }
-
- offset += uint32_t_size;
- std::vector<unsigned char> swTraceStringBuffer(swTraceDeclNameLength - 1);
- std::memcpy(swTraceStringBuffer.data(),
- packetBuffer + offset, swTraceStringBuffer.size());
-
- swTraceMessage.m_Name.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end()); // name
-
- // Check the ui_name
- offset += CalculateSizeOfPaddedSwString(swTraceMessage.m_Name);
- uint32_t swTraceUINameLength = ReadUint32(packetBuffer, offset);
-
- if (swTraceUINameLength == 0 || swTraceUINameLength > packetLength)
- {
- throw RuntimeException("Error swTraceUINameLength is an invalid size", CHECK_LOCATION());
- }
-
- offset += uint32_t_size;
- swTraceStringBuffer.resize(swTraceUINameLength - 1);
- std::memcpy(swTraceStringBuffer.data(),
- packetBuffer + offset, swTraceStringBuffer.size());
-
- swTraceMessage.m_UiName.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end()); // ui_name
-
- // Check arg_types
- offset += CalculateSizeOfPaddedSwString(swTraceMessage.m_UiName);
- uint32_t swTraceArgTypesLength = ReadUint32(packetBuffer, offset);
-
- if (swTraceArgTypesLength == 0 || swTraceArgTypesLength > packetLength)
- {
- throw RuntimeException("Error swTraceArgTypesLength is an invalid size", CHECK_LOCATION());
- }
-
- offset += uint32_t_size;
- swTraceStringBuffer.resize(swTraceArgTypesLength - 1);
- std::memcpy(swTraceStringBuffer.data(),
- packetBuffer + offset, swTraceStringBuffer.size());
-
- swTraceMessage.m_ArgTypes.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end()); // arg_types
-
- std::string swTraceString(swTraceStringBuffer.begin(), swTraceStringBuffer.end());
-
- // Check arg_names
- offset += CalculateSizeOfPaddedSwString(swTraceString);
- uint32_t swTraceArgNamesLength = ReadUint32(packetBuffer, offset);
-
- if (swTraceArgNamesLength == 0 || swTraceArgNamesLength > packetLength)
- {
- throw RuntimeException("Error swTraceArgNamesLength is an invalid size", CHECK_LOCATION());
- }
-
- offset += uint32_t_size;
- swTraceStringBuffer.resize(swTraceArgNamesLength - 1);
- std::memcpy(swTraceStringBuffer.data(),
- packetBuffer + offset, swTraceStringBuffer.size());
-
- swTraceString.assign(swTraceStringBuffer.begin(), swTraceStringBuffer.end());
- std::stringstream stringStream(swTraceString);
- std::string argName;
- while (std::getline(stringStream, argName, ','))
- {
- swTraceMessage.m_ArgNames.push_back(argName);
- }
-
- offset += CalculateSizeOfPaddedSwString(swTraceString);
-
- return swTraceMessage;
-}
-
/// Creates a timeline packet header
///
/// \params
@@ -493,7 +331,7 @@ TimelinePacketStatus WriteTimelineLabelBinaryPacket(uint64_t profilingGuid,
// Convert the label into a SWTrace string
std::vector<uint32_t> swTraceLabel;
- bool result = StringToSwTraceString<SwTraceCharPolicy>(label, swTraceLabel);
+ bool result = arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(label, swTraceLabel);
if (!result)
{
return TimelinePacketStatus::Error;
@@ -712,10 +550,14 @@ TimelinePacketStatus WriteTimelineMessageDirectoryPackage(unsigned char* buffer,
swTraceBuffer.push_back(declId);
bool result = true;
- result &= ConvertDirectoryComponent<SwTraceNameCharPolicy>(directoryComponent[1], swTraceBuffer); // decl_name
- result &= ConvertDirectoryComponent<SwTraceCharPolicy> (directoryComponent[2], swTraceBuffer); // ui_name
- result &= ConvertDirectoryComponent<SwTraceTypeCharPolicy>(directoryComponent[3], swTraceBuffer); // arg_types
- result &= ConvertDirectoryComponent<SwTraceCharPolicy> (directoryComponent[4], swTraceBuffer); // arg_names
+ result &= arm::pipe::ConvertDirectoryComponent<arm::pipe::SwTraceNameCharPolicy>(
+ directoryComponent[1], swTraceBuffer); // decl_name
+ result &= arm::pipe::ConvertDirectoryComponent<arm::pipe::SwTraceCharPolicy> (
+ directoryComponent[2], swTraceBuffer); // ui_name
+ result &= arm::pipe::ConvertDirectoryComponent<arm::pipe::SwTraceTypeCharPolicy>(
+ directoryComponent[3], swTraceBuffer); // arg_types
+ result &= arm::pipe::ConvertDirectoryComponent<arm::pipe::SwTraceCharPolicy> (
+ directoryComponent[4], swTraceBuffer); // arg_names
if (!result)
{
return TimelinePacketStatus::Error;
@@ -884,22 +726,7 @@ TimelinePacketStatus WriteTimelineEventBinary(uint64_t timestamp,
std::string CentreAlignFormatting(const std::string& stringToPass, const int spacingWidth)
{
- std::stringstream outputStream, centrePadding;
- int padding = spacingWidth - static_cast<int>(stringToPass.size());
-
- for (int i = 0; i < padding / 2; ++i)
- {
- centrePadding << " ";
- }
-
- outputStream << centrePadding.str() << stringToPass << centrePadding.str();
-
- if (padding > 0 && padding %2 != 0)
- {
- outputStream << " ";
- }
-
- return outputStream.str();
+ return arm::pipe::CentreAlignFormatting(stringToPass, spacingWidth);
}
void PrintDeviceDetails(const std::pair<const unsigned short, std::unique_ptr<Device>>& devicePair)
@@ -1088,15 +915,15 @@ uint64_t GetTimestamp()
return static_cast<uint64_t>(timestamp.count());
}
-Packet ReceivePacket(const unsigned char* buffer, uint32_t length)
+arm::pipe::Packet ReceivePacket(const unsigned char* buffer, uint32_t length)
{
if (buffer == nullptr)
{
- throw armnnProfiling::ProfilingException("data buffer is nullptr");
+ throw arm::pipe::ProfilingException("data buffer is nullptr");
}
if (length < 8)
{
- throw armnnProfiling::ProfilingException("length of data buffer is less than 8");
+ throw arm::pipe::ProfilingException("length of data buffer is less than 8");
}
uint32_t metadataIdentifier = 0;
@@ -1112,7 +939,7 @@ Packet ReceivePacket(const unsigned char* buffer, uint32_t length)
std::memcpy(packetData.get(), buffer + 8u, dataLength);
}
- return Packet(metadataIdentifier, dataLength, packetData);
+ return arm::pipe::Packet(metadataIdentifier, dataLength, packetData);
}
} // namespace profiling
diff --git a/src/profiling/ProfilingUtils.hpp b/src/profiling/ProfilingUtils.hpp
index 833b73d963..79fa6c7bb0 100644
--- a/src/profiling/ProfilingUtils.hpp
+++ b/src/profiling/ProfilingUtils.hpp
@@ -11,7 +11,7 @@
#include "ICounterDirectory.hpp"
#include "IPacketBuffer.hpp"
-#include <Packet.hpp>
+#include <common/include/Packet.hpp>
#include <boost/numeric/conversion/cast.hpp>
@@ -30,118 +30,6 @@ namespace profiling
constexpr unsigned int ThreadIdSize = sizeof(int); // Is platform dependent
-struct SwTraceHeader
-{
- uint8_t m_StreamVersion;
- uint8_t m_PointerBytes;
- uint8_t m_ThreadIdBytes;
-};
-
-struct SwTraceMessage
-{
- uint32_t m_Id;
- std::string m_Name;
- std::string m_UiName;
- std::vector<char> m_ArgTypes;
- std::vector<std::string> m_ArgNames;
-};
-
-struct SwTraceCharPolicy
-{
- static bool IsValidChar(unsigned char c)
- {
- // Check that the given character has ASCII 7-bit encoding
- return c < 128;
- }
-};
-
-struct SwTraceNameCharPolicy
-{
- static bool IsValidChar(unsigned char c)
- {
- // Check that the given character has ASCII 7-bit encoding, alpha-numeric and underscore only
- return c < 128 && (std::isalnum(c) || c == '_');
- }
-};
-
-struct SwTraceTypeCharPolicy
-{
- static bool IsValidChar(unsigned char c)
- {
- // Check that the given character is among the allowed ones
- switch (c)
- {
- case '@':
- case 't':
- case 'i':
- case 'I':
- case 'l':
- case 'L':
- case 'F':
- case 'p':
- case 's':
- return true; // Valid char
- default:
- return false; // Invalid char
- }
- }
-};
-
-template <typename SwTracePolicy>
-bool IsValidSwTraceString(const std::string& s)
-{
- // Check that all the characters in the given string conform to the given policy
- return std::all_of(s.begin(), s.end(), [](unsigned char c) { return SwTracePolicy::IsValidChar(c); });
-}
-
-template <typename SwTracePolicy>
-bool StringToSwTraceString(const std::string& s, std::vector<uint32_t>& outputBuffer)
-{
- // Converts the given string to an SWTrace "string" (i.e. a string of "chars"), and writes it into
- // the given buffer including the null-terminator. It also pads it to the next uint32_t if necessary
-
- // Clear the output buffer
- outputBuffer.clear();
-
- // Check that the given string is a valid SWTrace "string" (i.e. a string of "chars")
- if (!IsValidSwTraceString<SwTracePolicy>(s))
- {
- return false;
- }
-
- // Prepare the output buffer
- size_t s_size = s.size() + 1; // The size of the string (in chars) plus the null-terminator
- size_t uint32_t_size = sizeof(uint32_t);
- // Output buffer size = StringLength (32 bit) + amount of complete 32bit words that fit into the string
- // + an additional 32bit word if there are remaining chars to complete the string
- // (The rest of the 32bit word is then filled with the NULL terminator)
- size_t outBufferSize = 1 + (s_size / uint32_t_size) + (s_size % uint32_t_size != 0 ? 1 : 0);
- outputBuffer.resize(outBufferSize, '\0');
-
- // Write the SWTrace string to the output buffer
- outputBuffer[0] = boost::numeric_cast<uint32_t>(s_size);
- std::memcpy(outputBuffer.data() + 1, s.data(), s_size);
-
- return true;
-}
-
-template <typename SwTracePolicy,
- typename SwTraceBuffer = std::vector<uint32_t>>
-bool ConvertDirectoryComponent(const std::string& directoryComponent, SwTraceBuffer& swTraceBuffer)
-{
- // Convert the directory component using the given policy
- SwTraceBuffer tempSwTraceBuffer;
- bool result = StringToSwTraceString<SwTracePolicy>(directoryComponent, tempSwTraceBuffer);
- if (!result)
- {
- return false;
- }
-
- swTraceBuffer.insert(swTraceBuffer.end(), tempSwTraceBuffer.begin(), tempSwTraceBuffer.end());
-
- return true;
-}
-
uint16_t GetNextUid(bool peekOnly = false);
std::vector<uint16_t> GetNextCounterUids(uint16_t firstUid, uint16_t cores);
@@ -212,10 +100,6 @@ enum class TimelinePacketStatus
BufferExhaustion
};
-uint32_t CalculateSizeOfPaddedSwString(const std::string& str);
-
-SwTraceMessage ReadSwTraceMessage(const unsigned char*, unsigned int&, const unsigned int& packetLength);
-
TimelinePacketStatus WriteTimelineLabelBinaryPacket(uint64_t profilingGuid,
const std::string& label,
unsigned char* buffer,
@@ -264,7 +148,7 @@ class BufferExhaustion : public armnn::Exception
uint64_t GetTimestamp();
-Packet ReceivePacket(const unsigned char* buffer, uint32_t length);
+arm::pipe::Packet ReceivePacket(const unsigned char* buffer, uint32_t length);
} // namespace profiling
diff --git a/src/profiling/RequestCounterDirectoryCommandHandler.cpp b/src/profiling/RequestCounterDirectoryCommandHandler.cpp
index 5521a25f20..8f78ae63f0 100644
--- a/src/profiling/RequestCounterDirectoryCommandHandler.cpp
+++ b/src/profiling/RequestCounterDirectoryCommandHandler.cpp
@@ -13,7 +13,7 @@ namespace armnn
namespace profiling
{
-void RequestCounterDirectoryCommandHandler::operator()(const Packet& packet)
+void RequestCounterDirectoryCommandHandler::operator()(const arm::pipe::Packet& packet)
{
ProfilingState currentState = m_StateMachine.GetCurrentState();
switch (currentState)
diff --git a/src/profiling/RequestCounterDirectoryCommandHandler.hpp b/src/profiling/RequestCounterDirectoryCommandHandler.hpp
index d8ce881ffb..18577b2851 100644
--- a/src/profiling/RequestCounterDirectoryCommandHandler.hpp
+++ b/src/profiling/RequestCounterDirectoryCommandHandler.hpp
@@ -5,19 +5,20 @@
#pragma once
-#include "CommandHandlerFunctor.hpp"
#include "ISendCounterPacket.hpp"
#include "armnn/profiling/ISendTimelinePacket.hpp"
-#include <Packet.hpp>
#include "ProfilingStateMachine.hpp"
+#include <common/include/CommandHandlerFunctor.hpp>
+#include <common/include/Packet.hpp>
+
namespace armnn
{
namespace profiling
{
-class RequestCounterDirectoryCommandHandler : public CommandHandlerFunctor
+class RequestCounterDirectoryCommandHandler : public arm::pipe::CommandHandlerFunctor
{
public:
@@ -35,7 +36,7 @@ public:
, m_StateMachine(profilingStateMachine)
{}
- void operator()(const Packet& packet) override;
+ void operator()(const arm::pipe::Packet& packet) override;
private:
const ICounterDirectory& m_CounterDirectory;
diff --git a/src/profiling/SendCounterPacket.cpp b/src/profiling/SendCounterPacket.cpp
index 2182ce6d39..79123f0c5e 100644
--- a/src/profiling/SendCounterPacket.cpp
+++ b/src/profiling/SendCounterPacket.cpp
@@ -4,13 +4,14 @@
//
#include "SendCounterPacket.hpp"
-#include "EncodeVersion.hpp"
+#include <common/include/EncodeVersion.hpp>
#include <armnn/Exceptions.hpp>
#include <armnn/Conversion.hpp>
#include <Processes.hpp>
#include <armnn/utility/Assert.hpp>
#include <common/include/Constants.hpp>
+#include <common/include/SwTrace.hpp>
#include <boost/format.hpp>
#include <boost/numeric/conversion/cast.hpp>
@@ -61,19 +62,19 @@ void SendCounterPacket::SendStreamMetaDataPacket()
// Timeline Message Directory (packet_family = 1, packet_class = 0, packet_type = 0) Version 1.0.0
// Timeline Message (packet_family = 1, packet_class = 0, packet_type = 1) Version 1.0.0
std::vector<std::pair<uint32_t, uint32_t>> packetVersions;
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 1), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 2), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 3), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 4), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 5), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 6), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 7), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(3, 0, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 1), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 1), EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 0), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 1), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 2), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 3), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 4), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 5), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 6), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 7), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(3, 0, 0), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 0), arm::pipe::EncodeVersion(1, 0, 0)));
+ 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<uint32_t>(packetVersions.size());
uint32_t packetVersionSize = numeric_cast<uint32_t>(numberOfVersions * 2 * sizeUint32);
@@ -104,9 +105,9 @@ void SendCounterPacket::SendStreamMetaDataPacket()
// Packet body
offset += sizeUint32;
- WriteUint32(writeBuffer, offset, armnnProfiling::PIPE_MAGIC); // pipe_magic
+ WriteUint32(writeBuffer, offset, arm::pipe::PIPE_MAGIC); // pipe_magic
offset += sizeUint32;
- WriteUint32(writeBuffer, offset, EncodeVersion(1, 0, 0)); // stream_metadata_version
+ WriteUint32(writeBuffer, offset, arm::pipe::EncodeVersion(1, 0, 0)); // stream_metadata_version
offset += sizeUint32;
WriteUint32(writeBuffer, offset, MAX_METADATA_PACKET_LENGTH); // max_data_length
offset += sizeUint32;
@@ -213,7 +214,7 @@ bool SendCounterPacket::CreateCategoryRecord(const CategoryPtr& category,
// Convert the device name into a SWTrace namestring
std::vector<uint32_t> categoryNameBuffer;
- if (!StringToSwTraceString<SwTraceNameCharPolicy>(categoryName, categoryNameBuffer))
+ if (!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>(categoryName, categoryNameBuffer))
{
errorMessage = boost::str(boost::format("Cannot convert the name of category (%1%) to an SWTrace namestring")
% categoryName);
@@ -318,7 +319,7 @@ bool SendCounterPacket::CreateDeviceRecord(const DevicePtr& device,
// Convert the device name into a SWTrace string
std::vector<uint32_t> deviceNameBuffer;
- if (!StringToSwTraceString<SwTraceCharPolicy>(deviceName, deviceNameBuffer))
+ if (!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(deviceName, deviceNameBuffer))
{
errorMessage = boost::str(boost::format("Cannot convert the name of device %1% (%2%) to an SWTrace string")
% deviceUid
@@ -368,7 +369,7 @@ bool SendCounterPacket::CreateCounterSetRecord(const CounterSetPtr& counterSet,
// Convert the device name into a SWTrace namestring
std::vector<uint32_t> counterSetNameBuffer;
- if (!StringToSwTraceString<SwTraceNameCharPolicy>(counterSet->m_Name, counterSetNameBuffer))
+ if (!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>(counterSet->m_Name, counterSetNameBuffer))
{
errorMessage = boost::str(boost::format("Cannot convert the name of counter set %1% (%2%) to "
"an SWTrace namestring")
@@ -465,7 +466,7 @@ bool SendCounterPacket::CreateEventRecord(const CounterPtr& counter,
// Convert the counter name into a SWTrace string
std::vector<uint32_t> counterNameBuffer;
- if (!StringToSwTraceString<SwTraceCharPolicy>(counterName, counterNameBuffer))
+ if (!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(counterName, counterNameBuffer))
{
errorMessage = boost::str(boost::format("Cannot convert the name of counter %1% (name: %2%) "
"to an SWTrace string")
@@ -482,7 +483,7 @@ bool SendCounterPacket::CreateEventRecord(const CounterPtr& counter,
// Convert the counter description into a SWTrace string
std::vector<uint32_t> counterDescriptionBuffer;
- if (!StringToSwTraceString<SwTraceCharPolicy>(counterDescription, counterDescriptionBuffer))
+ if (!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(counterDescription, counterDescriptionBuffer))
{
errorMessage = boost::str(boost::format("Cannot convert the description of counter %1% (description: %2%) "
"to an SWTrace string")
@@ -507,7 +508,7 @@ bool SendCounterPacket::CreateEventRecord(const CounterPtr& counter,
if (includeUnits)
{
// Convert the counter units into a SWTrace namestring
- if (!StringToSwTraceString<SwTraceNameCharPolicy>(counterUnits, counterUnitsBuffer))
+ if (!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>(counterUnits, counterUnitsBuffer))
{
errorMessage = boost::str(boost::format("Cannot convert the units of counter %1% (units: %2%) "
"to an SWTrace string")
diff --git a/src/profiling/SendThread.cpp b/src/profiling/SendThread.cpp
index 5962f2fc5d..86e6c05a02 100644
--- a/src/profiling/SendThread.cpp
+++ b/src/profiling/SendThread.cpp
@@ -1,10 +1,9 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "SendThread.hpp"
-#include "EncodeVersion.hpp"
#include "ProfilingUtils.hpp"
#include <armnn/Exceptions.hpp>
@@ -25,7 +24,9 @@ namespace profiling
using boost::numeric_cast;
SendThread::SendThread(armnn::profiling::ProfilingStateMachine& profilingStateMachine,
- armnn::profiling::IBufferManager& buffer, armnn::profiling::ISendCounterPacket& sendCounterPacket, int timeout)
+ armnn::profiling::IBufferManager& buffer,
+ armnn::profiling::ISendCounterPacket& sendCounterPacket,
+ int timeout)
: m_StateMachine(profilingStateMachine)
, m_BufferManager(buffer)
, m_SendCounterPacket(sendCounterPacket)
diff --git a/src/profiling/SocketProfilingConnection.cpp b/src/profiling/SocketProfilingConnection.cpp
index c231045b10..9de425b62c 100644
--- a/src/profiling/SocketProfilingConnection.cpp
+++ b/src/profiling/SocketProfilingConnection.cpp
@@ -11,7 +11,6 @@
#include <fcntl.h>
#include <string>
-using namespace armnnUtils;
namespace armnn
{
@@ -20,13 +19,13 @@ namespace profiling
SocketProfilingConnection::SocketProfilingConnection()
{
- Sockets::Initialize();
+ arm::pipe::Initialize();
memset(m_Socket, 0, sizeof(m_Socket));
// Note: we're using Linux specific SOCK_CLOEXEC flag.
m_Socket[0].fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (m_Socket[0].fd == -1)
{
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Socket construction failed: ") + strerror(errno),
m_Socket[0].fd,
errno);
@@ -41,7 +40,7 @@ SocketProfilingConnection::SocketProfilingConnection()
if (0 != connect(m_Socket[0].fd, reinterpret_cast<const sockaddr*>(&server), sizeof(sockaddr_un)))
{
Close();
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Cannot connect to stream socket: ") + strerror(errno),
m_Socket[0].fd,
errno);
@@ -51,10 +50,10 @@ SocketProfilingConnection::SocketProfilingConnection()
m_Socket[0].events = POLLIN;
// Make the socket non blocking.
- if (!Sockets::SetNonBlocking(m_Socket[0].fd))
+ if (!arm::pipe::SetNonBlocking(m_Socket[0].fd))
{
Close();
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Failed to set socket as non blocking: ") + strerror(errno),
m_Socket[0].fd,
errno);
@@ -68,9 +67,9 @@ bool SocketProfilingConnection::IsOpen() const
void SocketProfilingConnection::Close()
{
- if (Sockets::Close(m_Socket[0].fd) != 0)
+ if (arm::pipe::Close(m_Socket[0].fd) != 0)
{
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Cannot close stream socket: ") + strerror(errno),
m_Socket[0].fd,
errno);
@@ -86,14 +85,14 @@ bool SocketProfilingConnection::WritePacket(const unsigned char* buffer, uint32_
return false;
}
- return Sockets::Write(m_Socket[0].fd, buffer, length) != -1;
+ return arm::pipe::Write(m_Socket[0].fd, buffer, length) != -1;
}
-Packet SocketProfilingConnection::ReadPacket(uint32_t timeout)
+arm::pipe::Packet SocketProfilingConnection::ReadPacket(uint32_t timeout)
{
// Is there currently at least a header worth of data waiting to be read?
int bytes_available = 0;
- Sockets::Ioctl(m_Socket[0].fd, FIONREAD, &bytes_available);
+ arm::pipe::Ioctl(m_Socket[0].fd, FIONREAD, &bytes_available);
if (bytes_available >= 8)
{
// Yes there is. Read it:
@@ -101,18 +100,18 @@ Packet SocketProfilingConnection::ReadPacket(uint32_t timeout)
}
// Poll for data on the socket or until timeout occurs
- int pollResult = Sockets::Poll(&m_Socket[0], 1, static_cast<int>(timeout));
+ int pollResult = arm::pipe::Poll(&m_Socket[0], 1, static_cast<int>(timeout));
switch (pollResult)
{
case -1: // Error
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Error occured while reading from socket: ") + strerror(errno),
m_Socket[0].fd,
errno);
case 0: // Timeout
- throw TimeoutException("SocketProfilingConnection: Timeout while reading from socket");
+ throw arm::pipe::TimeoutException("SocketProfilingConnection: Timeout while reading from socket");
default: // Normal poll return but it could still contain an error signal
// Check if the socket reported an error
@@ -122,13 +121,13 @@ Packet SocketProfilingConnection::ReadPacket(uint32_t timeout)
{
// This is an unrecoverable error.
Close();
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Error occured while polling receiving socket: POLLNVAL."),
m_Socket[0].fd);
}
if (m_Socket[0].revents == POLLERR)
{
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string(
"SocketProfilingConnection: Error occured while polling receiving socket: POLLERR: ")
+ strerror(errno),
@@ -139,7 +138,7 @@ Packet SocketProfilingConnection::ReadPacket(uint32_t timeout)
{
// This is an unrecoverable error.
Close();
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Connection closed by remote client: POLLHUP."),
m_Socket[0].fd);
}
@@ -158,30 +157,30 @@ Packet SocketProfilingConnection::ReadPacket(uint32_t timeout)
}
}
-Packet SocketProfilingConnection::ReceivePacket()
+arm::pipe::Packet SocketProfilingConnection::ReceivePacket()
{
char header[8] = {};
- long receiveResult = Sockets::Read(m_Socket[0].fd, &header, sizeof(header));
+ long receiveResult = arm::pipe::Read(m_Socket[0].fd, &header, sizeof(header));
// We expect 8 as the result here. 0 means EOF, socket is closed. -1 means there been some other kind of error.
switch( receiveResult )
{
case 0:
// Socket has closed.
Close();
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Remote socket has closed the connection."),
m_Socket[0].fd);
case -1:
// There's been a socket error. We will presume it's unrecoverable.
Close();
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Error occured while reading the packet: ") + strerror(errno),
m_Socket[0].fd,
errno);
default:
if (receiveResult < 8)
{
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string(
"SocketProfilingConnection: The received packet did not contains a valid PIPE header."),
m_Socket[0].fd);
@@ -201,10 +200,10 @@ Packet SocketProfilingConnection::ReceivePacket()
if (dataLength > 0)
{
packetData = std::make_unique<unsigned char[]>(dataLength);
- long receivedLength = Sockets::Read(m_Socket[0].fd, packetData.get(), dataLength);
+ long receivedLength = arm::pipe::Read(m_Socket[0].fd, packetData.get(), dataLength);
if (receivedLength < 0)
{
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Error occured while reading the packet: ") + strerror(errno),
m_Socket[0].fd,
errno);
@@ -212,13 +211,13 @@ Packet SocketProfilingConnection::ReceivePacket()
if (dataLength != static_cast<uint32_t>(receivedLength))
{
// What do we do here if we can't read in a full packet?
- throw armnnProfiling::SocketConnectionException(
+ throw arm::pipe::SocketConnectionException(
std::string("SocketProfilingConnection: Invalid PIPE packet."),
m_Socket[0].fd);
}
}
- return Packet(metadataIdentifier, dataLength, packetData);
+ return arm::pipe::Packet(metadataIdentifier, dataLength, packetData);
}
} // namespace profiling
diff --git a/src/profiling/SocketProfilingConnection.hpp b/src/profiling/SocketProfilingConnection.hpp
index a646c03d9c..8d9cb20935 100644
--- a/src/profiling/SocketProfilingConnection.hpp
+++ b/src/profiling/SocketProfilingConnection.hpp
@@ -22,12 +22,12 @@ public:
bool IsOpen() const final;
void Close() final;
bool WritePacket(const unsigned char* buffer, uint32_t length) final;
- Packet ReadPacket(uint32_t timeout) final;
+ arm::pipe::Packet ReadPacket(uint32_t timeout) final;
private:
// Read a full packet from the socket.
- Packet ReceivePacket();
+ arm::pipe::Packet ReceivePacket();
#ifndef __APPLE__
// To indicate we want to use an abstract UDS ensure the first character of the address is 0.
@@ -36,7 +36,7 @@ private:
// MACOSX does not support abstract UDS
const char* m_GatorNamespace = "/tmp/gatord_namespace";
#endif
- armnnUtils::Sockets::PollFd m_Socket[1]{};
+ arm::pipe::PollFd m_Socket[1]{};
};
} // namespace profiling
diff --git a/src/profiling/test/BufferTests.cpp b/src/profiling/test/BufferTests.cpp
index 804335138d..7a92ee19e5 100644
--- a/src/profiling/test/BufferTests.cpp
+++ b/src/profiling/test/BufferTests.cpp
@@ -7,6 +7,8 @@
#include "PacketBuffer.hpp"
#include "ProfilingUtils.hpp"
+#include <common/include/SwTrace.hpp>
+
#include <armnn/Exceptions.hpp>
#include <boost/test/unit_test.hpp>
@@ -380,8 +382,8 @@ BOOST_AUTO_TEST_CASE(ReadSwTraceMessageExceptionTest0)
unsigned int uint32_t_size = sizeof(uint32_t);
unsigned int offset = uint32_t_size;
- BOOST_CHECK_THROW(ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()),
- armnn::RuntimeException);
+ BOOST_CHECK_THROW(arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()),
+ arm::pipe::ProfilingException);
}
@@ -402,8 +404,8 @@ BOOST_AUTO_TEST_CASE(ReadSwTraceMessageExceptionTest1)
unsigned int uint32_t_size = sizeof(uint32_t);
unsigned int offset = uint32_t_size;
- BOOST_CHECK_THROW(ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()),
- armnn::RuntimeException);
+ BOOST_CHECK_THROW(arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize()),
+ arm::pipe::ProfilingException);
}
diff --git a/src/profiling/test/PrintPacketHeaderHandler.cpp b/src/profiling/test/PrintPacketHeaderHandler.cpp
index 24095d8250..f85a7b1fcb 100644
--- a/src/profiling/test/PrintPacketHeaderHandler.cpp
+++ b/src/profiling/test/PrintPacketHeaderHandler.cpp
@@ -1,11 +1,12 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "PrintPacketHeaderHandler.hpp"
#include <iostream>
+#include <sstream>
namespace armnn
{
@@ -18,7 +19,7 @@ std::vector<uint32_t> PrintPacketHeaderHandler::GetHeadersAccepted()
return std::vector<uint32_t>();
}
-void PrintPacketHeaderHandler::HandlePacket(const Packet& packet)
+void PrintPacketHeaderHandler::HandlePacket(const arm::pipe::Packet& packet)
{
std::stringstream ss;
ss << "Handler Received Outgoing Packet [" << packet.GetPacketFamily() << ":" << packet.GetPacketId() << "]";
diff --git a/src/profiling/test/PrintPacketHeaderHandler.hpp b/src/profiling/test/PrintPacketHeaderHandler.hpp
index 6564f3cea5..397da0b8ea 100644
--- a/src/profiling/test/PrintPacketHeaderHandler.hpp
+++ b/src/profiling/test/PrintPacketHeaderHandler.hpp
@@ -1,12 +1,13 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include <armnn/profiling/ILocalPacketHandler.hpp>
-#include <Packet.hpp>
+
+#include <common/include/Packet.hpp>
namespace armnn
{
@@ -18,7 +19,7 @@ class PrintPacketHeaderHandler : public ILocalPacketHandler
{
virtual std::vector<uint32_t> GetHeadersAccepted();
- virtual void HandlePacket(const Packet& packet);
+ virtual void HandlePacket(const arm::pipe::Packet& packet);
};
} // namespace profiling
diff --git a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
index 6784ddabcb..d6700bc41a 100644
--- a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
+++ b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -32,7 +32,7 @@ public:
{
// populate packet data and construct packet
std::memcpy(m_PacketData.get(), g_DataPtr, g_DataLength);
- m_Packet = std::make_unique<Packet>(0u, g_DataLength, m_PacketData);
+ m_Packet = std::make_unique<arm::pipe::Packet>(0u, g_DataLength, m_PacketData);
}
~DummyProfilingConnection() = default;
@@ -54,7 +54,7 @@ public:
return true;
}
- Packet ReadPacket(uint32_t timeout) override
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override
{
armnn::IgnoreUnused(timeout);
return std::move(*m_Packet);
@@ -63,7 +63,7 @@ public:
private:
bool m_Open;
std::unique_ptr<unsigned char[]> m_PacketData;
- std::unique_ptr<Packet> m_Packet;
+ std::unique_ptr<arm::pipe::Packet> m_Packet;
};
std::vector<char> ReadDumpFile(const std::string& dumpFileName)
@@ -105,8 +105,8 @@ BOOST_AUTO_TEST_CASE(DumpIncomingValidFile)
ProfilingConnectionDumpToFileDecorator decorator(std::make_unique<DummyProfilingConnection>(), options, false);
// NOTE: unique_ptr is needed here because operator=() is deleted for Packet
- std::unique_ptr<Packet> packet;
- BOOST_CHECK_NO_THROW(packet = std::make_unique<Packet>(decorator.ReadPacket(0)));
+ std::unique_ptr<arm::pipe::Packet> packet;
+ BOOST_CHECK_NO_THROW(packet = std::make_unique<arm::pipe::Packet>(decorator.ReadPacket(0)));
decorator.Close();
diff --git a/src/profiling/test/ProfilingMocks.hpp b/src/profiling/test/ProfilingMocks.hpp
index e4f71f932c..8bcf27a8d1 100644
--- a/src/profiling/test/ProfilingMocks.hpp
+++ b/src/profiling/test/ProfilingMocks.hpp
@@ -121,7 +121,7 @@ public:
}
}
- bool WritePacket(Packet&& packet)
+ bool WritePacket(arm::pipe::Packet&& packet)
{
std::lock_guard<std::mutex> lock(m_Mutex);
@@ -129,7 +129,7 @@ public:
return true;
}
- Packet ReadPacket(uint32_t timeout) override
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override
{
IgnoreUnused(timeout);
@@ -156,7 +156,7 @@ public:
private:
bool m_IsOpen;
std::vector<std::pair<PacketType, uint32_t>> m_WrittenData;
- Packet m_Packet;
+ arm::pipe::Packet m_Packet;
mutable std::mutex m_Mutex;
};
diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp
index bc16bb952b..f616442df0 100644
--- a/src/profiling/test/ProfilingTests.cpp
+++ b/src/profiling/test/ProfilingTests.cpp
@@ -7,18 +7,15 @@
#include "ProfilingTestUtils.hpp"
#include <backends/BackendProfiling.hpp>
+#include <common/include/EncodeVersion.hpp>
+#include <common/include/PacketVersionResolver.hpp>
+#include <common/include/SwTrace.hpp>
#include <CommandHandler.hpp>
-#include <CommandHandlerKey.hpp>
-#include <CommandHandlerRegistry.hpp>
-#include <common/include/SocketConnectionException.hpp>
#include <ConnectionAcknowledgedCommandHandler.hpp>
#include <CounterDirectory.hpp>
#include <CounterIdMap.hpp>
-#include <EncodeVersion.hpp>
#include <Holder.hpp>
#include <ICounterValues.hpp>
-#include <Packet.hpp>
-#include <PacketVersionResolver.hpp>
#include <PeriodicCounterCapture.hpp>
#include <PeriodicCounterSelectionCommandHandler.hpp>
#include <ProfilingStateMachine.hpp>
@@ -37,6 +34,11 @@
#include <armnn/Utils.hpp>
#include <armnn/utility/IgnoreUnused.hpp>
+#include <common/include/CommandHandlerKey.hpp>
+#include <common/include/CommandHandlerRegistry.hpp>
+#include <common/include/SocketConnectionException.hpp>
+#include <common/include/Packet.hpp>
+
#include <boost/numeric/conversion/cast.hpp>
#include <cstdint>
@@ -54,16 +56,16 @@ BOOST_AUTO_TEST_SUITE(ExternalProfiling)
BOOST_AUTO_TEST_CASE(CheckCommandHandlerKeyComparisons)
{
- CommandHandlerKey testKey1_0(1, 1, 1);
- CommandHandlerKey testKey1_1(1, 1, 1);
- CommandHandlerKey testKey1_2(1, 2, 1);
+ arm::pipe::CommandHandlerKey testKey1_0(1, 1, 1);
+ arm::pipe::CommandHandlerKey testKey1_1(1, 1, 1);
+ arm::pipe::CommandHandlerKey testKey1_2(1, 2, 1);
- CommandHandlerKey testKey0(0, 1, 1);
- CommandHandlerKey testKey1(0, 1, 1);
- CommandHandlerKey testKey2(0, 1, 1);
- CommandHandlerKey testKey3(0, 0, 0);
- CommandHandlerKey testKey4(0, 2, 2);
- CommandHandlerKey testKey5(0, 0, 2);
+ arm::pipe::CommandHandlerKey testKey0(0, 1, 1);
+ arm::pipe::CommandHandlerKey testKey1(0, 1, 1);
+ arm::pipe::CommandHandlerKey testKey2(0, 1, 1);
+ arm::pipe::CommandHandlerKey testKey3(0, 0, 0);
+ arm::pipe::CommandHandlerKey testKey4(0, 2, 2);
+ arm::pipe::CommandHandlerKey testKey5(0, 0, 2);
BOOST_CHECK(testKey1_0 > testKey0);
BOOST_CHECK(testKey1_0 == testKey1_1);
@@ -88,30 +90,32 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerKeyComparisons)
BOOST_CHECK(testKey1.GetPacketId() == 1);
BOOST_CHECK(testKey1.GetVersion() == 1);
- std::vector<CommandHandlerKey> vect = { CommandHandlerKey(0, 0, 1), CommandHandlerKey(0, 2, 0),
- CommandHandlerKey(0, 1, 0), CommandHandlerKey(0, 2, 1),
- CommandHandlerKey(0, 1, 1), CommandHandlerKey(0, 0, 1),
- CommandHandlerKey(0, 2, 0), CommandHandlerKey(0, 0, 0) };
+ std::vector<arm::pipe::CommandHandlerKey> vect = {
+ arm::pipe::CommandHandlerKey(0, 0, 1), arm::pipe::CommandHandlerKey(0, 2, 0),
+ arm::pipe::CommandHandlerKey(0, 1, 0), arm::pipe::CommandHandlerKey(0, 2, 1),
+ arm::pipe::CommandHandlerKey(0, 1, 1), arm::pipe::CommandHandlerKey(0, 0, 1),
+ arm::pipe::CommandHandlerKey(0, 2, 0), arm::pipe::CommandHandlerKey(0, 0, 0) };
std::sort(vect.begin(), vect.end());
- std::vector<CommandHandlerKey> expectedVect = { CommandHandlerKey(0, 0, 0), CommandHandlerKey(0, 0, 1),
- CommandHandlerKey(0, 0, 1), CommandHandlerKey(0, 1, 0),
- CommandHandlerKey(0, 1, 1), CommandHandlerKey(0, 2, 0),
- CommandHandlerKey(0, 2, 0), CommandHandlerKey(0, 2, 1) };
+ std::vector<arm::pipe::CommandHandlerKey> expectedVect = {
+ arm::pipe::CommandHandlerKey(0, 0, 0), arm::pipe::CommandHandlerKey(0, 0, 1),
+ arm::pipe::CommandHandlerKey(0, 0, 1), arm::pipe::CommandHandlerKey(0, 1, 0),
+ arm::pipe::CommandHandlerKey(0, 1, 1), arm::pipe::CommandHandlerKey(0, 2, 0),
+ arm::pipe::CommandHandlerKey(0, 2, 0), arm::pipe::CommandHandlerKey(0, 2, 1) };
BOOST_CHECK(vect == expectedVect);
}
BOOST_AUTO_TEST_CASE(CheckPacketKeyComparisons)
{
- PacketKey key0(0, 0);
- PacketKey key1(0, 0);
- PacketKey key2(0, 1);
- PacketKey key3(0, 2);
- PacketKey key4(1, 0);
- PacketKey key5(1, 0);
- PacketKey key6(1, 1);
+ arm::pipe::PacketKey key0(0, 0);
+ arm::pipe::PacketKey key1(0, 0);
+ arm::pipe::PacketKey key2(0, 1);
+ arm::pipe::PacketKey key3(0, 2);
+ arm::pipe::PacketKey key4(1, 0);
+ arm::pipe::PacketKey key5(1, 0);
+ arm::pipe::PacketKey key6(1, 1);
BOOST_CHECK(!(key0 < key1));
BOOST_CHECK(!(key0 > key1));
@@ -130,7 +134,7 @@ BOOST_AUTO_TEST_CASE(CheckPacketKeyComparisons)
BOOST_AUTO_TEST_CASE(CheckCommandHandler)
{
- PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
ProfilingStateMachine profilingStateMachine;
TestProfilingConnectionBase testProfilingConnectionBase;
@@ -147,7 +151,7 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandler)
sendCounterPacket, sendTimelinePacket,
profilingStateMachine,
mockProfilingServiceStatus);
- CommandHandlerRegistry commandHandlerRegistry;
+ arm::pipe::CommandHandlerRegistry commandHandlerRegistry;
commandHandlerRegistry.RegisterFunctor(&connectionAcknowledgedCommandHandler);
@@ -260,31 +264,31 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandler)
BOOST_AUTO_TEST_CASE(CheckEncodeVersion)
{
- Version version1(12);
+ arm::pipe::Version version1(12);
BOOST_CHECK(version1.GetMajor() == 0);
BOOST_CHECK(version1.GetMinor() == 0);
BOOST_CHECK(version1.GetPatch() == 12);
- Version version2(4108);
+ arm::pipe::Version version2(4108);
BOOST_CHECK(version2.GetMajor() == 0);
BOOST_CHECK(version2.GetMinor() == 1);
BOOST_CHECK(version2.GetPatch() == 12);
- Version version3(4198412);
+ arm::pipe::Version version3(4198412);
BOOST_CHECK(version3.GetMajor() == 1);
BOOST_CHECK(version3.GetMinor() == 1);
BOOST_CHECK(version3.GetPatch() == 12);
- Version version4(0);
+ arm::pipe::Version version4(0);
BOOST_CHECK(version4.GetMajor() == 0);
BOOST_CHECK(version4.GetMinor() == 0);
BOOST_CHECK(version4.GetPatch() == 0);
- Version version5(1, 0, 0);
+ arm::pipe::Version version5(1, 0, 0);
BOOST_CHECK(version5.GetEncodedValue() == 4194304);
}
@@ -295,7 +299,7 @@ BOOST_AUTO_TEST_CASE(CheckPacketClass)
std::unique_ptr<unsigned char[]> packetData1 = std::make_unique<unsigned char[]>(0);
std::unique_ptr<unsigned char[]> nullPacketData;
- Packet packetTest0(472580096, length, packetData0);
+ arm::pipe::Packet packetTest0(472580096, length, packetData0);
BOOST_CHECK(packetTest0.GetHeader() == 472580096);
BOOST_CHECK(packetTest0.GetPacketFamily() == 7);
@@ -304,15 +308,15 @@ BOOST_AUTO_TEST_CASE(CheckPacketClass)
BOOST_CHECK(packetTest0.GetPacketType() == 3);
BOOST_CHECK(packetTest0.GetPacketClass() == 5);
- BOOST_CHECK_THROW(Packet packetTest1(472580096, 0, packetData1), armnn::Exception);
- BOOST_CHECK_NO_THROW(Packet packetTest2(472580096, 0, nullPacketData));
+ BOOST_CHECK_THROW(arm::pipe::Packet packetTest1(472580096, 0, packetData1), arm::pipe::InvalidArgumentException);
+ BOOST_CHECK_NO_THROW(arm::pipe::Packet packetTest2(472580096, 0, nullPacketData));
- Packet packetTest3(472580096, 0, nullPacketData);
+ arm::pipe::Packet packetTest3(472580096, 0, nullPacketData);
BOOST_CHECK(packetTest3.GetLength() == 0);
BOOST_CHECK(packetTest3.GetData() == nullptr);
const unsigned char* packetTest0Data = packetTest0.GetData();
- Packet packetTest4(std::move(packetTest0));
+ arm::pipe::Packet packetTest4(std::move(packetTest0));
BOOST_CHECK(packetTest0.GetData() == nullptr);
BOOST_CHECK(packetTest4.GetData() == packetTest0Data);
@@ -334,12 +338,15 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerFunctor)
TestFunctorB testFunctorB(8, 963, version);
TestFunctorC testFunctorC(5, 983, version);
- CommandHandlerKey keyA(testFunctorA.GetFamilyId(), testFunctorA.GetPacketId(), testFunctorA.GetVersion());
- CommandHandlerKey keyB(testFunctorB.GetFamilyId(), testFunctorB.GetPacketId(), testFunctorB.GetVersion());
- CommandHandlerKey keyC(testFunctorC.GetFamilyId(), testFunctorC.GetPacketId(), testFunctorC.GetVersion());
+ arm::pipe::CommandHandlerKey keyA(
+ testFunctorA.GetFamilyId(), testFunctorA.GetPacketId(), testFunctorA.GetVersion());
+ arm::pipe::CommandHandlerKey keyB(
+ testFunctorB.GetFamilyId(), testFunctorB.GetPacketId(), testFunctorB.GetVersion());
+ arm::pipe::CommandHandlerKey keyC(
+ testFunctorC.GetFamilyId(), testFunctorC.GetPacketId(), testFunctorC.GetVersion());
// Create the unwrapped map to simulate the Command Handler Registry
- std::map<CommandHandlerKey, CommandHandlerFunctor*> registry;
+ std::map<arm::pipe::CommandHandlerKey, arm::pipe::CommandHandlerFunctor*> registry;
registry.insert(std::make_pair(keyB, &testFunctorB));
registry.insert(std::make_pair(keyA, &testFunctorA));
@@ -357,22 +364,25 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerFunctor)
std::unique_ptr<unsigned char[]> packetDataB;
std::unique_ptr<unsigned char[]> packetDataC;
- Packet packetA(500000000, 0, packetDataA);
- Packet packetB(600000000, 0, packetDataB);
- Packet packetC(400000000, 0, packetDataC);
+ arm::pipe::Packet packetA(500000000, 0, packetDataA);
+ arm::pipe::Packet packetB(600000000, 0, packetDataB);
+ arm::pipe::Packet packetC(400000000, 0, packetDataC);
// Check the correct operator of derived class is called
- registry.at(CommandHandlerKey(packetA.GetPacketFamily(), packetA.GetPacketId(), version))->operator()(packetA);
+ registry.at(arm::pipe::CommandHandlerKey(
+ packetA.GetPacketFamily(), packetA.GetPacketId(), version))->operator()(packetA);
BOOST_CHECK(testFunctorA.GetCount() == 1);
BOOST_CHECK(testFunctorB.GetCount() == 0);
BOOST_CHECK(testFunctorC.GetCount() == 0);
- registry.at(CommandHandlerKey(packetB.GetPacketFamily(), packetB.GetPacketId(), version))->operator()(packetB);
+ registry.at(arm::pipe::CommandHandlerKey(
+ packetB.GetPacketFamily(), packetB.GetPacketId(), version))->operator()(packetB);
BOOST_CHECK(testFunctorA.GetCount() == 1);
BOOST_CHECK(testFunctorB.GetCount() == 1);
BOOST_CHECK(testFunctorC.GetCount() == 0);
- registry.at(CommandHandlerKey(packetC.GetPacketFamily(), packetC.GetPacketId(), version))->operator()(packetC);
+ registry.at(arm::pipe::CommandHandlerKey(
+ packetC.GetPacketFamily(), packetC.GetPacketId(), version))->operator()(packetC);
BOOST_CHECK(testFunctorA.GetCount() == 1);
BOOST_CHECK(testFunctorB.GetCount() == 1);
BOOST_CHECK(testFunctorC.GetCount() == 1);
@@ -388,7 +398,7 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerRegistry)
TestFunctorC testFunctorC(5, 983, version);
// Create the Command Handler Registry
- CommandHandlerRegistry registry;
+ arm::pipe::CommandHandlerRegistry registry;
// Register multiple different derived classes
registry.RegisterFunctor(&testFunctorA);
@@ -399,9 +409,9 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerRegistry)
std::unique_ptr<unsigned char[]> packetDataB;
std::unique_ptr<unsigned char[]> packetDataC;
- Packet packetA(500000000, 0, packetDataA);
- Packet packetB(600000000, 0, packetDataB);
- Packet packetC(400000000, 0, packetDataC);
+ arm::pipe::Packet packetA(500000000, 0, packetDataA);
+ arm::pipe::Packet packetB(600000000, 0, packetDataB);
+ arm::pipe::Packet packetC(400000000, 0, packetDataC);
// Check the correct operator of derived class is called
registry.GetFunctor(packetA.GetPacketFamily(), packetA.GetPacketId(), version)->operator()(packetA);
@@ -427,7 +437,7 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerRegistry)
BOOST_CHECK(testFunctorC.GetCount() == 2);
// Check that non-existent key returns nullptr for its functor
- BOOST_CHECK_THROW(registry.GetFunctor(0, 0, 0), armnn::Exception);
+ BOOST_CHECK_THROW(registry.GetFunctor(0, 0, 0), arm::pipe::ProfilingException);
}
BOOST_AUTO_TEST_CASE(CheckPacketVersionResolver)
@@ -439,9 +449,9 @@ BOOST_AUTO_TEST_CASE(CheckPacketVersionResolver)
std::numeric_limits<uint32_t>::max());
// NOTE: Expected version is always 1.0.0, regardless of packetId
- const Version expectedVersion(1, 0, 0);
+ const arm::pipe::Version expectedVersion(1, 0, 0);
- PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
constexpr unsigned int numTests = 10u;
@@ -449,7 +459,7 @@ BOOST_AUTO_TEST_CASE(CheckPacketVersionResolver)
{
const uint32_t familyId = distribution(generator);
const uint32_t packetId = distribution(generator);
- Version resolvedVersion = packetVersionResolver.ResolvePacketVersion(familyId, packetId);
+ arm::pipe::Version resolvedVersion = packetVersionResolver.ResolvePacketVersion(familyId, packetId);
BOOST_TEST(resolvedVersion == expectedVersion);
}
@@ -1407,16 +1417,16 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
// Register a counter with a valid parent category name and not associated with a device
const Counter* counterWoDevice = nullptr;
BOOST_CHECK_NO_THROW(counterWoDevice = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID,
- 26,
- categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 3",
- "valid description",
- armnn::EmptyOptional(),// Units
- armnn::EmptyOptional(),// Number of cores
- 0)); // Device UID
+ 26,
+ categoryName,
+ 0,
+ 1,
+ 123.45f,
+ "valid name 3",
+ "valid description",
+ armnn::EmptyOptional(),// Units
+ armnn::EmptyOptional(),// Number of cores
+ 0)); // Device UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 3);
BOOST_CHECK(counterWoDevice);
BOOST_CHECK(counterWoDevice->m_Uid > counter->m_Uid);
@@ -1468,9 +1478,9 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
123.45f,
"valid name 5",
std::string("valid description"),
- armnn::EmptyOptional(), // Units
- armnn::EmptyOptional(), // Number of cores
- device->m_Uid)); // Device UID
+ armnn::EmptyOptional(), // Units
+ armnn::EmptyOptional(), // Number of cores
+ device->m_Uid)); // Device UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 4);
BOOST_CHECK(counterWDevice);
BOOST_CHECK(counterWDevice->m_Uid > counter->m_Uid);
@@ -1499,7 +1509,7 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
armnn::EmptyOptional(),// Units
armnn::EmptyOptional(),// No of cores
armnn::EmptyOptional(),// Device UID
- 0)); // CounterSet UID
+ 0)); // CounterSet UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 5);
BOOST_CHECK(counterWoCounterSet);
BOOST_CHECK(counterWoCounterSet->m_Uid > counter->m_Uid);
@@ -1615,18 +1625,19 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
const Counter* counterWMultiCoreDeviceWParentCategory = nullptr;
uint16_t numberOfCourse = multiCoreDeviceWParentCategory->m_Cores;
BOOST_CHECK_NO_THROW(counterWMultiCoreDeviceWParentCategory =
- counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID,
- 100,
- categoryName,
- 0,
- 1,
- 123.45f,
- "valid name 10",
- "valid description",
- armnn::EmptyOptional(), // Units
- numberOfCourse, // Number of cores
- armnn::EmptyOptional(), // Device UID
- armnn::EmptyOptional()));// Counter set UID
+ counterDirectory.RegisterCounter(
+ armnn::profiling::BACKEND_ID,
+ 100,
+ categoryName,
+ 0,
+ 1,
+ 123.45f,
+ "valid name 10",
+ "valid description",
+ armnn::EmptyOptional(), // Units
+ numberOfCourse, // Number of cores
+ armnn::EmptyOptional(), // Device UID
+ armnn::EmptyOptional()));// Counter set UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 26);
BOOST_CHECK(counterWMultiCoreDeviceWParentCategory);
BOOST_CHECK(counterWMultiCoreDeviceWParentCategory->m_Uid > counter->m_Uid);
@@ -1718,10 +1729,10 @@ BOOST_AUTO_TEST_CASE(CheckCounterDirectoryRegisterCounter)
BOOST_CHECK_NO_THROW(anotherCounter = counterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID, 24,
anotherCategoryName, 1, 0, .00043f,
"valid name", "valid description",
- armnn::EmptyOptional(), // Units
- armnn::EmptyOptional(), // Number of cores
- device->m_Uid, // Device UID
- counterSet->m_Uid)); // Counter set UID
+ armnn::EmptyOptional(), // Units
+ armnn::EmptyOptional(), // Number of cores
+ device->m_Uid, // Device UID
+ counterSet->m_Uid)); // Counter set UID
BOOST_CHECK(counterDirectory.GetCounterCount() == 29);
BOOST_CHECK(anotherCounter);
BOOST_CHECK(anotherCounter->m_MaxCounterUid == anotherCounter->m_Uid);
@@ -1804,7 +1815,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData)
offset += sizeOfUint16;
WriteUint16(data1, offset, 5000);
- Packet packetA(packetId, dataLength1, uniqueData1);
+ arm::pipe::Packet packetA(packetId, dataLength1, uniqueData1);
PeriodicCounterSelectionCommandHandler commandHandler(familyId, packetId, version, backendProfilingContext,
counterIdMap, holder, 10000u, captureThread,
@@ -1859,7 +1870,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData)
WriteUint32(reinterpret_cast<unsigned char*>(uniqueData2.get()), 0, period2);
- Packet packetB(packetId, dataLength2, uniqueData2);
+ arm::pipe::Packet packetB(packetId, dataLength2, uniqueData2);
commandHandler(packetB);
@@ -1911,7 +1922,7 @@ BOOST_AUTO_TEST_CASE(CheckTimelineActivationAndDeactivation)
std::atomic<bool> m_timelineReporting;
};
- PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
BufferManager bufferManager(512);
SendTimelinePacket sendTimelinePacket(bufferManager);
@@ -1936,7 +1947,7 @@ BOOST_AUTO_TEST_CASE(CheckTimelineActivationAndDeactivation)
uint32_t packetHeader1 = ConstructHeader(packetFamily1, packetId1);
// Create the ActivateTimelineReportingPacket
- Packet ActivateTimelineReportingPacket(packetHeader1); // Length == 0
+ arm::pipe::Packet ActivateTimelineReportingPacket(packetHeader1); // Length == 0
BOOST_CHECK_THROW(
activateTimelineReportingCommandHandler.operator()(ActivateTimelineReportingPacket), armnn::Exception);
@@ -1968,7 +1979,7 @@ BOOST_AUTO_TEST_CASE(CheckTimelineActivationAndDeactivation)
uint32_t packetHeader2 = ConstructHeader(packetFamily2, packetId2);
// Create the DeactivateTimelineReportingPacket
- Packet deactivateTimelineReportingPacket(packetHeader2); // Length == 0
+ arm::pipe::Packet deactivateTimelineReportingPacket(packetHeader2); // Length == 0
stateMachine.Reset();
BOOST_CHECK_THROW(
@@ -2036,7 +2047,7 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged)
offset += sizeOfUint16;
WriteUint16(data1, offset, 5000);
- Packet packetA(connectionPacketId, dataLength1, uniqueData1);
+ arm::pipe::Packet packetA(connectionPacketId, dataLength1, uniqueData1);
ProfilingStateMachine profilingState(ProfilingState::Uninitialised);
BOOST_CHECK(profilingState.GetCurrentState() == ProfilingState::Uninitialised);
@@ -2076,7 +2087,7 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged)
// command handler received different packet
const uint32_t differentPacketId = 0x40000;
- Packet packetB(differentPacketId, dataLength1, uniqueData1);
+ arm::pipe::Packet packetB(differentPacketId, dataLength1, uniqueData1);
profilingState.TransitionToState(ProfilingState::NotConnected);
profilingState.TransitionToState(ProfilingState::WaitingForAck);
ConnectionAcknowledgedCommandHandler differentCommandHandler(packetFamilyId,
@@ -2093,7 +2104,7 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged)
BOOST_AUTO_TEST_CASE(CheckSocketConnectionException)
{
// Check that creating a SocketProfilingConnection armnnProfiling in an exception as the Gator UDS doesn't exist.
- BOOST_CHECK_THROW(new SocketProfilingConnection(), armnnProfiling::SocketConnectionException);
+ BOOST_CHECK_THROW(new SocketProfilingConnection(), arm::pipe::SocketConnectionException);
}
BOOST_AUTO_TEST_CASE(CheckSocketConnectionException2)
@@ -2102,7 +2113,7 @@ BOOST_AUTO_TEST_CASE(CheckSocketConnectionException2)
{
new SocketProfilingConnection();
}
- catch (const armnnProfiling::SocketConnectionException& ex)
+ catch (const arm::pipe::SocketConnectionException& ex)
{
BOOST_CHECK(ex.GetSocketFd() == 0);
BOOST_CHECK(ex.GetErrorNo() == 111);
@@ -2116,13 +2127,13 @@ BOOST_AUTO_TEST_CASE(SwTraceIsValidCharTest)
// Only ASCII 7-bit encoding supported
for (unsigned char c = 0; c < 128; c++)
{
- BOOST_CHECK(SwTraceCharPolicy::IsValidChar(c));
+ BOOST_CHECK(arm::pipe::SwTraceCharPolicy::IsValidChar(c));
}
// Not ASCII
for (unsigned char c = 255; c >= 128; c++)
{
- BOOST_CHECK(!SwTraceCharPolicy::IsValidChar(c));
+ BOOST_CHECK(!arm::pipe::SwTraceCharPolicy::IsValidChar(c));
}
}
@@ -2132,81 +2143,81 @@ BOOST_AUTO_TEST_CASE(SwTraceIsValidNameCharTest)
const unsigned char validChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
for (unsigned char i = 0; i < sizeof(validChars) / sizeof(validChars[0]) - 1; i++)
{
- BOOST_CHECK(SwTraceNameCharPolicy::IsValidChar(validChars[i]));
+ BOOST_CHECK(arm::pipe::SwTraceNameCharPolicy::IsValidChar(validChars[i]));
}
// Non alpha-numeric chars
for (unsigned char c = 0; c < 48; c++)
{
- BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c));
+ BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c));
}
for (unsigned char c = 58; c < 65; c++)
{
- BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c));
+ BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c));
}
for (unsigned char c = 91; c < 95; c++)
{
- BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c));
+ BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c));
}
for (unsigned char c = 96; c < 97; c++)
{
- BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c));
+ BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c));
}
for (unsigned char c = 123; c < 128; c++)
{
- BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c));
+ BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c));
}
// Not ASCII
for (unsigned char c = 255; c >= 128; c++)
{
- BOOST_CHECK(!SwTraceNameCharPolicy::IsValidChar(c));
+ BOOST_CHECK(!arm::pipe::SwTraceNameCharPolicy::IsValidChar(c));
}
}
BOOST_AUTO_TEST_CASE(IsValidSwTraceStringTest)
{
// Valid SWTrace strings
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>(""));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("_"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("0123"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("valid_string"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("VALID_string_456"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>(" "));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("valid string"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("!$%"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>("valid|\\~string#123"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(""));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("_"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("0123"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("valid_string"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("VALID_string_456"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(" "));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("valid string"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("!$%"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("valid|\\~string#123"));
// Invalid SWTrace strings
- BOOST_CHECK(!IsValidSwTraceString<SwTraceCharPolicy>("€£"));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceCharPolicy>("invalid‡string"));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceCharPolicy>("12Ž34"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("€£"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("invalid‡string"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>("12Ž34"));
}
BOOST_AUTO_TEST_CASE(IsValidSwTraceNameStringTest)
{
// Valid SWTrace name strings
- BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>(""));
- BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>("_"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>("0123"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>("valid_string"));
- BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>("VALID_string_456"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(""));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("_"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("0123"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("valid_string"));
+ BOOST_CHECK(arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("VALID_string_456"));
// Invalid SWTrace name strings
- BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>(" "));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("invalid string"));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("!$%"));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("invalid|\\~string#123"));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("€£"));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("invalid‡string"));
- BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>("12Ž34"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(" "));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid string"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("!$%"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid|\\~string#123"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("€£"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid‡string"));
+ BOOST_CHECK(!arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>("12Ž34"));
}
template <typename SwTracePolicy>
void StringToSwTraceStringTestHelper(const std::string& testString, std::vector<uint32_t> buffer, size_t expectedSize)
{
// Convert the test string to a SWTrace string
- BOOST_CHECK(StringToSwTraceString<SwTracePolicy>(testString, buffer));
+ BOOST_CHECK(arm::pipe::StringToSwTraceString<SwTracePolicy>(testString, buffer));
// The buffer must contain at least the length of the string
BOOST_CHECK(!buffer.empty());
@@ -2230,22 +2241,22 @@ BOOST_AUTO_TEST_CASE(StringToSwTraceStringTest)
std::vector<uint32_t> buffer;
// Valid SWTrace strings (expected size in words)
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("", buffer, 2);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("_", buffer, 2);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("0123", buffer, 3);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("valid_string", buffer, 5);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("VALID_string_456", buffer, 6);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>(" ", buffer, 2);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("valid string", buffer, 5);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("!$%", buffer, 2);
- StringToSwTraceStringTestHelper<SwTraceCharPolicy>("valid|\\~string#123", buffer, 6);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("", buffer, 2);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("_", buffer, 2);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("0123", buffer, 3);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("valid_string", buffer, 5);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("VALID_string_456", buffer, 6);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>(" ", buffer, 2);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("valid string", buffer, 5);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("!$%", buffer, 2);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceCharPolicy>("valid|\\~string#123", buffer, 6);
// Invalid SWTrace strings
- BOOST_CHECK(!StringToSwTraceString<SwTraceCharPolicy>("€£", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>("€£", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceCharPolicy>("invalid‡string", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>("invalid‡string", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceCharPolicy>("12Ž34", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>("12Ž34", buffer));
BOOST_CHECK(buffer.empty());
}
@@ -2254,26 +2265,26 @@ BOOST_AUTO_TEST_CASE(StringToSwTraceNameStringTest)
std::vector<uint32_t> buffer;
// Valid SWTrace namestrings (expected size in words)
- StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("", buffer, 2);
- StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("_", buffer, 2);
- StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("0123", buffer, 3);
- StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("valid_string", buffer, 5);
- StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>("VALID_string_456", buffer, 6);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("", buffer, 2);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("_", buffer, 2);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("0123", buffer, 3);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("valid_string", buffer, 5);
+ StringToSwTraceStringTestHelper<arm::pipe::SwTraceNameCharPolicy>("VALID_string_456", buffer, 6);
// Invalid SWTrace namestrings
- BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>(" ", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>(" ", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("invalid string", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid string", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("!$%", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("!$%", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("invalid|\\~string#123", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid|\\~string#123", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("€£", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("€£", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("invalid‡string", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("invalid‡string", buffer));
BOOST_CHECK(buffer.empty());
- BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>("12Ž34", buffer));
+ BOOST_CHECK(!arm::pipe::StringToSwTraceString<arm::pipe::SwTraceNameCharPolicy>("12Ž34", buffer));
BOOST_CHECK(buffer.empty());
}
@@ -2414,7 +2425,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1)
const uint32_t wrongPacketId = 47;
const uint32_t wrongHeader = (wrongPacketId & 0x000003FF) << 16;
- Packet wrongPacket(wrongHeader);
+ arm::pipe::Packet wrongPacket(wrongHeader);
profilingStateMachine.TransitionToState(ProfilingState::Uninitialised);
BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state
@@ -2427,7 +2438,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1)
const uint32_t rightHeader = (packetId & 0x000003FF) << 16;
- Packet rightPacket(rightHeader);
+ arm::pipe::Packet rightPacket(rightHeader);
BOOST_CHECK_NO_THROW(commandHandler(rightPacket)); // Right packet
@@ -2473,7 +2484,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2)
RequestCounterDirectoryCommandHandler commandHandler(familyId, packetId, version, counterDirectory,
sendCounterPacket, sendTimelinePacket, profilingStateMachine);
const uint32_t header = (packetId & 0x000003FF) << 16;
- const Packet packet(header);
+ const arm::pipe::Packet packet(header);
const Device* device = counterDirectory.RegisterDevice("deviceA", 1);
BOOST_CHECK(device != nullptr);
@@ -2587,7 +2598,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodConnectionAcknowledgedPacket)
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Connection Acknowledged Packet
- Packet connectionAcknowledgedPacket(header);
+ arm::pipe::Packet connectionAcknowledgedPacket(header);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(connectionAcknowledgedPacket));
@@ -2643,7 +2654,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodRequestCounterDirectoryPacket)
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Request Counter Directory packet
- Packet requestCounterDirectoryPacket(header);
+ arm::pipe::Packet requestCounterDirectoryPacket(header);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(requestCounterDirectoryPacket));
@@ -2720,8 +2731,9 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadPeriodicCounterSelectionPacketInval
WriteUint16(data.get(), 6, counterUidB);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter
- // Capture thread
+ // Length > 0, this will start the Period Counter Capture thread
+ arm::pipe::Packet periodicCounterSelectionPacket(header, length, data);
+
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -2783,7 +2795,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketNoCo
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters
+ // Length == 0, this will disable the collection of counters
+ arm::pipe::Packet periodicCounterSelectionPacket(header);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -2861,8 +2874,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketSing
WriteUint16(data.get(), 4, counterUid);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter
- // Capture thread
+ // Length > 0, this will start the Period Counter Capture thread
+ arm::pipe::Packet periodicCounterSelectionPacket(header, length, data);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -2940,8 +2953,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPeriodicCounterSelectionPacketMult
WriteUint16(data.get(), 6, counterUidB);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header, length, data); // Length > 0, this will start the Period Counter
- // Capture thread
+ // Length > 0, this will start the Period Counter Capture thread
+ arm::pipe::Packet periodicCounterSelectionPacket(header, length, data);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -3061,7 +3074,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPerJobCounterSelectionPacket)
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Per-Job Counter Selection packet
- Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters
+ // Length == 0, this will disable the collection of counters
+ arm::pipe::Packet periodicCounterSelectionPacket(header);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
@@ -3218,7 +3232,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadConnectionAcknowledgedPacket)
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Connection Acknowledged Packet
- Packet connectionAcknowledgedPacket(header);
+ arm::pipe::Packet connectionAcknowledgedPacket(header);
// Write an invalid "Connection Acknowledged" packet into the mock profiling connection, to simulate an invalid
// reply from an external profiling service
mockProfilingConnection->WritePacket(std::move(connectionAcknowledgedPacket));
@@ -3282,7 +3296,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadRequestCounterDirectoryPacket)
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Request Counter Directory packet
- Packet requestCounterDirectoryPacket(header);
+ arm::pipe::Packet requestCounterDirectoryPacket(header);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(requestCounterDirectoryPacket));
@@ -3347,7 +3361,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadPeriodicCounterSelectionPacket)
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
// Create the Periodic Counter Selection packet
- Packet periodicCounterSelectionPacket(header); // Length == 0, this will disable the collection of counters
+ // Length == 0, this will disable the collection of counters
+ arm::pipe::Packet periodicCounterSelectionPacket(header);
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(periodicCounterSelectionPacket));
diff --git a/src/profiling/test/ProfilingTests.hpp b/src/profiling/test/ProfilingTests.hpp
index c350fd2860..f96a1c89ab 100644
--- a/src/profiling/test/ProfilingTests.hpp
+++ b/src/profiling/test/ProfilingTests.hpp
@@ -10,10 +10,12 @@
#include <armnn/Logging.hpp>
#include <armnn/utility/PolymorphicDowncast.hpp>
-#include <CommandHandlerFunctor.hpp>
#include <IProfilingConnection.hpp>
#include <ProfilingService.hpp>
+#include <common/include/CommandHandlerFunctor.hpp>
+
+
#include <boost/test/unit_test.hpp>
#include <chrono>
@@ -82,14 +84,14 @@ public:
return false;
}
- Packet ReadPacket(uint32_t timeout) override
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override
{
// First time we're called return a connection ack packet. After that always timeout.
if (m_FirstCall)
{
m_FirstCall = false;
// Return connection acknowledged packet
- return Packet(65536);
+ return arm::pipe::Packet(65536);
}
else
{
@@ -108,7 +110,7 @@ public:
: m_ReadRequests(0)
{}
- Packet ReadPacket(uint32_t timeout) override
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override
{
// Return connection acknowledged packet after three timeouts
if (m_ReadRequests % 3 == 0)
@@ -118,7 +120,7 @@ public:
throw armnn::TimeoutException("Simulate a timeout error\n");
}
- return Packet(65536);
+ return arm::pipe::Packet(65536);
}
int ReadCalledCount()
@@ -137,7 +139,7 @@ public:
: m_ReadRequests(0)
{}
- Packet ReadPacket(uint32_t timeout) override
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override
{
IgnoreUnused(timeout);
++m_ReadRequests;
@@ -156,7 +158,7 @@ private:
class TestProfilingConnectionBadAckPacket : public TestProfilingConnectionBase
{
public:
- Packet ReadPacket(uint32_t timeout) override
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override
{
IgnoreUnused(timeout);
// Connection Acknowledged Packet header (word 0, word 1 is always zero):
@@ -168,18 +170,18 @@ public:
uint32_t packetId = 37; // Wrong packet id!!!
uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
- return Packet(header);
+ return arm::pipe::Packet(header);
}
};
-class TestFunctorA : public CommandHandlerFunctor
+class TestFunctorA : public arm::pipe::CommandHandlerFunctor
{
public:
using CommandHandlerFunctor::CommandHandlerFunctor;
int GetCount() { return m_Count; }
- void operator()(const Packet& packet) override
+ void operator()(const arm::pipe::Packet& packet) override
{
IgnoreUnused(packet);
m_Count++;
diff --git a/src/profiling/test/RequestCountersPacketHandler.cpp b/src/profiling/test/RequestCountersPacketHandler.cpp
index 76c4b0cdc6..230c38857f 100644
--- a/src/profiling/test/RequestCountersPacketHandler.cpp
+++ b/src/profiling/test/RequestCountersPacketHandler.cpp
@@ -1,12 +1,12 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "RequestCountersPacketHandler.hpp"
#include "DirectoryCaptureCommandHandler.hpp"
-#include "PacketVersionResolver.hpp"
+#include <common/include/PacketVersionResolver.hpp>
#include <common/include/ProfilingException.hpp>
@@ -23,13 +23,13 @@ std::vector<uint32_t> RequestCountersPacketHandler::GetHeadersAccepted()
return headers;
}
-void RequestCountersPacketHandler::HandlePacket(const Packet& packet)
+void RequestCountersPacketHandler::HandlePacket(const arm::pipe::Packet& packet)
{
if (packet.GetHeader() != m_CounterDirectoryMessageHeader)
{
return;
}
- armnn::profiling::PacketVersionResolver packetVersionResolver;
+ arm::pipe::PacketVersionResolver packetVersionResolver;
DirectoryCaptureCommandHandler directoryCaptureCommandHandler(
0, 2, packetVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue());
directoryCaptureCommandHandler.operator()(packet);
@@ -69,7 +69,7 @@ void RequestCountersPacketHandler::SendCounterSelectionPacket()
offset += uint16_t_size;
}
- Packet packet(0x40000, bodySize, uniqueData);
+ arm::pipe::Packet packet(0x40000, bodySize, uniqueData);
m_Connection->ReturnPacket(packet);
}
diff --git a/src/profiling/test/RequestCountersPacketHandler.hpp b/src/profiling/test/RequestCountersPacketHandler.hpp
index 203edcc9df..b5e48626a7 100644
--- a/src/profiling/test/RequestCountersPacketHandler.hpp
+++ b/src/profiling/test/RequestCountersPacketHandler.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -7,9 +7,10 @@
#include <armnn/Types.hpp>
#include <armnn/profiling/ILocalPacketHandler.hpp>
-#include "Packet.hpp"
#include "ProfilingUtils.hpp"
+#include <common/include/Packet.hpp>
+
namespace armnn
{
@@ -26,7 +27,7 @@ public:
std::vector<uint32_t> GetHeadersAccepted() override; // ILocalPacketHandler
- void HandlePacket(const Packet& packet) override; // ILocalPacketHandler
+ void HandlePacket(const arm::pipe::Packet& packet) override; // ILocalPacketHandler
void SetConnection(IInternalProfilingConnection* profilingConnection) override // ILocalPacketHandler
{
diff --git a/src/profiling/test/SendCounterPacketTests.cpp b/src/profiling/test/SendCounterPacketTests.cpp
index c5f9177c90..87cfb5bf58 100644
--- a/src/profiling/test/SendCounterPacketTests.cpp
+++ b/src/profiling/test/SendCounterPacketTests.cpp
@@ -9,7 +9,7 @@
#include <BufferManager.hpp>
#include <CounterDirectory.hpp>
-#include <EncodeVersion.hpp>
+#include <common/include/EncodeVersion.hpp>
#include <ProfilingUtils.hpp>
#include <SendCounterPacket.hpp>
#include <Processes.hpp>
@@ -325,19 +325,19 @@ BOOST_AUTO_TEST_CASE(SendStreamMetaDataPacketTest)
// Timeline Message Directory (packet_family = 1, packet_class = 0, packet_type = 0) Version 1.0.0
// Timeline Message (packet_family = 1, packet_class = 0, packet_type = 1) Version 1.0.0
std::vector<std::pair<uint32_t, uint32_t>> packetVersions;
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 1), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 2), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 3), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 4), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 5), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 6), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(0, 7), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(3, 0, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 1), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 0), EncodeVersion(1, 0, 0)));
- packetVersions.push_back(std::make_pair(ConstructHeader(1, 0, 1), EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 0), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 1), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 2), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 3), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 4), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 5), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 6), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(0, 7), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(3, 0, 0), arm::pipe::EncodeVersion(1, 0, 0)));
+ packetVersions.push_back(std::make_pair(ConstructHeader(3, 1, 0), arm::pipe::EncodeVersion(1, 0, 0)));
+ 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 packetEntries = static_cast<uint32_t>(packetVersions.size());
@@ -359,9 +359,9 @@ BOOST_AUTO_TEST_CASE(SendStreamMetaDataPacketTest)
BOOST_TEST(headerWord1 == totalLength - (2 * sizeUint32)); // data length
uint32_t offset = sizeUint32 * 2;
- BOOST_TEST(ReadUint32(readBuffer2, offset) == armnnProfiling::PIPE_MAGIC); // pipe_magic
+ BOOST_TEST(ReadUint32(readBuffer2, offset) == arm::pipe::PIPE_MAGIC); // pipe_magic
offset += sizeUint32;
- BOOST_TEST(ReadUint32(readBuffer2, offset) == EncodeVersion(1, 0, 0)); // stream_metadata_version
+ BOOST_TEST(ReadUint32(readBuffer2, offset) == arm::pipe::EncodeVersion(1, 0, 0)); // stream_metadata_version
offset += sizeUint32;
BOOST_TEST(ReadUint32(readBuffer2, offset) == MAX_METADATA_PACKET_LENGTH); // max_data_len
offset += sizeUint32;
diff --git a/src/profiling/test/SendTimelinePacketTests.cpp b/src/profiling/test/SendTimelinePacketTests.cpp
index 5e9f6bddea..7b68bb9753 100644
--- a/src/profiling/test/SendTimelinePacketTests.cpp
+++ b/src/profiling/test/SendTimelinePacketTests.cpp
@@ -6,14 +6,16 @@
#include "ProfilingMocks.hpp"
#include <BufferManager.hpp>
-#include <Threads.hpp>
+#include <LabelsAndEventClasses.hpp>
#include <ProfilingService.hpp>
#include <ProfilingUtils.hpp>
#include <SendTimelinePacket.hpp>
+#include <Threads.hpp>
#include <TimelinePacketWriterFactory.hpp>
+#include <common/include/SwTrace.hpp>
+
#include <boost/test/unit_test.hpp>
-#include <LabelsAndEventClasses.hpp>
#include <functional>
#include <Runtime.hpp>
@@ -72,9 +74,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest)
BOOST_CHECK(DeclCount == 5);
offset += uint32_t_size;
- SwTraceMessage swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(),
- offset,
- packetBuffer->GetSize());
+ arm::pipe::SwTraceMessage swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(),
+ offset,
+ packetBuffer->GetSize());
BOOST_CHECK(swTraceMessage.m_Id == 0);
BOOST_CHECK(swTraceMessage.m_Name == "declareLabel");
@@ -86,7 +88,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest)
BOOST_CHECK(swTraceMessage.m_ArgNames[0] == "guid");
BOOST_CHECK(swTraceMessage.m_ArgNames[1] == "value");
- swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize());
+ swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(),
+ offset,
+ packetBuffer->GetSize());
BOOST_CHECK(swTraceMessage.m_Id == 1);
BOOST_CHECK(swTraceMessage.m_Name == "declareEntity");
@@ -96,7 +100,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest)
BOOST_CHECK(swTraceMessage.m_ArgNames.size() == 1);
BOOST_CHECK(swTraceMessage.m_ArgNames[0] == "guid");
- swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize());
+ swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(),
+ offset,
+ packetBuffer->GetSize());
BOOST_CHECK(swTraceMessage.m_Id == 2);
BOOST_CHECK(swTraceMessage.m_Name == "declareEventClass");
@@ -108,7 +114,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest)
BOOST_CHECK(swTraceMessage.m_ArgNames[0] == "guid");
BOOST_CHECK(swTraceMessage.m_ArgNames[1] == "nameGuid");
- swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize());
+ swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(),
+ offset,
+ packetBuffer->GetSize());
BOOST_CHECK(swTraceMessage.m_Id == 3);
BOOST_CHECK(swTraceMessage.m_Name == "declareRelationship");
@@ -126,7 +134,9 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest)
BOOST_CHECK(swTraceMessage.m_ArgNames[3] == "tailGuid");
BOOST_CHECK(swTraceMessage.m_ArgNames[4] == "attributeGuid");
- swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset, packetBuffer->GetSize());
+ swTraceMessage = arm::pipe::ReadSwTraceMessage(packetBuffer->GetReadableData(),
+ offset,
+ packetBuffer->GetSize());
BOOST_CHECK(swTraceMessage.m_Id == 4);
BOOST_CHECK(swTraceMessage.m_Name == "declareEvent");
diff --git a/src/profiling/test/TestTimelinePacketHandler.cpp b/src/profiling/test/TestTimelinePacketHandler.cpp
index ccb806b238..df847d4c7c 100644
--- a/src/profiling/test/TestTimelinePacketHandler.cpp
+++ b/src/profiling/test/TestTimelinePacketHandler.cpp
@@ -7,11 +7,8 @@
#include "IProfilingConnection.hpp"
#include <LabelsAndEventClasses.hpp>
-#include <armnn/utility/IgnoreUnused.hpp>
-
#include <chrono>
#include <iostream>
-#include <sstream>
namespace armnn
{
@@ -27,7 +24,7 @@ std::vector<uint32_t> TestTimelinePacketHandler::GetHeadersAccepted()
return headers;
}
-void TestTimelinePacketHandler::HandlePacket(const Packet& packet)
+void TestTimelinePacketHandler::HandlePacket(const arm::pipe::Packet& packet)
{
if (packet.GetHeader() == m_DirectoryHeader)
{
@@ -79,44 +76,46 @@ void TestTimelinePacketHandler::SetInferenceComplete()
m_InferenceCompletedConditionVariable.notify_one();
}
-void TestTimelinePacketHandler::ProcessDirectoryPacket(const Packet& packet)
+void TestTimelinePacketHandler::ProcessDirectoryPacket(const arm::pipe::Packet& packet)
{
m_DirectoryDecoder(packet);
}
-void TestTimelinePacketHandler::ProcessMessagePacket(const Packet& packet)
+void TestTimelinePacketHandler::ProcessMessagePacket(const arm::pipe::Packet& packet)
{
m_Decoder(packet);
}
// TimelineMessageDecoder functions
-ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEntity(const Entity& entity)
+arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEntity(const Entity& entity)
{
m_TimelineModel.AddEntity(entity.m_Guid);
- return ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
+ return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
}
-ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEventClass(
- const ITimelineDecoder::EventClass& eventClass)
+arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEventClass(
+ const arm::pipe::ITimelineDecoder::EventClass& eventClass)
{
m_TimelineModel.AddEventClass(eventClass);
- return ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
+ return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
}
-ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEvent(const ITimelineDecoder::Event& event)
+arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateEvent(
+ const arm::pipe::ITimelineDecoder::Event& event)
{
m_TimelineModel.AddEvent(event);
- return ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
+ return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
}
-ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateLabel(const ITimelineDecoder::Label& label)
+arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateLabel(
+ const arm::pipe::ITimelineDecoder::Label& label)
{
m_TimelineModel.AddLabel(label);
- return ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
+ return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
}
-ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateRelationship(
- const ITimelineDecoder::Relationship& relationship)
+arm::pipe::ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateRelationship(
+ const arm::pipe::ITimelineDecoder::Relationship& relationship)
{
m_TimelineModel.AddRelationship(relationship);
// check to see if this is an execution link to an inference of event class end of life
@@ -133,7 +132,7 @@ ITimelineDecoder::TimelineStatus TimelineMessageDecoder::CreateRelationship(
}
}
}
- return ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
+ return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
}
} // namespace profiling
diff --git a/src/profiling/test/TestTimelinePacketHandler.hpp b/src/profiling/test/TestTimelinePacketHandler.hpp
index 08239fc38f..ab6eee5121 100644
--- a/src/profiling/test/TestTimelinePacketHandler.hpp
+++ b/src/profiling/test/TestTimelinePacketHandler.hpp
@@ -6,14 +6,15 @@
#pragma once
#include <armnn/profiling/ILocalPacketHandler.hpp>
-#include <armnn/profiling/ITimelineDecoder.hpp>
-#include <Packet.hpp>
+#include <server/include/timelineDecoder/ITimelineDecoder.hpp>
#include "ProfilingUtils.hpp"
-#include "TimelineCaptureCommandHandler.hpp"
-#include "TimelineDirectoryCaptureCommandHandler.hpp"
+#include <server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp>
+#include <server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp>
#include "TimelineModel.hpp"
+#include <common/include/Packet.hpp>
+
#include <condition_variable>
#include <map>
#include <mutex>
@@ -27,7 +28,7 @@ namespace profiling
// forward declaration of class
class TestTimelinePacketHandler;
-class TimelineMessageDecoder : public ITimelineDecoder
+class TimelineMessageDecoder : public arm::pipe::ITimelineDecoder
{
public:
TimelineMessageDecoder(TimelineModel& model) : m_PacketHandler(nullptr), m_TimelineModel(model) {}
@@ -57,7 +58,7 @@ public:
virtual std::vector<uint32_t> GetHeadersAccepted() override; // ILocalPacketHandler
- virtual void HandlePacket(const Packet& packet) override; // ILocalPacketHandler
+ virtual void HandlePacket(const arm::pipe::Packet& packet) override; // ILocalPacketHandler
void Stop();
@@ -72,8 +73,8 @@ public:
}
private:
- void ProcessDirectoryPacket(const Packet& packet);
- void ProcessMessagePacket(const Packet& packet);
+ void ProcessDirectoryPacket(const arm::pipe::Packet& packet);
+ void ProcessMessagePacket(const arm::pipe::Packet& packet);
IInternalProfilingConnection* m_Connection;
std::mutex m_InferenceCompletedMutex;
std::condition_variable m_InferenceCompletedConditionVariable;
@@ -82,8 +83,8 @@ private:
uint32_t m_DirectoryHeader;
uint32_t m_MessageHeader;
TimelineMessageDecoder m_MessageDecoder;
- timelinedecoder::TimelineCaptureCommandHandler m_Decoder;
- timelinedecoder::TimelineDirectoryCaptureCommandHandler m_DirectoryDecoder;
+ arm::pipe::TimelineCaptureCommandHandler m_Decoder;
+ arm::pipe::TimelineDirectoryCaptureCommandHandler m_DirectoryDecoder;
};
} // namespace profiling
diff --git a/src/profiling/test/TimelineModel.cpp b/src/profiling/test/TimelineModel.cpp
index 2e4fd06013..1f02addcf9 100644
--- a/src/profiling/test/TimelineModel.cpp
+++ b/src/profiling/test/TimelineModel.cpp
@@ -14,7 +14,7 @@ namespace armnn
namespace profiling
{
-void TimelineModel::AddLabel(const ITimelineDecoder::Label& label)
+void TimelineModel::AddLabel(const arm::pipe::ITimelineDecoder::Label& label)
{
m_LabelMap.emplace(label.m_Guid, label);
}
@@ -50,14 +50,14 @@ Entity* TimelineModel::FindEntity(uint64_t id)
}
}
-void TimelineModel::AddRelationship(const ITimelineDecoder::Relationship& relationship)
+void TimelineModel::AddRelationship(const arm::pipe::ITimelineDecoder::Relationship& relationship)
{
m_Relationships.emplace(relationship.m_Guid, relationship);
- if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::LabelLink)
+ if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::LabelLink)
{
HandleLabelLink(relationship);
}
- else if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::RetentionLink)
+ else if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink)
{
// Take care of the special case of a connection between layers in ArmNN
// modelled by a retention link between two layer entities with an attribute GUID
@@ -79,16 +79,16 @@ void TimelineModel::AddRelationship(const ITimelineDecoder::Relationship& relati
// report unknown relationship type
std::stringstream ss;
ss << "Encountered a RetentionLink of unknown type [" << relationship.m_AttributeGuid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
}
}
- else if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::ExecutionLink)
+ else if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink)
{
HandleExecutionLink(relationship);
}
}
-void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relationship)
+void TimelineModel::HandleLabelLink(const arm::pipe::ITimelineDecoder::Relationship& relationship)
{
Entity* entity = FindEntity(relationship.m_HeadGuid);
// we have a label attribute of an entity
@@ -101,7 +101,7 @@ void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relati
std::stringstream ss;
ss << "could not find label link [" << relationship.m_Guid <<
"] value [" << relationship.m_TailGuid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
}
if (relationship.m_AttributeGuid != 0)
{
@@ -112,7 +112,7 @@ void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relati
std::stringstream ss;
ss << "could not find label link [" << relationship.m_Guid <<
"] attribute [" << relationship.m_AttributeGuid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
}
}
else
@@ -120,7 +120,7 @@ void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relati
//report an error
std::stringstream ss;
ss << "label link [" << relationship.m_Guid << "] has a zero attribute guid";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
}
if (entity != nullptr && attribute != nullptr && value != nullptr)
{
@@ -148,11 +148,11 @@ void TimelineModel::HandleLabelLink(const ITimelineDecoder::Relationship& relati
{
ss << "attribute [" << *attribute << "] ";
}
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
}
}
-void TimelineModel::HandleConnection(const ITimelineDecoder::Relationship& relationship)
+void TimelineModel::HandleConnection(const arm::pipe::ITimelineDecoder::Relationship& relationship)
{
Entity* outputLayer = FindEntity(relationship.m_HeadGuid);
if (outputLayer == nullptr)
@@ -160,7 +160,7 @@ void TimelineModel::HandleConnection(const ITimelineDecoder::Relationship& relat
std::stringstream ss;
ss << "could not find output entity [" << relationship.m_HeadGuid << "]";
ss << " of connection [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
Entity* inputLayer = FindEntity(relationship.m_TailGuid);
@@ -169,14 +169,14 @@ void TimelineModel::HandleConnection(const ITimelineDecoder::Relationship& relat
std::stringstream ss;
ss << "could not find input entity [" << relationship.m_TailGuid << "]";
ss << " of connection [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
Connection connection(relationship.m_Guid, outputLayer, inputLayer);
outputLayer->AddConnection(connection);
}
-void TimelineModel::HandleChild(const ITimelineDecoder::Relationship& relationship)
+void TimelineModel::HandleChild(const arm::pipe::ITimelineDecoder::Relationship& relationship)
{
Entity* parentEntity = FindEntity(relationship.m_HeadGuid);
if (parentEntity == nullptr)
@@ -184,7 +184,7 @@ void TimelineModel::HandleChild(const ITimelineDecoder::Relationship& relationsh
std::stringstream ss;
ss << "could not find parent entity [" << relationship.m_HeadGuid << "]";
ss << " of child relationship [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
Entity* childEntity = FindEntity(relationship.m_TailGuid);
@@ -193,13 +193,13 @@ void TimelineModel::HandleChild(const ITimelineDecoder::Relationship& relationsh
std::stringstream ss;
ss << "could not find child entity [" << relationship.m_TailGuid << "]";
ss << " of child relationship [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
parentEntity->AddChild(childEntity);
}
-void TimelineModel::HandleExecutionOf(const ITimelineDecoder::Relationship& relationship)
+void TimelineModel::HandleExecutionOf(const arm::pipe::ITimelineDecoder::Relationship& relationship)
{
Entity* parentEntity = FindEntity(relationship.m_HeadGuid);
if (parentEntity == nullptr)
@@ -207,7 +207,7 @@ void TimelineModel::HandleExecutionOf(const ITimelineDecoder::Relationship& rela
std::stringstream ss;
ss << "could not find parent entity [" << relationship.m_HeadGuid << "]";
ss << " of execution relationship [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
Entity* executedEntity = FindEntity(relationship.m_TailGuid);
@@ -216,13 +216,13 @@ void TimelineModel::HandleExecutionOf(const ITimelineDecoder::Relationship& rela
std::stringstream ss;
ss << "could not find executed entity [" << relationship.m_TailGuid << "]";
ss << " of execution relationship [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
parentEntity->AddExecution(executedEntity);
}
-void TimelineModel::HandleExecutionLink(const ITimelineDecoder::Relationship& relationship)
+void TimelineModel::HandleExecutionLink(const arm::pipe::ITimelineDecoder::Relationship& relationship)
{
// entityGuid,
Entity* parentEntity = FindEntity(relationship.m_HeadGuid);
@@ -231,7 +231,7 @@ void TimelineModel::HandleExecutionLink(const ITimelineDecoder::Relationship& re
std::stringstream ss;
ss << "could not find entity [" << relationship.m_HeadGuid << "]";
ss << " of ExecutionLink [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
// eventGuid,
@@ -241,7 +241,7 @@ void TimelineModel::HandleExecutionLink(const ITimelineDecoder::Relationship& re
std::stringstream ss;
ss << "could not find event [" << relationship.m_TailGuid << "]";
ss << " of ExecutionLink [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
// eventClassGuid
@@ -251,7 +251,7 @@ void TimelineModel::HandleExecutionLink(const ITimelineDecoder::Relationship& re
std::stringstream ss;
ss << "could not find event class [" << relationship.m_TailGuid << "]";
ss << " of ExecutionLink [" << relationship.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
return;
}
eventObj->SetEventClass(eventClassObj);
@@ -277,7 +277,7 @@ bool TimelineModel::IsInferenceGuid(uint64_t guid) const
return it != m_InferenceGuids.end();
}
-void TimelineModel::AddEventClass(const ITimelineDecoder::EventClass& eventClass)
+void TimelineModel::AddEventClass(const arm::pipe::ITimelineDecoder::EventClass& eventClass)
{
std::string* eventClassName = FindLabel(eventClass.m_NameGuid);
if (eventClassName != nullptr)
@@ -290,7 +290,7 @@ void TimelineModel::AddEventClass(const ITimelineDecoder::EventClass& eventClass
std::stringstream ss;
ss << "could not find name [" << eventClass.m_NameGuid << "]";
ss << " of of event class [" << eventClass.m_Guid << "]";
- m_Errors.push_back(armnnProfiling::ProfilingException(ss.str()));
+ m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
}
}
@@ -307,7 +307,7 @@ EventClassObj* TimelineModel::FindEventClass(uint64_t id)
}
}
-void TimelineModel::AddEvent(const ITimelineDecoder::Event& event)
+void TimelineModel::AddEvent(const arm::pipe::ITimelineDecoder::Event& event)
{
EventObj evt(event.m_Guid, event.m_TimeStamp, event.m_ThreadId);
m_Events.emplace(event.m_Guid, evt);
diff --git a/src/profiling/test/TimelineModel.hpp b/src/profiling/test/TimelineModel.hpp
index a6d62ce3e8..ccbec7b01d 100644
--- a/src/profiling/test/TimelineModel.hpp
+++ b/src/profiling/test/TimelineModel.hpp
@@ -5,8 +5,8 @@
#pragma once
-#include <armnn/profiling/ITimelineDecoder.hpp>
#include <common/include/ProfilingException.hpp>
+#include <server/include/timelineDecoder/ITimelineDecoder.hpp>
#include <map>
#include <sstream>
@@ -17,7 +17,7 @@ namespace armnn
namespace profiling
{
-using LabelMap = std::map<uint64_t, ITimelineDecoder::Label>;
+using LabelMap = std::map<uint64_t, arm::pipe::ITimelineDecoder::Label>;
using Attribute = std::pair<std::string, std::string>;
using Attributes = std::map<std::string, Attribute>;
class Entity;
@@ -31,13 +31,13 @@ public:
{
std::stringstream ss;
ss << "connection [" << guid << "] head cannot be null";
- throw armnnProfiling::ProfilingException(ss.str());
+ throw arm::pipe::ProfilingException(ss.str());
}
if (tail == nullptr)
{
std::stringstream ss;
ss << "connection [" << guid << "] tail cannot be null";
- throw armnnProfiling::ProfilingException(ss.str());
+ throw arm::pipe::ProfilingException(ss.str());
}
}
@@ -136,8 +136,8 @@ private:
using Entities = std::map<uint64_t, Entity>;
struct ModelRelationship
{
- ModelRelationship(const ITimelineDecoder::Relationship& relationship) : m_Relationship(relationship) {}
- ITimelineDecoder::Relationship m_Relationship;
+ ModelRelationship(const arm::pipe::ITimelineDecoder::Relationship& relationship) : m_Relationship(relationship) {}
+ arm::pipe::ITimelineDecoder::Relationship m_Relationship;
std::vector<Entity*> m_RelatedEntities;
};
using Relationships = std::map<uint64_t, ModelRelationship>;
@@ -146,35 +146,35 @@ using Events = std::map<uint64_t, EventObj>;
class TimelineModel
{
public:
- void AddLabel(const ITimelineDecoder::Label& label);
+ void AddLabel(const arm::pipe::ITimelineDecoder::Label& label);
std::string* FindLabel(uint64_t guid);
void AddEntity(uint64_t guid);
Entity* FindEntity(uint64_t id);
- void AddRelationship(const ITimelineDecoder::Relationship& relationship);
+ void AddRelationship(const arm::pipe::ITimelineDecoder::Relationship& relationship);
ModelRelationship* FindRelationship(uint64_t id);
const LabelMap& GetLabelMap() const {return m_LabelMap;}
const Entities& GetEntities() const {return m_Entities;}
- const std::vector<armnnProfiling::ProfilingException>& GetErrors() const {return m_Errors;}
+ const std::vector<arm::pipe::ProfilingException>& GetErrors() const {return m_Errors;}
bool IsInferenceGuid(uint64_t guid) const;
- void AddEventClass(const ITimelineDecoder::EventClass& eventClass);
+ void AddEventClass(const arm::pipe::ITimelineDecoder::EventClass& eventClass);
const EventClasses& GetEventClasses() const {return m_EventClasses;}
EventClassObj* FindEventClass(uint64_t id);
- void AddEvent(const ITimelineDecoder::Event& event);
+ void AddEvent(const arm::pipe::ITimelineDecoder::Event& event);
EventObj* FindEvent(uint64_t id);
private:
LabelMap m_LabelMap;
Entities m_Entities;
Relationships m_Relationships;
- std::vector<armnnProfiling::ProfilingException> m_Errors;
+ std::vector<arm::pipe::ProfilingException> m_Errors;
std::vector<uint64_t> m_InferenceGuids;
EventClasses m_EventClasses;
Events m_Events;
- void HandleLabelLink(const ITimelineDecoder::Relationship& relationship);
- void HandleConnection(const ITimelineDecoder::Relationship& relationship);
- void HandleChild(const ITimelineDecoder::Relationship& relationship);
- void HandleExecutionOf(const ITimelineDecoder::Relationship& relationship);
- void HandleExecutionLink(const ITimelineDecoder::Relationship& relationship);
+ void HandleLabelLink(const arm::pipe::ITimelineDecoder::Relationship& relationship);
+ void HandleConnection(const arm::pipe::ITimelineDecoder::Relationship& relationship);
+ void HandleChild(const arm::pipe::ITimelineDecoder::Relationship& relationship);
+ void HandleExecutionOf(const arm::pipe::ITimelineDecoder::Relationship& relationship);
+ void HandleExecutionLink(const arm::pipe::ITimelineDecoder::Relationship& relationship);
};
std::vector<std::string> GetModelDescription(const TimelineModel& model);
diff --git a/src/profiling/test/TimelinePacketTests.cpp b/src/profiling/test/TimelinePacketTests.cpp
index 71c6915a8c..4f056ce761 100644
--- a/src/profiling/test/TimelinePacketTests.cpp
+++ b/src/profiling/test/TimelinePacketTests.cpp
@@ -6,6 +6,8 @@
#include <Threads.hpp>
#include <ProfilingUtils.hpp>
+#include <common/include/SwTrace.hpp>
+
#include <boost/test/unit_test.hpp>
#include <boost/numeric/conversion/cast.hpp>
@@ -524,7 +526,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction)
// Check the ui_name
std::vector<uint32_t> swTraceString;
- StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
+ arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(label, swTraceString);
offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
uint32_t swTraceUINameLength = ReadUint32(buffer.data(), offset);
BOOST_CHECK(swTraceUINameLength == 14); // ui_name length including the null-terminator
@@ -536,7 +538,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction)
swTraceUINameLength - 1) == 0); // The length of the label
// Check arg_types
- StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
+ arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(label, swTraceString);
offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
uint32_t swTraceArgTypesLength = ReadUint32(buffer.data(), offset);
BOOST_CHECK(swTraceArgTypesLength == 3); // arg_types length including the null-terminator
@@ -548,7 +550,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction)
swTraceArgTypesLength - 1) == 0); // The length of the label
// Check arg_names
- StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
+ arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(label, swTraceString);
offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
uint32_t swTraceArgNamesLength = ReadUint32(buffer.data(), offset);
BOOST_CHECK(swTraceArgNamesLength == 11); // arg_names length including the null-terminator
@@ -560,7 +562,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction)
swTraceArgNamesLength - 1) == 0); // The length of the label
// Check second message decl_id
- StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
+ arm::pipe::StringToSwTraceString<arm::pipe::SwTraceCharPolicy>(label, swTraceString);
offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
readDeclId = ReadUint32(buffer.data(), offset);
BOOST_CHECK(readDeclId == 1);