File: performance_counters.h

package info (click to toggle)
intel-compute-runtime 25.35.35096.9-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 79,324 kB
  • sloc: cpp: 926,243; lisp: 3,433; sh: 715; makefile: 162; python: 21
file content (122 lines) | stat: -rw-r--r-- 4,849 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
114
115
116
117
118
119
120
121
122
/*
 * Copyright (C) 2018-2024 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#pragma once
#include "shared/source/utilities/metrics_library.h"

#include <mutex>

namespace aub_stream {
enum EngineType : uint32_t;
}

namespace NEO {

//////////////////////////////////////////////////////
// Forward declaration.
//////////////////////////////////////////////////////
class TagNodeBase;

//////////////////////////////////////////////////////
// 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(PerformanceCounters *performanceCounters, aub_stream::EngineType engineType, const bool reservePerfCounters);
    uint32_t getGpuCommandsSize(const MetricsLibraryApi::GpuCommandBufferType commandBufferType, const bool begin);
    bool getGpuCommands(const MetricsLibraryApi::GpuCommandBufferType commandBufferType, TagNodeBase &performanceCounters, const bool begin, const uint32_t bufferSize, void *pBuffer);

    /////////////////////////////////////////////////////
    // Gpu/Api reports.
    /////////////////////////////////////////////////////
    uint32_t getApiReportSize();
    uint32_t getGpuReportSize();
    bool getApiReport(const TagNodeBase *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 getQueryHandleRef(QueryHandle_1_0 &handle);
    void deleteQuery(QueryHandle_1_0 &handle);

    /////////////////////////////////////////////////////
    // Metrics Library callbacks.
    /////////////////////////////////////////////////////
    static MetricsLibraryApi::StatusCode ML_STDCALL flushCommandBufferCallback(MetricsLibraryApi::ClientHandle_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};
    ClientOptionsSubDeviceData_1_0 subDevice = {};
    ClientOptionsSubDeviceIndexData_1_0 subDeviceIndex = {};
    ClientOptionsSubDeviceCountData_1_0 subDeviceCount = {};

    /////////////////////////////////////////////////////
    // 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