Nikhil Raj | bc62605 | 2019-08-15 15:49:45 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | #pragma once |
| 6 | |
Aron Virginas-Tar | e898db9 | 2019-08-22 12:56:34 +0100 | [diff] [blame] | 7 | #include <armnn/Exceptions.hpp> |
Nikhil Raj | bc62605 | 2019-08-15 15:49:45 +0100 | [diff] [blame] | 8 | |
| 9 | #include <boost/log/trivial.hpp> |
| 10 | |
Aron Virginas-Tar | e898db9 | 2019-08-22 12:56:34 +0100 | [diff] [blame] | 11 | namespace armnn |
| 12 | { |
| 13 | |
| 14 | namespace profiling |
| 15 | { |
Nikhil Raj | bc62605 | 2019-08-15 15:49:45 +0100 | [diff] [blame] | 16 | |
| 17 | class Packet |
| 18 | { |
| 19 | public: |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 20 | Packet(uint32_t header, uint32_t length, std::unique_ptr<char[]>& data) |
| 21 | : m_Header(header), m_Length(length), m_Data(std::move(data)) |
Matteo Martincigh | 149528e | 2019-09-05 12:02:04 +0100 | [diff] [blame] | 22 | { |
| 23 | m_PacketId = ((header >> 16) & 1023); |
| 24 | m_PacketFamily = (header >> 26); |
Nikhil Raj | bc62605 | 2019-08-15 15:49:45 +0100 | [diff] [blame] | 25 | |
Matteo Martincigh | 149528e | 2019-09-05 12:02:04 +0100 | [diff] [blame] | 26 | if (length == 0 && m_Data != nullptr) |
| 27 | { |
| 28 | throw armnn::InvalidArgumentException("Data should be null when length is zero"); |
| 29 | } |
| 30 | } |
Nikhil Raj | bc62605 | 2019-08-15 15:49:45 +0100 | [diff] [blame] | 31 | |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 32 | Packet(Packet&& other) : |
| 33 | m_Header(other.m_Header), |
| 34 | m_PacketFamily(other.m_PacketFamily), |
| 35 | m_PacketId(other.m_PacketId), |
| 36 | m_Length(other.m_Length), |
| 37 | m_Data(std::move(other.m_Data)){}; |
| 38 | |
| 39 | Packet(const Packet& other) = delete; |
| 40 | Packet& operator=(const Packet&) = delete; |
| 41 | |
Nikhil Raj | bc62605 | 2019-08-15 15:49:45 +0100 | [diff] [blame] | 42 | uint32_t GetHeader() const; |
| 43 | uint32_t GetPacketFamily() const; |
| 44 | uint32_t GetPacketId() const; |
| 45 | uint32_t GetLength() const; |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 46 | const char* const GetData() const; |
Nikhil Raj | bc62605 | 2019-08-15 15:49:45 +0100 | [diff] [blame] | 47 | |
| 48 | uint32_t GetPacketClass() const; |
| 49 | uint32_t GetPacketType() const; |
| 50 | |
| 51 | private: |
| 52 | uint32_t m_Header; |
| 53 | uint32_t m_PacketFamily; |
| 54 | uint32_t m_PacketId; |
| 55 | uint32_t m_Length; |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 56 | std::unique_ptr<char[]> m_Data; |
Aron Virginas-Tar | e898db9 | 2019-08-22 12:56:34 +0100 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | } // namespace profiling |
| 60 | |
| 61 | } // namespace armnn |