From 5ccb33da0565e0bf2279318f1e7ad597afcc0367 Mon Sep 17 00:00:00 2001 From: Colm Donelan Date: Fri, 24 Jan 2020 16:27:02 +0000 Subject: IVGCVSW-4316 Promote ISendTimelinePacket and IProfilingGuidGenerator As part of IVGCVSW-4316 we need to expose ISendTimelinePacket and IProfilingGuidGenerator to enable them to be used by backends for profiling. This also required moving ProfilingRelationshipType from ProfilingUtils. Signed-off-by: Colm Donelan Change-Id: I58cc64e32ecfffa5231c9d2028522ed58d0ddf31 --- CMakeLists.txt | 4 +- .../armnn/profiling/IProfilingGuidGenerator.hpp | 32 ++++++++++++ include/armnn/profiling/ISendTimelinePacket.hpp | 61 ++++++++++++++++++++++ .../ConnectionAcknowledgedCommandHandler.hpp | 2 +- src/profiling/IProfilingGuidGenerator.hpp | 32 ------------ src/profiling/ISendTimelinePacket.hpp | 56 -------------------- src/profiling/ProfilingGuidGenerator.hpp | 2 +- src/profiling/ProfilingUtils.hpp | 11 +--- .../RequestCounterDirectoryCommandHandler.hpp | 2 +- src/profiling/SendTimelinePacket.hpp | 2 +- src/profiling/TimelinePacketWriterFactory.hpp | 2 +- src/profiling/TimelineUtilityMethods.hpp | 2 +- 12 files changed, 103 insertions(+), 105 deletions(-) create mode 100644 include/armnn/profiling/IProfilingGuidGenerator.hpp create mode 100644 include/armnn/profiling/ISendTimelinePacket.hpp delete mode 100644 src/profiling/IProfilingGuidGenerator.hpp delete mode 100644 src/profiling/ISendTimelinePacket.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c8c3870c2..b1af90d8af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -242,6 +242,8 @@ list(APPEND armnn_sources include/armnn/TypesUtils.hpp include/armnn/Utils.hpp include/armnn/Version.hpp + include/armnn/profiling/IProfilingGuidGenerator.hpp + include/armnn/profiling/ISendTimelinePacket.hpp src/armnn/layers/LayerCloneBase.hpp src/armnn/layers/LayerWithParameters.hpp src/armnn/layers/ActivationLayer.hpp @@ -468,12 +470,10 @@ list(APPEND armnn_sources src/profiling/ICounterDirectory.hpp src/profiling/ICounterValues.hpp src/profiling/ISendCounterPacket.hpp - src/profiling/ISendTimelinePacket.hpp src/profiling/IPacketBuffer.hpp src/profiling/IPeriodicCounterCapture.hpp src/profiling/IProfilingConnection.hpp src/profiling/IProfilingConnectionFactory.hpp - src/profiling/IProfilingGuidGenerator.hpp src/profiling/LabelsAndEventClasses.cpp src/profiling/LabelsAndEventClasses.hpp src/profiling/Packet.hpp diff --git a/include/armnn/profiling/IProfilingGuidGenerator.hpp b/include/armnn/profiling/IProfilingGuidGenerator.hpp new file mode 100644 index 0000000000..fb9f7401fb --- /dev/null +++ b/include/armnn/profiling/IProfilingGuidGenerator.hpp @@ -0,0 +1,32 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include + +#include + +namespace armnn +{ + +namespace profiling +{ + +class IProfilingGuidGenerator +{ +public: + /// Return the next random Guid in the sequence + virtual ProfilingDynamicGuid NextGuid() = 0; + + /// Create a ProfilingStaticGuid based on a hash of the string + virtual ProfilingStaticGuid GenerateStaticId(const std::string& str) = 0; + + virtual ~IProfilingGuidGenerator() {} +}; + +} // namespace profiling + +} // namespace armnn diff --git a/include/armnn/profiling/ISendTimelinePacket.hpp b/include/armnn/profiling/ISendTimelinePacket.hpp new file mode 100644 index 0000000000..49a9fcf40e --- /dev/null +++ b/include/armnn/profiling/ISendTimelinePacket.hpp @@ -0,0 +1,61 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include +#include +#include +#include + +namespace armnn +{ + +namespace profiling +{ + +enum class ProfilingRelationshipType +{ + RetentionLink, /// Head retains(parents) Tail + ExecutionLink, /// Head execution start depends on Tail execution completion + DataLink, /// Head uses data of Tail + LabelLink /// Head uses label Tail (Tail MUST be a guid of a label). +}; + +class ISendTimelinePacket +{ +public: + virtual ~ISendTimelinePacket() + {} + + /// Commits the current buffer and reset the member variables + virtual void Commit() = 0; + + /// Create and write a TimelineEntityBinaryPacket from the parameters to the buffer. + virtual void SendTimelineEntityBinaryPacket(uint64_t profilingGuid) = 0; + + /// Create and write a TimelineEventBinaryPacket from the parameters to the buffer. + virtual void + SendTimelineEventBinaryPacket(uint64_t timestamp, std::thread::id threadId, uint64_t profilingGuid) = 0; + + /// Create and write a TimelineEventClassBinaryPacket from the parameters to the buffer. + virtual void SendTimelineEventClassBinaryPacket(uint64_t profilingGuid) = 0; + + /// Create and write a TimelineLabelBinaryPacket from the parameters to the buffer. + virtual void SendTimelineLabelBinaryPacket(uint64_t profilingGuid, const std::string& label) = 0; + + /// Create and write a TimelineMessageDirectoryPackage in the buffer + virtual void SendTimelineMessageDirectoryPackage() = 0; + + /// Create and write a TimelineRelationshipBinaryPacket from the parameters to the buffer. + virtual void SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, + uint64_t relationshipGuid, + uint64_t headGuid, + uint64_t tailGuid) = 0; +}; + +} // namespace profiling + +} // namespace armnn diff --git a/src/profiling/ConnectionAcknowledgedCommandHandler.hpp b/src/profiling/ConnectionAcknowledgedCommandHandler.hpp index 05559a3f9f..6054306da8 100644 --- a/src/profiling/ConnectionAcknowledgedCommandHandler.hpp +++ b/src/profiling/ConnectionAcknowledgedCommandHandler.hpp @@ -7,7 +7,7 @@ #include "CommandHandlerFunctor.hpp" #include "ISendCounterPacket.hpp" -#include "ISendTimelinePacket.hpp" +#include "armnn/profiling/ISendTimelinePacket.hpp" #include "Packet.hpp" #include "ProfilingStateMachine.hpp" diff --git a/src/profiling/IProfilingGuidGenerator.hpp b/src/profiling/IProfilingGuidGenerator.hpp deleted file mode 100644 index fb9f7401fb..0000000000 --- a/src/profiling/IProfilingGuidGenerator.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright © 2019 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include - -#include - -namespace armnn -{ - -namespace profiling -{ - -class IProfilingGuidGenerator -{ -public: - /// Return the next random Guid in the sequence - virtual ProfilingDynamicGuid NextGuid() = 0; - - /// Create a ProfilingStaticGuid based on a hash of the string - virtual ProfilingStaticGuid GenerateStaticId(const std::string& str) = 0; - - virtual ~IProfilingGuidGenerator() {} -}; - -} // namespace profiling - -} // namespace armnn diff --git a/src/profiling/ISendTimelinePacket.hpp b/src/profiling/ISendTimelinePacket.hpp deleted file mode 100644 index a95413455a..0000000000 --- a/src/profiling/ISendTimelinePacket.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// -// Copyright © 2019 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include "ProfilingUtils.hpp" - -#include -#include -#include -#include - -namespace armnn -{ - -namespace profiling -{ - -class ISendTimelinePacket -{ -public: - virtual ~ISendTimelinePacket() {} - - /// Commits the current buffer and reset the member variables - virtual void Commit() = 0; - - /// Create and write a TimelineEntityBinaryPacket from the parameters to the buffer. - virtual void SendTimelineEntityBinaryPacket(uint64_t profilingGuid) = 0; - - /// Create and write a TimelineEventBinaryPacket from the parameters to the buffer. - virtual void SendTimelineEventBinaryPacket(uint64_t timestamp, - std::thread::id threadId, - uint64_t profilingGuid) = 0; - - /// Create and write a TimelineEventClassBinaryPacket from the parameters to the buffer. - virtual void SendTimelineEventClassBinaryPacket(uint64_t profilingGuid) = 0; - - /// Create and write a TimelineLabelBinaryPacket from the parameters to the buffer. - virtual void SendTimelineLabelBinaryPacket(uint64_t profilingGuid, const std::string& label) = 0; - - /// Create and write a TimelineMessageDirectoryPackage in the buffer - virtual void SendTimelineMessageDirectoryPackage() = 0; - - /// Create and write a TimelineRelationshipBinaryPacket from the parameters to the buffer. - virtual void SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, - uint64_t relationshipGuid, - uint64_t headGuid, - uint64_t tailGuid) = 0; -}; - -} // namespace profiling - -} // namespace armnn - diff --git a/src/profiling/ProfilingGuidGenerator.hpp b/src/profiling/ProfilingGuidGenerator.hpp index 97de4a88e5..a31903585c 100644 --- a/src/profiling/ProfilingGuidGenerator.hpp +++ b/src/profiling/ProfilingGuidGenerator.hpp @@ -5,7 +5,7 @@ #pragma once -#include "IProfilingGuidGenerator.hpp" +#include "armnn/profiling/IProfilingGuidGenerator.hpp" #include diff --git a/src/profiling/ProfilingUtils.hpp b/src/profiling/ProfilingUtils.hpp index 9bbe421817..a63f255aea 100644 --- a/src/profiling/ProfilingUtils.hpp +++ b/src/profiling/ProfilingUtils.hpp @@ -6,6 +6,7 @@ #pragma once #include +#include #include "ICounterDirectory.hpp" #include "IPacketBuffer.hpp" @@ -16,8 +17,8 @@ #include #include #include -#include #include +#include namespace armnn { @@ -197,14 +198,6 @@ enum class TimelinePacketStatus BufferExhaustion }; -enum class ProfilingRelationshipType -{ - RetentionLink, /// Head retains(parents) Tail - ExecutionLink, /// Head execution start depends on Tail execution completion - DataLink, /// Head uses data of Tail - LabelLink /// Head uses label Tail (Tail MUST be a guid of a label). -}; - uint32_t CalculateSizeOfPaddedSwString(const std::string& str); SwTraceMessage ReadSwTraceMessage(const unsigned char*, unsigned int& offset); diff --git a/src/profiling/RequestCounterDirectoryCommandHandler.hpp b/src/profiling/RequestCounterDirectoryCommandHandler.hpp index 99c035240c..9ceca3f643 100644 --- a/src/profiling/RequestCounterDirectoryCommandHandler.hpp +++ b/src/profiling/RequestCounterDirectoryCommandHandler.hpp @@ -7,7 +7,7 @@ #include "CommandHandlerFunctor.hpp" #include "ISendCounterPacket.hpp" -#include "ISendTimelinePacket.hpp" +#include "armnn/profiling/ISendTimelinePacket.hpp" #include "Packet.hpp" #include "ProfilingStateMachine.hpp" diff --git a/src/profiling/SendTimelinePacket.hpp b/src/profiling/SendTimelinePacket.hpp index 4b2e06328b..737a1aa9a7 100644 --- a/src/profiling/SendTimelinePacket.hpp +++ b/src/profiling/SendTimelinePacket.hpp @@ -6,7 +6,7 @@ #pragma once #include "IBufferManager.hpp" -#include "ISendTimelinePacket.hpp" +#include "armnn/profiling/ISendTimelinePacket.hpp" #include "ProfilingUtils.hpp" #include diff --git a/src/profiling/TimelinePacketWriterFactory.hpp b/src/profiling/TimelinePacketWriterFactory.hpp index 1bbd3fd60f..a1e9945303 100644 --- a/src/profiling/TimelinePacketWriterFactory.hpp +++ b/src/profiling/TimelinePacketWriterFactory.hpp @@ -6,7 +6,7 @@ #pragma once #include "IBufferManager.hpp" -#include "ISendTimelinePacket.hpp" +#include "armnn/profiling/ISendTimelinePacket.hpp" #include diff --git a/src/profiling/TimelineUtilityMethods.hpp b/src/profiling/TimelineUtilityMethods.hpp index 5b00ec8738..c33dd92193 100644 --- a/src/profiling/TimelineUtilityMethods.hpp +++ b/src/profiling/TimelineUtilityMethods.hpp @@ -5,7 +5,7 @@ #pragma once -#include "ISendTimelinePacket.hpp" +#include "armnn/profiling/ISendTimelinePacket.hpp" #include namespace armnn -- cgit v1.2.1