Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 1 | // |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 2 | // Copyright © 2019 Arm Ltd and Contributors. All rights reserved. |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include "ProfilingUtils.hpp" |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 9 | #include "Runtime.hpp" |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 10 | |
| 11 | #include <armnn/BackendId.hpp> |
| 12 | #include <armnn/Optional.hpp> |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 13 | #include <BufferManager.hpp> |
| 14 | #include <ProfilingService.hpp> |
| 15 | |
Nikhil Raj | 77fe76b | 2021-06-09 14:55:32 +0100 | [diff] [blame] | 16 | #include <common/include/ProfilingGuid.hpp> |
| 17 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 18 | using namespace armnn; |
| 19 | using namespace armnn::profiling; |
| 20 | |
Finn Williams | 985fecf | 2020-04-30 11:06:43 +0100 | [diff] [blame] | 21 | const static uint32_t bodyHeaderSize = 6; |
| 22 | |
Finn Williams | a0de056 | 2020-04-22 12:27:37 +0100 | [diff] [blame] | 23 | uint32_t GetStreamMetaDataPacketSize(); |
| 24 | |
Jan Eilers | f78c767 | 2020-07-01 18:09:39 +0100 | [diff] [blame] | 25 | /// Returns a vector of CpuRef, CpuAcc or GpuAcc backends if they where registered |
| 26 | std::vector<BackendId> GetSuitableBackendRegistered(); |
| 27 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 28 | inline unsigned int OffsetToNextWord(unsigned int numberOfBytes); |
| 29 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 30 | void VerifyTimelineHeaderBinary(const unsigned char* readableData, |
| 31 | unsigned int& offset, |
| 32 | uint32_t packetDataLength); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 33 | |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 34 | ProfilingGuid VerifyTimelineLabelBinaryPacketData(Optional<ProfilingGuid> guid, |
| 35 | const std::string& label, |
| 36 | const unsigned char* readableData, |
| 37 | unsigned int& offset); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 38 | |
| 39 | void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid, |
Jim Flynn | 1892d21 | 2020-05-26 21:10:49 +0100 | [diff] [blame] | 40 | ProfilingGuid nameGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 41 | const unsigned char* readableData, |
| 42 | unsigned int& offset); |
| 43 | |
| 44 | void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, |
| 45 | Optional<ProfilingGuid> relationshipGuid, |
| 46 | Optional<ProfilingGuid> headGuid, |
| 47 | Optional<ProfilingGuid> tailGuid, |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 48 | Optional<ProfilingGuid> attributeGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 49 | const unsigned char* readableData, |
| 50 | unsigned int& offset); |
| 51 | |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 52 | ProfilingGuid VerifyTimelineEntityBinaryPacketData(Optional<ProfilingGuid> guid, |
| 53 | const unsigned char* readableData, |
| 54 | unsigned int& offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 55 | |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 56 | ProfilingGuid VerifyTimelineEventBinaryPacket(Optional<uint64_t> timestamp, |
Jim Flynn | 1fdeb99 | 2020-07-09 07:28:37 +0100 | [diff] [blame] | 57 | Optional<int> threadId, |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 58 | Optional<ProfilingGuid> eventGuid, |
| 59 | const unsigned char* readableData, |
| 60 | unsigned int& offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 61 | |
| 62 | void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId); |
| 63 | |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 64 | bool CompareOutput(std::vector<std::string> output, std::vector<std::string> expectedOutput); |
| 65 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 66 | namespace armnn |
| 67 | { |
| 68 | |
| 69 | namespace profiling |
| 70 | { |
| 71 | |
| 72 | class ProfilingServiceRuntimeHelper : public ProfilingService |
| 73 | { |
| 74 | public: |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 75 | ProfilingServiceRuntimeHelper(ProfilingService& profilingService) |
| 76 | : m_ProfilingService(profilingService) {} |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 77 | ~ProfilingServiceRuntimeHelper() = default; |
| 78 | |
| 79 | BufferManager& GetProfilingBufferManager() |
| 80 | { |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 81 | return GetBufferManager(m_ProfilingService); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 82 | } |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 83 | armnn::profiling::ProfilingService& m_ProfilingService; |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 84 | |
| 85 | void ForceTransitionToState(ProfilingState newState) |
| 86 | { |
| 87 | TransitionToState(m_ProfilingService, newState); |
| 88 | } |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | } // namespace profiling |
| 92 | |
| 93 | } // namespace armnn |
| 94 | |