summaryrefslogtreecommitdiff
path: root/src/intel/perf/intel_perf_mdapi.h
blob: 8fb8d327136e8917e14bf9598abdee3f0466a0c1 (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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
 * Copyright © 2018 Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

#ifndef INTEL_PERF_MDAPI_H
#define INTEL_PERF_MDAPI_H

#include <stdint.h>

#include "dev/intel_device_info.h"

struct intel_perf_query_result;

/* Guid has to matches with MDAPI's. */
#define GEN_PERF_QUERY_GUID_MDAPI "2f01b241-7014-42a7-9eb6-a925cad3daba"

/*
 * Data format expected by MDAPI.
 */

struct gfx7_mdapi_metrics {
   uint64_t TotalTime;

   uint64_t ACounters[45];
   uint64_t NOACounters[16];

   uint64_t PerfCounter1;
   uint64_t PerfCounter2;
   uint32_t SplitOccured;
   uint32_t CoreFrequencyChanged;
   uint64_t CoreFrequency;
   uint32_t ReportId;
   uint32_t ReportsCount;
};

#define GTDI_QUERY_BDW_METRICS_OA_COUNT         36
#define GTDI_QUERY_BDW_METRICS_OA_40b_COUNT     32
#define GTDI_QUERY_BDW_METRICS_NOA_COUNT        16
struct gfx8_mdapi_metrics {
   uint64_t TotalTime;
   uint64_t GPUTicks;
   uint64_t OaCntr[GTDI_QUERY_BDW_METRICS_OA_COUNT];
   uint64_t NoaCntr[GTDI_QUERY_BDW_METRICS_NOA_COUNT];
   uint64_t BeginTimestamp;
   uint64_t Reserved1;
   uint64_t Reserved2;
   uint32_t Reserved3;
   uint32_t OverrunOccured;
   uint64_t MarkerUser;
   uint64_t MarkerDriver;

   uint64_t SliceFrequency;
   uint64_t UnsliceFrequency;
   uint64_t PerfCounter1;
   uint64_t PerfCounter2;
   uint32_t SplitOccured;
   uint32_t CoreFrequencyChanged;
   uint64_t CoreFrequency;
   uint32_t ReportId;
   uint32_t ReportsCount;
};

#define GTDI_MAX_READ_REGS 16

struct gfx9_mdapi_metrics {
   uint64_t TotalTime;
   uint64_t GPUTicks;
   uint64_t OaCntr[GTDI_QUERY_BDW_METRICS_OA_COUNT];
   uint64_t NoaCntr[GTDI_QUERY_BDW_METRICS_NOA_COUNT];
   uint64_t BeginTimestamp;
   uint64_t Reserved1;
   uint64_t Reserved2;
   uint32_t Reserved3;
   uint32_t OverrunOccured;
   uint64_t MarkerUser;
   uint64_t MarkerDriver;

   uint64_t SliceFrequency;
   uint64_t UnsliceFrequency;
   uint64_t PerfCounter1;
   uint64_t PerfCounter2;
   uint32_t SplitOccured;
   uint32_t CoreFrequencyChanged;
   uint64_t CoreFrequency;
   uint32_t ReportId;
   uint32_t ReportsCount;

   uint64_t UserCntr[GTDI_MAX_READ_REGS];
   uint32_t UserCntrCfgId;
   uint32_t Reserved4;
};

/* Add new definition */
#define gfx11_mdapi_metrics gfx9_mdapi_metrics

struct mdapi_pipeline_metrics {
   uint64_t IAVertices;
   uint64_t IAPrimitives;
   uint64_t VSInvocations;
   uint64_t GSInvocations;
   uint64_t GSPrimitives;
   uint64_t CInvocations;
   uint64_t CPrimitives;
   uint64_t PSInvocations;
   uint64_t HSInvocations;
   uint64_t DSInvocations;
   uint64_t CSInvocations;
   uint64_t Reserved1; /* Gfx10+ */
};

int intel_perf_query_result_write_mdapi(void *data, uint32_t data_size,
                                      const struct intel_device_info *devinfo,
                                      const struct intel_perf_query_info *query,
                                      const struct intel_perf_query_result *result);

static inline void intel_perf_query_mdapi_write_marker(void *data, uint32_t data_size,
                                                     const struct intel_device_info *devinfo,
                                                     uint64_t value)
{
   switch (devinfo->ver) {
   case 8: {
      if (data_size < sizeof(struct gfx8_mdapi_metrics))
         return;
      struct gfx8_mdapi_metrics *mdapi_data = data;
      mdapi_data->MarkerUser = value;
      break;
   }
   case 9:
   case 11: {
      if (data_size < sizeof(struct gfx9_mdapi_metrics))
         return;
      struct gfx9_mdapi_metrics *mdapi_data = data;
      mdapi_data->MarkerUser = value;
      break;
   }
   default:
      break;
   }
}

#endif /* INTEL_PERF_MDAPI_H */