aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/Packet.hpp
blob: 1e047a65116b86e44925c5e6f6cd6f4e2341cf64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once

#include <armnn/Exceptions.hpp>

#include <boost/log/trivial.hpp>

namespace armnn
{

namespace profiling
{

class Packet
{
public:
    Packet(uint32_t header, uint32_t length, std::unique_ptr<char[]>& data)
    : m_Header(header), m_Length(length), m_Data(std::move(data))
    {
        m_PacketId = ((header >> 16) & 1023);
        m_PacketFamily = (header >> 26);

        if (length == 0 && m_Data != nullptr)
        {
            throw armnn::InvalidArgumentException("Data should be null when length is zero");
        }
    }

    Packet(Packet&& other) :
           m_Header(other.m_Header),
           m_PacketFamily(other.m_PacketFamily),
           m_PacketId(other.m_PacketId),
           m_Length(other.m_Length),
           m_Data(std::move(other.m_Data)){};

    Packet(const Packet& other) = delete;
    Packet& operator=(const Packet&) = delete;

    uint32_t GetHeader() const;
    uint32_t GetPacketFamily() const;
    uint32_t GetPacketId() const;
    uint32_t GetLength() const;
    const char* const GetData() const;

    uint32_t GetPacketClass() const;
    uint32_t GetPacketType() const;

private:
    uint32_t m_Header;
    uint32_t m_PacketFamily;
    uint32_t m_PacketId;
    uint32_t m_Length;
    std::unique_ptr<char[]> m_Data;
};

} // namespace profiling

} // namespace armnn