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