aboutsummaryrefslogtreecommitdiff
path: root/tests/profiling/gatordmock/DirectoryCaptureCommandHandler.hpp
blob: 4cf96be7417e1f070b4c814707f634931f290a2b (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// Copyright © 2019 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//

#pragma once

#include "CounterDirectory.hpp"
#include "GatordMockService.hpp"
#include "MockUtils.hpp"


#include "Packet.hpp"
#include "CommandHandlerFunctor.hpp"
#include "SendCounterPacket.hpp"
#include "IPeriodicCounterCapture.hpp"


#include <vector>
#include <thread>
#include <functional>

namespace armnn
{

namespace gatordmock
{

class DirectoryCaptureCommandHandler : public profiling::CommandHandlerFunctor
{

public:

    DirectoryCaptureCommandHandler(uint32_t familyId,
                                   uint32_t packetId,
                                   uint32_t version,
                                   bool quietOperation = false)
            : CommandHandlerFunctor(familyId, packetId, version)
            , m_QuietOperation(quietOperation)
            , m_CounterDirectoryCount(0)
             {}

    void operator()(const armnn::profiling::Packet &packet) override;

    CounterDirectory GetCounterDirectory() const;
    uint32_t GetCounterDirectoryCount() const;

private:
    void ParseData(const armnn::profiling::Packet &packet);

    std::vector<CategoryRecord> ReadCategoryRecords(const unsigned char *const data,
                                              uint32_t offset,
                                              std::vector<uint32_t> categoryOffsets);

    std::vector<CounterSetRecord> ReadCounterSetRecords(const unsigned char *const data,
                                              uint32_t offset,
                                              std::vector<uint32_t> eventRecordsOffsets);

    std::vector<DeviceRecord> ReadDeviceRecords(const unsigned char *const data,
                                              uint32_t offset,
                                              std::vector<uint32_t> eventRecordsOffsets);

    std::vector<EventRecord> ReadEventRecords(const unsigned char *const data,
                                              uint32_t offset,
                                              std::vector<uint32_t> eventRecordsOffsets);

    CounterDirectory m_CounterDirectory;

    bool m_QuietOperation;
    std::atomic<uint32_t> m_CounterDirectoryCount;
};

} // namespace gatordmock

} // namespace armnn