blob: 912265ee7616ca3f860d4893867953412a6d8c17 [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>
20#include <armnn/Optional.hpp>
Nikhil Raj5b1bcc92021-06-08 12:31:50 +010021#include <common/include/ProfilingGuidGenerator.hpp>
Jim Flynn64063552020-02-14 10:18:08 +000022
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000023namespace arm
Jim Flynn64063552020-02-14 10:18:08 +000024{
25
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000026namespace pipe
Jim Flynn64063552020-02-14 10:18:08 +000027{
28
Jim Flynnaf947722022-03-02 11:04:47 +000029class IProfilingService : public IProfilingGuidGenerator,
30 public IProfilingServiceStatus,
31 public IReadWriteCounterValues
Jim Flynn64063552020-02-14 10:18:08 +000032{
33public:
Jim Flynnaf947722022-03-02 11:04:47 +000034 static std::unique_ptr<IProfilingService> CreateProfilingService(
Jim Flynn34430252022-03-04 15:03:58 +000035 uint16_t maxGlobalCounterId,
36 IInitialiseProfilingService& initialiser,
Jim Flynnaf947722022-03-02 11:04:47 +000037 armnn::Optional<IReportStructure&> reportStructure = armnn::EmptyOptional());
Jim Flynn64063552020-02-14 10:18:08 +000038 virtual ~IProfilingService() {};
39 virtual std::unique_ptr<ISendTimelinePacket> GetSendTimelinePacket() const = 0;
40 virtual const ICounterMappings& GetCounterMappings() const = 0;
41 virtual ISendCounterPacket& GetSendCounterPacket() = 0;
42 virtual bool IsProfilingEnabled() const = 0;
Jim Flynnaf947722022-03-02 11:04:47 +000043 virtual bool IsTimelineReportingEnabled() const = 0;
Jim Flynn64063552020-02-14 10:18:08 +000044 virtual CaptureData GetCaptureData() = 0;
Jim Flynnaf947722022-03-02 11:04:47 +000045 virtual ProfilingState GetCurrentState() const = 0;
46 // Resets the profiling options, optionally clears the profiling service entirely
47 virtual void ResetExternalProfilingOptions(const ProfilingOptions& options,
48 bool resetProfilingService = false) = 0;
49 virtual ProfilingState ConfigureProfilingService(const ProfilingOptions& options,
50 bool resetProfilingService = false) = 0;
51 // Store a profiling context returned from a backend that support profiling.
Cathal Corbett6f073722022-03-04 12:11:09 +000052 virtual void AddBackendProfilingContext(const std::string& backendId,
Jim Flynnaf947722022-03-02 11:04:47 +000053 std::shared_ptr<IBackendProfilingContext> profilingContext) = 0;
54 virtual ICounterRegistry& GetCounterRegistry() = 0;
55 virtual IRegisterCounterMapping& GetCounterMappingRegistry() = 0;
Jim Flynn34430252022-03-04 15:03:58 +000056 virtual bool IsCategoryRegistered(const std::string& categoryName) const = 0;
57 virtual void InitializeCounterValue(uint16_t counterUid) = 0;
58
Jim Flynnaf947722022-03-02 11:04:47 +000059 // IProfilingGuidGenerator functions
60 /// Return the next random Guid in the sequence
61 ProfilingDynamicGuid NextGuid() override;
62 /// Create a ProfilingStaticGuid based on a hash of the string
63 ProfilingStaticGuid GenerateStaticId(const std::string& str) override;
64 static ProfilingDynamicGuid GetNextGuid();
65 static ProfilingStaticGuid GetStaticId(const std::string& str);
66 void ResetGuidGenerator();
67
Jim Flynn34430252022-03-04 15:03:58 +000068 virtual void Disconnect() = 0;
69
Jim Flynnaf947722022-03-02 11:04:47 +000070private:
71 static ProfilingGuidGenerator m_GuidGenerator;
Jim Flynn64063552020-02-14 10:18:08 +000072};
73
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000074} // namespace pipe
Jim Flynn64063552020-02-14 10:18:08 +000075
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000076} // namespace arm