IVGCVSW-4760 Change the offsets in the counter directory body_header to be from the...
[platform/upstream/armnn.git] / src / profiling / test / ProfilingTestUtils.hpp
1 //
2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #pragma once
7
8 #include "ProfilingUtils.hpp"
9 #include "Runtime.hpp"
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
20 const static uint32_t bodyHeaderSize = 6;
21
22 uint32_t GetStreamMetaDataPacketSize();
23
24 inline unsigned int OffsetToNextWord(unsigned int numberOfBytes);
25
26 void VerifyTimelineHeaderBinary(const unsigned char* readableData,
27                                 unsigned int& offset,
28                                 uint32_t packetDataLength);
29
30 void VerifyTimelineLabelBinaryPacketData(Optional<ProfilingGuid> guid,
31                                          const std::string& label,
32                                          const unsigned char* readableData,
33                                          unsigned int& offset);
34
35 void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid,
36                                               const unsigned char* readableData,
37                                               unsigned int& offset);
38
39 void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType,
40                                                 Optional<ProfilingGuid> relationshipGuid,
41                                                 Optional<ProfilingGuid> headGuid,
42                                                 Optional<ProfilingGuid> tailGuid,
43                                                 const unsigned char* readableData,
44                                                 unsigned int& offset);
45
46 void VerifyTimelineEntityBinaryPacketData(Optional<ProfilingGuid> guid,
47                                           const unsigned char* readableData,
48                                           unsigned int& offset);
49
50 void VerifyTimelineEventBinaryPacket(Optional<uint64_t> timestamp,
51                                      Optional<std::thread::id> threadId,
52                                      Optional<ProfilingGuid> eventGuid,
53                                      const unsigned char* readableData,
54                                      unsigned int& offset);
55
56 void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId);
57
58 namespace armnn
59 {
60
61 namespace profiling
62 {
63
64 class ProfilingServiceRuntimeHelper : public ProfilingService
65 {
66 public:
67     ProfilingServiceRuntimeHelper(ProfilingService& profilingService)
68     : m_ProfilingService(profilingService) {}
69     ~ProfilingServiceRuntimeHelper() = default;
70
71     BufferManager& GetProfilingBufferManager()
72     {
73         return GetBufferManager(m_ProfilingService);
74     }
75     armnn::profiling::ProfilingService& m_ProfilingService;
76
77     void ForceTransitionToState(ProfilingState newState)
78     {
79         TransitionToState(m_ProfilingService, newState);
80     }
81 };
82
83 } // namespace profiling
84
85 } // namespace armnn
86