aboutsummaryrefslogtreecommitdiff
path: root/profiling
diff options
context:
space:
mode:
authorJim Flynn <jim.flynn@arm.com>2022-03-20 21:52:17 +0000
committerJim Flynn <jim.flynn@arm.com>2022-03-23 20:32:03 +0000
commit277618302d0f131eac0b6ac2015dd3eb09aa6ff9 (patch)
treee468fa1362640484b508812596fb5c1b62186882 /profiling
parenta3bc0b4976395226c0fa0898b26098c4534edbdb (diff)
downloadarmnn-277618302d0f131eac0b6ac2015dd3eb09aa6ff9.tar.gz
IVGCVSW-6706 Move headers to profiling/client/include
!android-nn-driver:7337 Change-Id: Ide401623829cc99fb9b51e9bbce3482ce706a8dd Signed-off-by: Jim Flynn <jim.flynn@arm.com>
Diffstat (limited to 'profiling')
-rw-r--r--profiling/CMakeLists.txt1
-rw-r--r--profiling/client/include/CounterIdMap.hpp51
-rw-r--r--profiling/client/include/Holder.hpp67
-rw-r--r--profiling/client/include/ICounterValues.hpp47
-rw-r--r--profiling/client/include/IInitialiseProfilingService.hpp26
-rw-r--r--profiling/client/include/ILocalPacketHandler.hpp68
-rw-r--r--profiling/client/include/IProfilingService.hpp81
-rw-r--r--profiling/client/include/IProfilingServiceStatus.hpp30
-rw-r--r--profiling/client/include/IReportStructure.hpp26
-rw-r--r--profiling/client/include/ISendCounterPacket.hpp41
-rw-r--r--profiling/client/include/ISendTimelinePacket.hpp61
-rw-r--r--profiling/client/include/ProfilingOptions.hpp45
-rw-r--r--profiling/client/include/ProfilingState.hpp24
-rw-r--r--profiling/client/include/TimelineUtilityMethods.hpp98
-rw-r--r--profiling/client/include/backends/IBackendProfiling.hpp106
-rw-r--r--profiling/client/include/backends/IBackendProfilingContext.hpp30
-rw-r--r--profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp1
17 files changed, 802 insertions, 1 deletions
diff --git a/profiling/CMakeLists.txt b/profiling/CMakeLists.txt
index f9ffd66433..265c5365c7 100644
--- a/profiling/CMakeLists.txt
+++ b/profiling/CMakeLists.txt
@@ -22,6 +22,7 @@ add_custom_target(AdditionalCMakeFiles SOURCES ${additional_cmake_files})
include(GNUInstallDirs)
include_directories(SYSTEM common/include)
+include_directories(SYSTEM client/include)
include_directories(SYSTEM ${PROJECT_SOURCE_DIR})
set(BUILD_UNIT_TESTS 0)
diff --git a/profiling/client/include/CounterIdMap.hpp b/profiling/client/include/CounterIdMap.hpp
new file mode 100644
index 0000000000..cce7184c46
--- /dev/null
+++ b/profiling/client/include/CounterIdMap.hpp
@@ -0,0 +1,51 @@
+//
+// Copyright © 2020 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#pragma once
+
+#include <map>
+#include <string>
+
+namespace arm
+{
+namespace pipe
+{
+
+class ICounterMappings
+{
+public:
+ virtual uint16_t GetGlobalId(uint16_t backendCounterId, const std::string& backendId) const = 0;
+ virtual const std::pair<uint16_t, std::string>& GetBackendId(uint16_t globalCounterId) const = 0;
+ virtual ~ICounterMappings() {}
+};
+
+class IRegisterCounterMapping
+{
+public:
+ virtual void RegisterMapping(uint16_t globalCounterId,
+ uint16_t backendCounterId,
+ const std::string& backendId) = 0;
+ virtual void Reset() = 0;
+ virtual ~IRegisterCounterMapping() {}
+};
+
+class CounterIdMap : public ICounterMappings, public IRegisterCounterMapping
+{
+
+public:
+ CounterIdMap() = default;
+ virtual ~CounterIdMap() {}
+ void RegisterMapping(uint16_t globalCounterId,
+ uint16_t backendCounterId,
+ const std::string& backendId) override;
+ void Reset() override;
+ uint16_t GetGlobalId(uint16_t backendCounterId, const std::string& backendId) const override;
+ const std::pair<uint16_t, std::string>& GetBackendId(uint16_t globalCounterId) const override;
+private:
+ std::map<uint16_t, std::pair<uint16_t, std::string>> m_GlobalCounterIdMap;
+ std::map<std::pair<uint16_t, std::string>, uint16_t> m_BackendCounterIdMap;
+};
+
+} // namespace pipe
+} // namespace arm
diff --git a/profiling/client/include/Holder.hpp b/profiling/client/include/Holder.hpp
new file mode 100644
index 0000000000..db5468feda
--- /dev/null
+++ b/profiling/client/include/Holder.hpp
@@ -0,0 +1,67 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <mutex>
+#include <vector>
+#include <set>
+
+namespace arm
+{
+
+namespace pipe
+{
+
+class CaptureData
+{
+public:
+ CaptureData()
+ : m_CapturePeriod(0)
+ , m_CounterIds()
+ , m_ActiveBackends(){}
+ CaptureData(uint32_t capturePeriod, std::vector<uint16_t>& counterIds, std::set<std::string> activeBackends)
+ : m_CapturePeriod(capturePeriod)
+ , m_CounterIds(counterIds)
+ , m_ActiveBackends(activeBackends){}
+ CaptureData(const CaptureData& captureData)
+ : m_CapturePeriod(captureData.m_CapturePeriod)
+ , m_CounterIds(captureData.m_CounterIds)
+ , m_ActiveBackends(captureData.m_ActiveBackends){}
+
+ CaptureData& operator=(const CaptureData& other);
+
+ void SetActiveBackends(const std::set<std::string>& activeBackends);
+ void SetCapturePeriod(uint32_t capturePeriod);
+ void SetCounterIds(const std::vector<uint16_t>& counterIds);
+ uint32_t GetCapturePeriod() const;
+ const std::vector<uint16_t>& GetCounterIds() const;
+ const std::set<std::string>& GetActiveBackends() const;
+ bool IsCounterIdInCaptureData(uint16_t counterId);
+
+private:
+ uint32_t m_CapturePeriod;
+ std::vector<uint16_t> m_CounterIds;
+ std::set<std::string> m_ActiveBackends;
+};
+
+class Holder
+{
+public:
+ Holder()
+ : m_CaptureData() {}
+ CaptureData GetCaptureData() const;
+ void SetCaptureData(uint32_t capturePeriod,
+ const std::vector<uint16_t>& counterIds,
+ const std::set<std::string>& activeBackends);
+
+private:
+ mutable std::mutex m_CaptureThreadMutex;
+ CaptureData m_CaptureData;
+};
+
+} // namespace pipe
+
+} // namespace arm
diff --git a/profiling/client/include/ICounterValues.hpp b/profiling/client/include/ICounterValues.hpp
new file mode 100644
index 0000000000..a851c6b3f3
--- /dev/null
+++ b/profiling/client/include/ICounterValues.hpp
@@ -0,0 +1,47 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <cstdint>
+
+namespace arm
+{
+
+namespace pipe
+{
+
+class IReadCounterValues
+{
+public:
+ virtual ~IReadCounterValues() {}
+
+ virtual bool IsCounterRegistered(uint16_t counterUid) const = 0;
+ virtual bool IsCounterRegistered(const std::string& counterName) const = 0;
+ virtual uint16_t GetCounterCount() const = 0;
+ virtual uint32_t GetAbsoluteCounterValue(uint16_t counterUid) const = 0;
+ virtual uint32_t GetDeltaCounterValue(uint16_t counterUid) = 0;
+};
+
+class IWriteCounterValues
+{
+public:
+ virtual ~IWriteCounterValues() {}
+
+ virtual void SetCounterValue(uint16_t counterUid, uint32_t value) = 0;
+ virtual uint32_t AddCounterValue(uint16_t counterUid, uint32_t value) = 0;
+ virtual uint32_t SubtractCounterValue(uint16_t counterUid, uint32_t value) = 0;
+ virtual uint32_t IncrementCounterValue(uint16_t counterUid) = 0;
+};
+
+class IReadWriteCounterValues : public IReadCounterValues, public IWriteCounterValues
+{
+public:
+ virtual ~IReadWriteCounterValues() {}
+};
+
+} // namespace pipe
+
+} // namespace arm
diff --git a/profiling/client/include/IInitialiseProfilingService.hpp b/profiling/client/include/IInitialiseProfilingService.hpp
new file mode 100644
index 0000000000..fc3f4b9a5d
--- /dev/null
+++ b/profiling/client/include/IInitialiseProfilingService.hpp
@@ -0,0 +1,26 @@
+//
+// Copyright © 2022 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+namespace arm
+{
+
+namespace pipe
+{
+
+// forward declaration
+class IProfilingService;
+
+class IInitialiseProfilingService
+{
+public:
+ virtual ~IInitialiseProfilingService() {}
+ virtual void InitialiseProfilingService(IProfilingService& profilingService) = 0;
+};
+
+} // namespace pipe
+
+} // namespace arm
diff --git a/profiling/client/include/ILocalPacketHandler.hpp b/profiling/client/include/ILocalPacketHandler.hpp
new file mode 100644
index 0000000000..0a69f27491
--- /dev/null
+++ b/profiling/client/include/ILocalPacketHandler.hpp
@@ -0,0 +1,68 @@
+//
+// Copyright © 2020 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+
+#include <common/include/IgnoreUnused.hpp>
+#include <common/include/TargetEndianess.hpp>
+
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+// forward declare to prevent a circular dependency
+namespace arm
+{
+namespace pipe
+{
+
+class Packet;
+
+// the handlers need to be able to do two
+// things to service the FileOnlyProfilingConnection
+// and any other implementation of IProfilingConnection
+// set the endianness and write a packet back i.e.
+// return a packet and close the connection
+class IInternalProfilingConnection
+{
+public:
+ virtual ~IInternalProfilingConnection() {};
+
+ virtual void SetEndianess(const TargetEndianness& endianness) = 0;
+
+ virtual void ReturnPacket(Packet& packet) = 0;
+
+ virtual void Close() = 0;
+};
+
+class ILocalPacketHandler
+{
+public:
+ virtual ~ILocalPacketHandler() {};
+
+ /// @return lists the headers of the packets that this handler accepts
+ /// only these packets will get sent to this handler.
+ /// If this function returns an empty list then ALL packets
+ /// will be sent to the PacketHandler i.e. a universal handler.
+ virtual std::vector<uint32_t> GetHeadersAccepted() = 0;
+
+ /// process the packet
+ virtual void HandlePacket(const Packet& packet) = 0;
+
+ /// Set a profiling connection on the handler. Only need to implement this
+ /// function if the handler will be writing data back to the profiled application.
+ virtual void SetConnection(IInternalProfilingConnection* profilingConnection)
+ {
+ arm::pipe::IgnoreUnused(profilingConnection);
+ }
+};
+
+using ILocalPacketHandlerPtr = std::unique_ptr<ILocalPacketHandler>;
+using ILocalPacketHandlerSharedPtr = std::shared_ptr<ILocalPacketHandler>;
+
+} // namespace pipe
+
+} // namespace arm
diff --git a/profiling/client/include/IProfilingService.hpp b/profiling/client/include/IProfilingService.hpp
new file mode 100644
index 0000000000..21d5c9ce77
--- /dev/null
+++ b/profiling/client/include/IProfilingService.hpp
@@ -0,0 +1,81 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "CounterIdMap.hpp"
+#include "Holder.hpp"
+#include "ICounterValues.hpp"
+#include "IInitialiseProfilingService.hpp"
+#include "IProfilingServiceStatus.hpp"
+#include "ISendCounterPacket.hpp"
+#include "IReportStructure.hpp"
+#include "ProfilingOptions.hpp"
+#include "ProfilingState.hpp"
+
+#include <client/include/backends/IBackendProfilingContext.hpp>
+
+#include <common/include/ICounterRegistry.hpp>
+#include <common/include/Optional.hpp>
+#include <common/include/ProfilingGuidGenerator.hpp>
+
+
+namespace arm
+{
+
+namespace pipe
+{
+
+class IProfilingService : public IProfilingGuidGenerator,
+ public IProfilingServiceStatus,
+ public IReadWriteCounterValues
+{
+public:
+ static std::unique_ptr<IProfilingService> CreateProfilingService(
+ uint16_t maxGlobalCounterId,
+ IInitialiseProfilingService& initialiser,
+ const std::string& softwareInfo,
+ const std::string& softwareVersion,
+ const std::string& hardwareVersion,
+ arm::pipe::Optional<IReportStructure&> reportStructure = arm::pipe::EmptyOptional());
+ virtual ~IProfilingService() {};
+ virtual std::unique_ptr<ISendTimelinePacket> GetSendTimelinePacket() const = 0;
+ virtual const ICounterMappings& GetCounterMappings() const = 0;
+ virtual ISendCounterPacket& GetSendCounterPacket() = 0;
+ virtual bool IsProfilingEnabled() const = 0;
+ virtual bool IsTimelineReportingEnabled() const = 0;
+ virtual CaptureData GetCaptureData() = 0;
+ virtual ProfilingState GetCurrentState() const = 0;
+ // Resets the profiling options, optionally clears the profiling service entirely
+ virtual void ResetExternalProfilingOptions(const ProfilingOptions& options,
+ bool resetProfilingService = false) = 0;
+ virtual ProfilingState ConfigureProfilingService(const ProfilingOptions& options,
+ bool resetProfilingService = false) = 0;
+ // Store a profiling context returned from a backend that support profiling.
+ virtual void AddBackendProfilingContext(const std::string& backendId,
+ std::shared_ptr<IBackendProfilingContext> profilingContext) = 0;
+ virtual ICounterRegistry& GetCounterRegistry() = 0;
+ virtual IRegisterCounterMapping& GetCounterMappingRegistry() = 0;
+ virtual bool IsCategoryRegistered(const std::string& categoryName) const = 0;
+ virtual void InitializeCounterValue(uint16_t counterUid) = 0;
+
+ // IProfilingGuidGenerator functions
+ /// Return the next random Guid in the sequence
+ ProfilingDynamicGuid NextGuid() override;
+ /// Create a ProfilingStaticGuid based on a hash of the string
+ ProfilingStaticGuid GenerateStaticId(const std::string& str) override;
+ static ProfilingDynamicGuid GetNextGuid();
+ static ProfilingStaticGuid GetStaticId(const std::string& str);
+ void ResetGuidGenerator();
+
+ virtual void Disconnect() = 0;
+
+private:
+ static ProfilingGuidGenerator m_GuidGenerator;
+};
+
+} // namespace pipe
+
+} // namespace arm
diff --git a/profiling/client/include/IProfilingServiceStatus.hpp b/profiling/client/include/IProfilingServiceStatus.hpp
new file mode 100644
index 0000000000..f979e740f0
--- /dev/null
+++ b/profiling/client/include/IProfilingServiceStatus.hpp
@@ -0,0 +1,30 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "ILocalPacketHandler.hpp"
+
+#include <common/include/Packet.hpp>
+
+#include <cstdint>
+
+namespace arm
+{
+
+namespace pipe
+{
+
+class IProfilingServiceStatus
+{
+public:
+ virtual void NotifyProfilingServiceActive() = 0;
+ virtual void WaitForProfilingServiceActivation(unsigned int timeout) = 0;
+ virtual ~IProfilingServiceStatus() {};
+};
+
+} // namespace pipe
+
+} // namespace arm
diff --git a/profiling/client/include/IReportStructure.hpp b/profiling/client/include/IReportStructure.hpp
new file mode 100644
index 0000000000..8891cbd3b0
--- /dev/null
+++ b/profiling/client/include/IReportStructure.hpp
@@ -0,0 +1,26 @@
+//
+// Copyright © 2020 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+namespace arm
+{
+
+namespace pipe
+{
+
+class IProfilingService;
+
+class IReportStructure
+{
+public:
+ virtual ~IReportStructure() {}
+ virtual void ReportStructure(arm::pipe::IProfilingService& profilingService) = 0;
+};
+
+} // namespace pipe
+
+} // namespace arm
+
diff --git a/profiling/client/include/ISendCounterPacket.hpp b/profiling/client/include/ISendCounterPacket.hpp
new file mode 100644
index 0000000000..c76150fc58
--- /dev/null
+++ b/profiling/client/include/ISendCounterPacket.hpp
@@ -0,0 +1,41 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <client/include/backends/IBackendProfiling.hpp>
+
+#include <common/include/ICounterDirectory.hpp>
+
+namespace arm
+{
+
+namespace pipe
+{
+
+class ISendCounterPacket
+{
+public:
+ using IndexValuePairsVector = std::vector<CounterValue>;
+
+ virtual ~ISendCounterPacket() {}
+
+ /// Create and write a StreamMetaDataPacket in the buffer
+ virtual void SendStreamMetaDataPacket() = 0;
+
+ /// Create and write a CounterDirectoryPacket from the parameters to the buffer.
+ virtual void SendCounterDirectoryPacket(const ICounterDirectory& counterDirectory) = 0;
+
+ /// Create and write a PeriodicCounterCapturePacket from the parameters to the buffer.
+ virtual void SendPeriodicCounterCapturePacket(uint64_t timestamp, const IndexValuePairsVector& values) = 0;
+
+ /// Create and write a PeriodicCounterSelectionPacket from the parameters to the buffer.
+ virtual void SendPeriodicCounterSelectionPacket(uint32_t capturePeriod,
+ const std::vector<uint16_t>& selectedCounterIds) = 0;
+};
+
+} // namespace pipe
+
+} // namespace arm
diff --git a/profiling/client/include/ISendTimelinePacket.hpp b/profiling/client/include/ISendTimelinePacket.hpp
new file mode 100644
index 0000000000..4785e04ef8
--- /dev/null
+++ b/profiling/client/include/ISendTimelinePacket.hpp
@@ -0,0 +1,61 @@
+//
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <algorithm>
+#include <string>
+#include <vector>
+
+namespace arm
+{
+
+namespace pipe
+{
+
+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, int threadId, uint64_t profilingGuid) = 0;
+
+ /// Create and write a TimelineEventClassBinaryPacket from the parameters to the buffer.
+ virtual void SendTimelineEventClassBinaryPacket(uint64_t profilingGuid, uint64_t nameGuid) = 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,
+ uint64_t attributeGuid) = 0;
+};
+
+} // namespace pipe
+
+} // namespace arm
diff --git a/profiling/client/include/ProfilingOptions.hpp b/profiling/client/include/ProfilingOptions.hpp
new file mode 100644
index 0000000000..30d383d92e
--- /dev/null
+++ b/profiling/client/include/ProfilingOptions.hpp
@@ -0,0 +1,45 @@
+//
+// Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "ILocalPacketHandler.hpp"
+
+#include <string>
+#include <vector>
+
+namespace arm
+{
+namespace pipe
+{
+/// The lowest performance data capture interval we support is 10 miliseconds.
+constexpr unsigned int LOWEST_CAPTURE_PERIOD = 10000u;
+
+struct ProfilingOptions {
+ ProfilingOptions()
+ : m_EnableProfiling(false), m_TimelineEnabled(false), m_OutgoingCaptureFile(""),
+ m_IncomingCaptureFile(""), m_FileOnly(false), m_CapturePeriod(arm::pipe::LOWEST_CAPTURE_PERIOD),
+ m_FileFormat("binary"), m_LocalPacketHandlers() {}
+
+ /// Indicates whether external profiling is enabled or not.
+ bool m_EnableProfiling;
+ /// Indicates whether external timeline profiling is enabled or not.
+ bool m_TimelineEnabled;
+ /// Path to a file in which outgoing timeline profiling messages will be stored.
+ std::string m_OutgoingCaptureFile;
+ /// Path to a file in which incoming timeline profiling messages will be stored.
+ std::string m_IncomingCaptureFile;
+ /// Enable profiling output to file only.
+ bool m_FileOnly;
+ /// The duration at which captured profiling messages will be flushed.
+ uint32_t m_CapturePeriod;
+ /// The format of the file used for outputting profiling data.
+ std::string m_FileFormat;
+ std::vector <ILocalPacketHandlerSharedPtr> m_LocalPacketHandlers;
+};
+
+} // namespace pipe
+
+} // namespace arm
diff --git a/profiling/client/include/ProfilingState.hpp b/profiling/client/include/ProfilingState.hpp
new file mode 100644
index 0000000000..0fc1903118
--- /dev/null
+++ b/profiling/client/include/ProfilingState.hpp
@@ -0,0 +1,24 @@
+//
+// Copyright © 2022 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+namespace arm
+{
+
+namespace pipe
+{
+
+enum class ProfilingState
+{
+ Uninitialised,
+ NotConnected,
+ WaitingForAck,
+ Active
+};
+
+} // namespace pipe
+
+} // namespace arm
diff --git a/profiling/client/include/TimelineUtilityMethods.hpp b/profiling/client/include/TimelineUtilityMethods.hpp
new file mode 100644
index 0000000000..5bb4e5ead0
--- /dev/null
+++ b/profiling/client/include/TimelineUtilityMethods.hpp
@@ -0,0 +1,98 @@
+//
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <client/include/IProfilingService.hpp>
+#include <client/include/ISendTimelinePacket.hpp>
+
+namespace arm
+{
+
+namespace pipe
+{
+
+class TimelineUtilityMethods
+{
+public:
+
+ // static factory method which will return a pointer to a timelie utility methods
+ // object if profiling is enabled. Otherwise will return a null unique_ptr
+ static std::unique_ptr<TimelineUtilityMethods> GetTimelineUtils(IProfilingService& profilingService);
+
+ TimelineUtilityMethods(
+ std::unique_ptr<ISendTimelinePacket>& sendTimelinePacket)
+ : m_SendTimelinePacket(std::move(sendTimelinePacket)) {}
+
+ TimelineUtilityMethods(TimelineUtilityMethods&& other)
+ : m_SendTimelinePacket(std::move(other.m_SendTimelinePacket)) {}
+
+ TimelineUtilityMethods(const TimelineUtilityMethods& other) = delete;
+
+ TimelineUtilityMethods& operator=(const TimelineUtilityMethods& other) = delete;
+
+ TimelineUtilityMethods& operator=(TimelineUtilityMethods&& other) = default;
+
+ ~TimelineUtilityMethods() = default;
+
+ static void SendWellKnownLabelsAndEventClasses(ISendTimelinePacket& timelinePacket);
+
+ ProfilingDynamicGuid CreateNamedTypedEntity(const std::string& name, const std::string& type);
+
+ void CreateNamedTypedEntity(ProfilingGuid entityGuid, const std::string& name, const std::string& type);
+
+ void CreateNamedTypedEntity(ProfilingGuid entityGuid, const std::string& name, ProfilingStaticGuid typeGuid);
+
+ void MarkEntityWithLabel(ProfilingGuid entityGuid, const std::string& labelName, ProfilingStaticGuid labelLinkGuid);
+
+ ProfilingStaticGuid DeclareLabel(const std::string& labelName);
+
+ void NameEntity(ProfilingGuid entityGuid, const std::string& name);
+
+ void TypeEntity(ProfilingGuid entityGuid, const std::string& type);
+
+ ProfilingDynamicGuid CreateNamedTypedChildEntity(ProfilingGuid parentEntityGuid,
+ const std::string& entityName,
+ const std::string& entityType);
+
+ void CreateNamedTypedChildEntity(ProfilingGuid entityGuid,
+ ProfilingGuid parentEntityGuid,
+ const std::string& entityName,
+ const std::string& entityType);
+
+ void CreateNamedTypedChildEntity(ProfilingGuid entityGuid,
+ ProfilingGuid parentEntityGuid,
+ const std::string& entityName,
+ ProfilingStaticGuid typeGuid);
+
+ ProfilingDynamicGuid CreateRelationship(ProfilingRelationshipType relationshipType,
+ ProfilingGuid headGuid,
+ ProfilingGuid tailGuid,
+ ProfilingGuid relationshipCategory);
+
+ ProfilingDynamicGuid CreateConnectionRelationship(ProfilingRelationshipType relationshipType,
+ ProfilingGuid headGuid,
+ ProfilingGuid tailGuid);
+
+ void CreateTypedEntity(ProfilingGuid entityGuid, ProfilingStaticGuid typeGuid);
+
+ void MarkEntityWithType(ProfilingGuid entityGuid, ProfilingStaticGuid typeNameGuid);
+
+ ProfilingDynamicGuid RecordEvent(ProfilingGuid entityGuid, ProfilingStaticGuid eventClassGuid);
+
+ ProfilingDynamicGuid RecordWorkloadInferenceAndStartOfLifeEvent(ProfilingGuid workloadGuid,
+ ProfilingGuid inferenceGuid);
+
+ void RecordEndOfLifeEvent(ProfilingGuid entityGuid);
+
+ void Commit() { m_SendTimelinePacket->Commit(); }
+
+private:
+ std::unique_ptr<ISendTimelinePacket> m_SendTimelinePacket;
+};
+
+} // namespace pipe
+
+} // namespace arm
diff --git a/profiling/client/include/backends/IBackendProfiling.hpp b/profiling/client/include/backends/IBackendProfiling.hpp
new file mode 100644
index 0000000000..347d2ddf03
--- /dev/null
+++ b/profiling/client/include/backends/IBackendProfiling.hpp
@@ -0,0 +1,106 @@
+//
+// Copyright © 2020 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#pragma once
+
+#include <client/include/ISendTimelinePacket.hpp>
+
+#include <common/include/IProfilingGuidGenerator.hpp>
+#include <common/include/Optional.hpp>
+
+#include <memory>
+#include <vector>
+
+namespace arm
+{
+
+namespace pipe
+{
+
+struct CounterValue
+{
+ CounterValue(uint16_t id, uint32_t value) :
+ counterId(id), counterValue(value) {}
+ uint16_t counterId;
+ uint32_t counterValue;
+};
+
+struct Timestamp
+{
+ uint64_t timestamp;
+ std::vector<CounterValue> counterValues;
+};
+
+struct CounterStatus
+{
+ CounterStatus(uint16_t backendCounterId,
+ uint16_t globalCounterId,
+ bool enabled,
+ uint32_t samplingRateInMicroseconds)
+ : m_BackendCounterId(backendCounterId),
+ m_GlobalCounterId(globalCounterId),
+ m_Enabled(enabled),
+ m_SamplingRateInMicroseconds(samplingRateInMicroseconds) {}
+ uint16_t m_BackendCounterId;
+ uint16_t m_GlobalCounterId;
+ bool m_Enabled;
+ uint32_t m_SamplingRateInMicroseconds;
+};
+
+class IRegisterBackendCounters
+{
+public:
+ virtual void RegisterCategory(const std::string& categoryName) = 0;
+
+ virtual uint16_t RegisterDevice(const std::string& deviceName,
+ uint16_t cores = 0,
+ const arm::pipe::Optional<std::string>& parentCategoryName
+ = arm::pipe::EmptyOptional()) = 0;
+
+ virtual uint16_t RegisterCounterSet(const std::string& counterSetName,
+ uint16_t count = 0,
+ const arm::pipe::Optional<std::string>& parentCategoryName
+ = arm::pipe::EmptyOptional()) = 0;
+
+ virtual uint16_t RegisterCounter(const uint16_t uid,
+ const std::string& parentCategoryName,
+ uint16_t counterClass,
+ uint16_t interpolation,
+ double multiplier,
+ const std::string& name,
+ const std::string& description,
+ const arm::pipe::Optional<std::string>& units = arm::pipe::EmptyOptional(),
+ const arm::pipe::Optional<uint16_t>& numberOfCores = arm::pipe::EmptyOptional(),
+ const arm::pipe::Optional<uint16_t>& deviceUid = arm::pipe::EmptyOptional(),
+ const arm::pipe::Optional<uint16_t>& counterSetUid = arm::pipe::EmptyOptional()) = 0;
+
+ virtual ~IRegisterBackendCounters() {}
+};
+
+class IBackendProfiling
+{
+public:
+ virtual ~IBackendProfiling()
+ {}
+
+ virtual std::unique_ptr<IRegisterBackendCounters>
+ GetCounterRegistrationInterface(uint16_t currentMaxGlobalCounterID) = 0;
+
+ virtual std::unique_ptr<ISendTimelinePacket> GetSendTimelinePacket() = 0;
+
+ virtual IProfilingGuidGenerator& GetProfilingGuidGenerator() = 0;
+
+ virtual void ReportCounters(const std::vector<Timestamp>& counterValues) = 0;
+
+ virtual CounterStatus GetCounterStatus(uint16_t backendCounterId) = 0;
+
+ virtual std::vector<CounterStatus> GetActiveCounters() = 0;
+
+ virtual bool IsProfilingEnabled() const = 0;
+
+};
+
+} // namespace pipe
+
+} // namespace arm
diff --git a/profiling/client/include/backends/IBackendProfilingContext.hpp b/profiling/client/include/backends/IBackendProfilingContext.hpp
new file mode 100644
index 0000000000..a1ed05e43d
--- /dev/null
+++ b/profiling/client/include/backends/IBackendProfilingContext.hpp
@@ -0,0 +1,30 @@
+//
+// Copyright © 2020 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#pragma once
+
+#include "IBackendProfiling.hpp"
+#include <vector>
+
+namespace arm
+{
+namespace pipe
+{
+
+class IBackendProfilingContext
+{
+public:
+ virtual ~IBackendProfilingContext()
+ {}
+ virtual uint16_t RegisterCounters(uint16_t currentMaxGlobalCounterID) = 0;
+ virtual arm::pipe::Optional<std::string> ActivateCounters(
+ uint32_t capturePeriod, const std::vector<uint16_t>& counterIds) = 0;
+ virtual std::vector<Timestamp> ReportCounterValues() = 0;
+ virtual bool EnableProfiling(bool flag) = 0;
+ virtual bool EnableTimelineReporting(bool flag) = 0;
+};
+
+using IBackendProfilingContextUniquePtr = std::unique_ptr<IBackendProfilingContext>;
+} // namespace pipe
+} // namespace arm
diff --git a/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp b/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp
index 516e648ce4..ebf408ef7f 100644
--- a/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp
+++ b/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp
@@ -14,7 +14,6 @@
TEST_SUITE("BasePipeServerTests")
{
-using namespace armnn;
using namespace arm::pipe;
TEST_CASE("BasePipeServerTest")