blob: bc16860029bafdaa3123de531c4577daf7fea626 [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"
11#include "ICounterRegistry.hpp"
Jim Flynn34430252022-03-04 15:03:58 +000012#include "IInitialiseProfilingService.hpp"
Jim Flynn6398a982020-05-27 17:05:21 +010013#include "IProfilingServiceStatus.hpp"
Jim Flynn64063552020-02-14 10:18:08 +000014#include "ISendCounterPacket.hpp"
Jim Flynnaf947722022-03-02 11:04:47 +000015#include "IReportStructure.hpp"
16#include "ProfilingState.hpp"
Nikhil Raj5b1bcc92021-06-08 12:31:50 +010017
Jim Flynnaf947722022-03-02 11:04:47 +000018#include <armnn/backends/profiling/IBackendProfilingContext.hpp>
19#include <armnn/profiling/ProfilingOptions.hpp>
Jim Flynndecd08b2022-03-13 22:35:46 +000020
21#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
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000024namespace arm
Jim Flynn64063552020-02-14 10:18:08 +000025{
26
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000027namespace pipe
Jim Flynn64063552020-02-14 10:18:08 +000028{
29
Jim Flynnaf947722022-03-02 11:04:47 +000030class IProfilingService : public IProfilingGuidGenerator,
31 public IProfilingServiceStatus,
32 public IReadWriteCounterValues
Jim Flynn64063552020-02-14 10:18:08 +000033{
34public:
Jim Flynnaf947722022-03-02 11:04:47 +000035 static std::unique_ptr<IProfilingService> CreateProfilingService(
Jim Flynn34430252022-03-04 15:03:58 +000036 uint16_t maxGlobalCounterId,
37 IInitialiseProfilingService& initialiser,
Jim Flynndecd08b2022-03-13 22:35:46 +000038 arm::pipe::Optional<IReportStructure&> reportStructure = arm::pipe::EmptyOptional());
Jim Flynn64063552020-02-14 10:18:08 +000039 virtual ~IProfilingService() {};
40 virtual std::unique_ptr<ISendTimelinePacket> GetSendTimelinePacket() const = 0;
41 virtual const ICounterMappings& GetCounterMappings() const = 0;
42 virtual ISendCounterPacket& GetSendCounterPacket() = 0;
43 virtual bool IsProfilingEnabled() const = 0;
Jim Flynnaf947722022-03-02 11:04:47 +000044 virtual bool IsTimelineReportingEnabled() const = 0;
Jim Flynn64063552020-02-14 10:18:08 +000045 virtual CaptureData GetCaptureData() = 0;
Jim Flynnaf947722022-03-02 11:04:47 +000046 virtual ProfilingState GetCurrentState() const = 0;
47 // Resets the profiling options, optionally clears the profiling service entirely
48 virtual void ResetExternalProfilingOptions(const ProfilingOptions& options,
49 bool resetProfilingService = false) = 0;
50 virtual ProfilingState ConfigureProfilingService(const ProfilingOptions& options,
51 bool resetProfilingService = false) = 0;
52 // Store a profiling context returned from a backend that support profiling.
Cathal Corbett6f073722022-03-04 12:11:09 +000053 virtual void AddBackendProfilingContext(const std::string& backendId,
Jim Flynnaf947722022-03-02 11:04:47 +000054 std::shared_ptr<IBackendProfilingContext> profilingContext) = 0;
55 virtual ICounterRegistry& GetCounterRegistry() = 0;
56 virtual IRegisterCounterMapping& GetCounterMappingRegistry() = 0;
Jim Flynn34430252022-03-04 15:03:58 +000057 virtual bool IsCategoryRegistered(const std::string& categoryName) const = 0;
58 virtual void InitializeCounterValue(uint16_t counterUid) = 0;
59
Jim Flynnaf947722022-03-02 11:04:47 +000060 // IProfilingGuidGenerator functions
61 /// Return the next random Guid in the sequence
62 ProfilingDynamicGuid NextGuid() override;
63 /// Create a ProfilingStaticGuid based on a hash of the string
64 ProfilingStaticGuid GenerateStaticId(const std::string& str) override;
65 static ProfilingDynamicGuid GetNextGuid();
66 static ProfilingStaticGuid GetStaticId(const std::string& str);
67 void ResetGuidGenerator();
68
Jim Flynn34430252022-03-04 15:03:58 +000069 virtual void Disconnect() = 0;
70
Jim Flynnaf947722022-03-02 11:04:47 +000071private:
72 static ProfilingGuidGenerator m_GuidGenerator;
Jim Flynn64063552020-02-14 10:18:08 +000073};
74
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000075} // namespace pipe
Jim Flynn64063552020-02-14 10:18:08 +000076
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000077} // namespace arm