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: |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 20 | Packet() |
| 21 | : m_Header(0) |
| 22 | , m_Length(0) |
| 23 | , m_Data(nullptr) |
| 24 | {} |
| 25 | |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 26 | Packet(uint32_t header, uint32_t length, std::unique_ptr<char[]>& data) |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 27 | : m_Header(header) |
| 28 | , m_Length(length) |
| 29 | , m_Data(std::move(data)) |
Matteo Martincigh | 149528e | 2019-09-05 12:02:04 +0100 | [diff] [blame] | 30 | { |
| 31 | m_PacketId = ((header >> 16) & 1023); |
| 32 | m_PacketFamily = (header >> 26); |
Nikhil Raj | bc62605 | 2019-08-15 15:49:45 +0100 | [diff] [blame] | 33 | |
Matteo Martincigh | 149528e | 2019-09-05 12:02:04 +0100 | [diff] [blame] | 34 | if (length == 0 && m_Data != nullptr) |
| 35 | { |
| 36 | throw armnn::InvalidArgumentException("Data should be null when length is zero"); |
| 37 | } |
| 38 | } |
Nikhil Raj | bc62605 | 2019-08-15 15:49:45 +0100 | [diff] [blame] | 39 | |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 40 | Packet(Packet&& other) : |
| 41 | m_Header(other.m_Header), |
| 42 | m_PacketFamily(other.m_PacketFamily), |
| 43 | m_PacketId(other.m_PacketId), |
| 44 | m_Length(other.m_Length), |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 45 | m_Data(std::move(other.m_Data)) |
| 46 | {} |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 47 | |
| 48 | Packet(const Packet& other) = delete; |
| 49 | Packet& operator=(const Packet&) = delete; |
| 50 | |
Nikhil Raj | bc62605 | 2019-08-15 15:49:45 +0100 | [diff] [blame] | 51 | uint32_t GetHeader() const; |
| 52 | uint32_t GetPacketFamily() const; |
| 53 | uint32_t GetPacketId() const; |
| 54 | uint32_t GetLength() const; |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 55 | const char* const GetData() const; |
Nikhil Raj | bc62605 | 2019-08-15 15:49:45 +0100 | [diff] [blame] | 56 | |
| 57 | uint32_t GetPacketClass() const; |
| 58 | uint32_t GetPacketType() const; |
| 59 | |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 60 | bool IsEmpty() { return m_Header == 0 && m_Length == 0; } |
| 61 | |
Nikhil Raj | bc62605 | 2019-08-15 15:49:45 +0100 | [diff] [blame] | 62 | private: |
| 63 | uint32_t m_Header; |
| 64 | uint32_t m_PacketFamily; |
| 65 | uint32_t m_PacketId; |
| 66 | uint32_t m_Length; |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 67 | std::unique_ptr<char[]> m_Data; |
Aron Virginas-Tar | e898db9 | 2019-08-22 12:56:34 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | } // namespace profiling |
| 71 | |
| 72 | } // namespace armnn |