1 // 2 // Copyright © 2020 Arm Ltd. All rights reserved. 3 // SPDX-License-Identifier: MIT 4 // 5 6 #pragma once 7 8 9 #include <armnn/utility/IgnoreUnused.hpp> 10 11 #include <cstdint> 12 #include <memory> 13 #include <vector> 14 15 // forward declare to prevent a circular dependency 16 namespace arm 17 { 18 namespace pipe 19 { 20 class Packet; 21 } // namespace pipe 22 } // namespace arm 23 24 namespace armnn 25 { 26 27 namespace profiling 28 { 29 30 enum class TargetEndianness 31 { 32 BeWire, 33 LeWire 34 }; 35 36 // the handlers need to be able to do two 37 // things to service the FileOnlyProfilingConnection 38 // and any other implementation of IProfilingConnection 39 // set the endianness and write a packet back i.e. 40 // return a packet and close the connection 41 class IInternalProfilingConnection 42 { 43 public: ~IInternalProfilingConnection()44 virtual ~IInternalProfilingConnection() {}; 45 46 virtual void SetEndianess(const TargetEndianness& endianness) = 0; 47 48 virtual void ReturnPacket(arm::pipe::Packet& packet) = 0; 49 50 virtual void Close() = 0; 51 }; 52 53 class ILocalPacketHandler 54 { 55 public: ~ILocalPacketHandler()56 virtual ~ILocalPacketHandler() {}; 57 58 /// @return lists the headers of the packets that this handler accepts 59 /// only these packets will get sent to this handler. 60 /// If this function returns an empty list then ALL packets 61 /// will be sent to the PacketHandler i.e. a universal handler. 62 virtual std::vector<uint32_t> GetHeadersAccepted() = 0; 63 64 /// process the packet 65 virtual void HandlePacket(const arm::pipe::Packet& packet) = 0; 66 67 /// Set a profiling connection on the handler. Only need to implement this 68 /// function if the handler will be writing data back to the profiled application. SetConnection(IInternalProfilingConnection * profilingConnection)69 virtual void SetConnection(IInternalProfilingConnection* profilingConnection) 70 {armnn::IgnoreUnused(profilingConnection);} 71 }; 72 73 using ILocalPacketHandlerPtr = std::unique_ptr<ILocalPacketHandler>; 74 using ILocalPacketHandlerSharedPtr = std::shared_ptr<ILocalPacketHandler>; 75 76 } // namespace profiling 77 78 } // namespace armnn