blob: 353059aec332e5c3b6f833fb0909a5dfd084aabd [file] [log] [blame]
Jim Flynn64063552020-02-14 10:18:08 +00001//
Jim Flynn6398a982020-05-27 17:05:21 +01002// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
Jim Flynn64063552020-02-14 10:18:08 +00003// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8#include "CounterIdMap.hpp"
9#include "Holder.hpp"
Jim Flynnaf947722022-03-02 11:04:47 +000010#include "ICounterValues.hpp"
Jim Flynn34430252022-03-04 15:03:58 +000011#include "IInitialiseProfilingService.hpp"
Jim Flynn6398a982020-05-27 17:05:21 +010012#include "IProfilingServiceStatus.hpp"
Jim Flynn64063552020-02-14 10:18:08 +000013#include "ISendCounterPacket.hpp"
Jim Flynnaf947722022-03-02 11:04:47 +000014#include "IReportStructure.hpp"
15#include "ProfilingState.hpp"
Nikhil Raj5b1bcc92021-06-08 12:31:50 +010016
Jim Flynnaf947722022-03-02 11:04:47 +000017#include <armnn/backends/profiling/IBackendProfilingContext.hpp>
18#include <armnn/profiling/ProfilingOptions.hpp>
Jim Flynndecd08b2022-03-13 22:35:46 +000019
Jim Flynnc454ac92022-03-16 18:43:18 +000020#include <common/include/ICounterRegistry.hpp>
Jim Flynndecd08b2022-03-13 22:35:46 +000021#include <common/include/Optional.hpp>
Nikhil Raj5b1bcc92021-06-08 12:31:50 +010022#include <common/include/ProfilingGuidGenerator.hpp>
Jim Flynn64063552020-02-14 10:18:08 +000023
Jim Flynnc454ac92022-03-16 18:43:18 +000024
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000025namespace arm
Jim Flynn64063552020-02-14 10:18:08 +000026{
27
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000028namespace pipe
Jim Flynn64063552020-02-14 10:18:08 +000029{
30
Jim Flynnaf947722022-03-02 11:04:47 +000031class IProfilingService : public IProfilingGuidGenerator,
32 public IProfilingServiceStatus,
33 public IReadWriteCounterValues
Jim Flynn64063552020-02-14 10:18:08 +000034{
35public:
Jim Flynnaf947722022-03-02 11:04:47 +000036 static std::unique_ptr<IProfilingService> CreateProfilingService(
Jim Flynn34430252022-03-04 15:03:58 +000037 uint16_t maxGlobalCounterId,
38 IInitialiseProfilingService& initialiser,
Jim Flynn9c85b412022-03-16 00:27:43 +000039 const std::string& softwareInfo,
40 const std::string& softwareVersion,
41 const std::string& hardwareVersion,
Jim Flynndecd08b2022-03-13 22:35:46 +000042 arm::pipe::Optional<IReportStructure&> reportStructure = arm::pipe::EmptyOptional());
Jim Flynn64063552020-02-14 10:18:08 +000043 virtual ~IProfilingService() {};
44 virtual std::unique_ptr<ISendTimelinePacket> GetSendTimelinePacket() const = 0;
45 virtual const ICounterMappings& GetCounterMappings() const = 0;
46 virtual ISendCounterPacket& GetSendCounterPacket() = 0;
47 virtual bool IsProfilingEnabled() const = 0;
Jim Flynnaf947722022-03-02 11:04:47 +000048 virtual bool IsTimelineReportingEnabled() const = 0;
Jim Flynn64063552020-02-14 10:18:08 +000049 virtual CaptureData GetCaptureData() = 0;
Jim Flynnaf947722022-03-02 11:04:47 +000050 virtual ProfilingState GetCurrentState() const = 0;
51 // Resets the profiling options, optionally clears the profiling service entirely
52 virtual void ResetExternalProfilingOptions(const ProfilingOptions& options,
53 bool resetProfilingService = false) = 0;
54 virtual ProfilingState ConfigureProfilingService(const ProfilingOptions& options,
55 bool resetProfilingService = false) = 0;
56 // Store a profiling context returned from a backend that support profiling.
Cathal Corbett6f073722022-03-04 12:11:09 +000057 virtual void AddBackendProfilingContext(const std::string& backendId,
Jim Flynnaf947722022-03-02 11:04:47 +000058 std::shared_ptr<IBackendProfilingContext> profilingContext) = 0;
59 virtual ICounterRegistry& GetCounterRegistry() = 0;
60 virtual IRegisterCounterMapping& GetCounterMappingRegistry() = 0;
Jim Flynn34430252022-03-04 15:03:58 +000061 virtual bool IsCategoryRegistered(const std::string& categoryName) const = 0;
62 virtual void InitializeCounterValue(uint16_t counterUid) = 0;
63
Jim Flynnaf947722022-03-02 11:04:47 +000064 // IProfilingGuidGenerator functions
65 /// Return the next random Guid in the sequence
66 ProfilingDynamicGuid NextGuid() override;
67 /// Create a ProfilingStaticGuid based on a hash of the string
68 ProfilingStaticGuid GenerateStaticId(const std::string& str) override;
69 static ProfilingDynamicGuid GetNextGuid();
70 static ProfilingStaticGuid GetStaticId(const std::string& str);
71 void ResetGuidGenerator();
72
Jim Flynn34430252022-03-04 15:03:58 +000073 virtual void Disconnect() = 0;
74
Jim Flynnaf947722022-03-02 11:04:47 +000075private:
76 static ProfilingGuidGenerator m_GuidGenerator;
Jim Flynn64063552020-02-14 10:18:08 +000077};
78
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000079} // namespace pipe
Jim Flynn64063552020-02-14 10:18:08 +000080
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000081} // namespace arm