File: performance_counters.h

package info (click to toggle)
intel-compute-runtime 20.44.18297-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 34,780 kB
  • sloc: cpp: 379,729; lisp: 4,931; python: 299; sh: 196; makefile: 8
file content (113 lines) | stat: -rw-r--r-- 4,408 bytes parent folder | download
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * Copyright (C) 2017-2020 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#pragma once
#include "opencl/source/event/perf_counter.h"
#include "opencl/source/os_interface/metrics_library.h"

#include <mutex>

namespace NEO {

//////////////////////////////////////////////////////
// Forward declaration.
//////////////////////////////////////////////////////
template <typename Node>
struct TagNode;
class CommandQueue;

//////////////////////////////////////////////////////
// Performance counters implementation.
//////////////////////////////////////////////////////
class PerformanceCounters {
  public:
    //////////////////////////////////////////////////////
    // Constructor/destructor.
    //////////////////////////////////////////////////////
    PerformanceCounters();
    virtual ~PerformanceCounters() = default;

    //////////////////////////////////////////////////////
    // Performance counters creation.
    //////////////////////////////////////////////////////
    static std::unique_ptr<PerformanceCounters> create(class Device *device);
    bool enable(bool ccsEngine);
    void shutdown();
    uint32_t getReferenceNumber();

    /////////////////////////////////////////////////////
    // Gpu oa/mmio configuration.
    /////////////////////////////////////////////////////
    virtual bool enableCountersConfiguration() = 0;
    virtual void releaseCountersConfiguration() = 0;

    //////////////////////////////////////////////////////
    // Gpu commands.
    //////////////////////////////////////////////////////
    static uint32_t getGpuCommandsSize(CommandQueue &commandQueue, const bool reservePerfCounters);
    uint32_t getGpuCommandsSize(const MetricsLibraryApi::GpuCommandBufferType commandBufferType, const bool begin);
    bool getGpuCommands(const MetricsLibraryApi::GpuCommandBufferType commandBufferType, TagNode<HwPerfCounter> &performanceCounters, const bool begin, const uint32_t bufferSize, void *pBuffer);

    /////////////////////////////////////////////////////
    // Gpu/Api reports.
    /////////////////////////////////////////////////////
    uint32_t getApiReportSize();
    uint32_t getGpuReportSize();
    bool getApiReport(const TagNode<HwPerfCounter> *performanceCounters, const size_t inputParamSize, void *pClientData, size_t *pOutputSize, bool isEventComplete);

    /////////////////////////////////////////////////////
    // Metrics Library interface.
    /////////////////////////////////////////////////////
    MetricsLibrary *getMetricsLibraryInterface();
    void setMetricsLibraryInterface(std::unique_ptr<MetricsLibrary> newMetricsLibrary);
    bool openMetricsLibrary();
    void closeMetricsLibrary();

    /////////////////////////////////////////////////////
    // Metrics Library context/query handles.
    /////////////////////////////////////////////////////
    ContextHandle_1_0 getMetricsLibraryContext();
    void getQueryHandle(QueryHandle_1_0 &handle);
    void deleteQuery(QueryHandle_1_0 &handle);

  protected:
    /////////////////////////////////////////////////////
    // Common members.
    /////////////////////////////////////////////////////
    std::mutex mutex;
    uint32_t referenceCounter = 0;
    bool available = false;
    bool usingCcsEngine = false;

    /////////////////////////////////////////////////////
    // Metrics Library interface.
    /////////////////////////////////////////////////////
    std::unique_ptr<MetricsLibrary> metricsLibrary = {};

    /////////////////////////////////////////////////////
    // Metrics Library client data.
    /////////////////////////////////////////////////////
    ClientData_1_0 clientData = {};
    ClientType_1_0 clientType = {ClientApi::OpenCL, ClientGen::Unknown};

    /////////////////////////////////////////////////////
    // Metrics Library context.
    /////////////////////////////////////////////////////
    ContextCreateData_1_0 contextData = {};
    ContextHandle_1_0 context = {};

    /////////////////////////////////////////////////////
    // Metrics Library oa counters configuration.
    /////////////////////////////////////////////////////
    ConfigurationHandle_1_0 oaConfiguration = {};

    /////////////////////////////////////////////////////
    // Metrics Library query object.
    /////////////////////////////////////////////////////
    QueryHandle_1_0 query = {};
};
} // namespace NEO