Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame] | 1 | // |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 2 | // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include "CounterIdMap.hpp" |
| 9 | #include "Holder.hpp" |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 10 | #include "ICounterValues.hpp" |
| 11 | #include "ICounterRegistry.hpp" |
Jim Flynn | 3443025 | 2022-03-04 15:03:58 +0000 | [diff] [blame] | 12 | #include "IInitialiseProfilingService.hpp" |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 13 | #include "IProfilingServiceStatus.hpp" |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame] | 14 | #include "ISendCounterPacket.hpp" |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 15 | #include "IReportStructure.hpp" |
| 16 | #include "ProfilingState.hpp" |
Nikhil Raj | 5b1bcc9 | 2021-06-08 12:31:50 +0100 | [diff] [blame] | 17 | |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 18 | #include <armnn/backends/profiling/IBackendProfilingContext.hpp> |
| 19 | #include <armnn/profiling/ProfilingOptions.hpp> |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame^] | 20 | |
| 21 | #include <common/include/Optional.hpp> |
Nikhil Raj | 5b1bcc9 | 2021-06-08 12:31:50 +0100 | [diff] [blame] | 22 | #include <common/include/ProfilingGuidGenerator.hpp> |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame] | 23 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 24 | namespace arm |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame] | 25 | { |
| 26 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 27 | namespace pipe |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame] | 28 | { |
| 29 | |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 30 | class IProfilingService : public IProfilingGuidGenerator, |
| 31 | public IProfilingServiceStatus, |
| 32 | public IReadWriteCounterValues |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame] | 33 | { |
| 34 | public: |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 35 | static std::unique_ptr<IProfilingService> CreateProfilingService( |
Jim Flynn | 3443025 | 2022-03-04 15:03:58 +0000 | [diff] [blame] | 36 | uint16_t maxGlobalCounterId, |
| 37 | IInitialiseProfilingService& initialiser, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame^] | 38 | arm::pipe::Optional<IReportStructure&> reportStructure = arm::pipe::EmptyOptional()); |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame] | 39 | 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 Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 44 | virtual bool IsTimelineReportingEnabled() const = 0; |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame] | 45 | virtual CaptureData GetCaptureData() = 0; |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 46 | 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 Corbett | 6f07372 | 2022-03-04 12:11:09 +0000 | [diff] [blame] | 53 | virtual void AddBackendProfilingContext(const std::string& backendId, |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 54 | std::shared_ptr<IBackendProfilingContext> profilingContext) = 0; |
| 55 | virtual ICounterRegistry& GetCounterRegistry() = 0; |
| 56 | virtual IRegisterCounterMapping& GetCounterMappingRegistry() = 0; |
Jim Flynn | 3443025 | 2022-03-04 15:03:58 +0000 | [diff] [blame] | 57 | virtual bool IsCategoryRegistered(const std::string& categoryName) const = 0; |
| 58 | virtual void InitializeCounterValue(uint16_t counterUid) = 0; |
| 59 | |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 60 | // 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 Flynn | 3443025 | 2022-03-04 15:03:58 +0000 | [diff] [blame] | 69 | virtual void Disconnect() = 0; |
| 70 | |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 71 | private: |
| 72 | static ProfilingGuidGenerator m_GuidGenerator; |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame] | 73 | }; |
| 74 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 75 | } // namespace pipe |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame] | 76 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 77 | } // namespace arm |