PAPI 7.1.0.0
Loading...
Searching...
No Matches
linux_intel_gpu_metrics.c
Go to the documentation of this file.
1/*
2 * linux_intel_gpu_metrics.c: IntelĀ® Graphics Processing Unit (GPU) Component for PAPI.
3 *
4 * Copyright (c) 2020 Intel Corp. All rights reserved
5 * Contributed by Peinan Zhang <peinan.zhang@intel.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11 * of the Software, and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <stdint.h>
28#include <unistd.h>
29#include <dlfcn.h>
30#include <string.h>
31#include <pthread.h>
32
35
36
37#define DEFAULT_LOOPS 0 // collection infinitely until receive stop command
38#define DEFAULT_MODE METRIC_SUMMARY // summary report
39
40#define GPUDEBUG SUBDBG
41
42// all available devices
43static uint32_t num_avail_devices = 0;
45
46// devices currently being queried
47static uint32_t num_active_devices = 0;
49
50static MetricInfo metricInfoList;
51static int total_metrics = 0;
52static int global_metrics_type = TIME_BASED; // default type
53
55
65void
66parseMetricName(const char *metricName, int *devnum, int *tilenum) {
67 char *name = strdup(metricName);
68 char *ptr = name;
69 char *param = name;
70 uint32_t dnum = 0;
71 uint32_t tnum = 0;
72
73 if ((*param != '\0') && (ptr=strstr(param, ":"))) {
74 if ((ptr=strstr(param, ":device="))) {
75 ptr += 8;
76 dnum = atoi(ptr)+1;
77 }
78 if ((ptr=strstr(param, ":tile="))) {
79 ptr += 6;
80 tnum = atoi(ptr)+1;
81 }
82 }
83 *devnum = (dnum)?dnum:1;
84 *tilenum = (tnum)?tnum:0; // default tile is 0 for root device
85 free(name);
86}
87
88
93getHandle(uint32_t device_code) {
94 uint32_t i=0;
95 for (i=0; i<num_avail_devices; i++) {
96 if (IsDeviceHandle(device_code, avail_devices[i])) {
97 return avail_devices[i];
98 }
99 }
100 return 0;
101}
102
106int
107addMetricToDevice(uint32_t code, int rootDev) {
108
109 int index = GetIdx(code);
110 if (index >= total_metrics) {
111 return -1;
112 }
113 uint32_t group = GetGroupIdx(metricInfoList.infoEntries[index].code);
114 uint32_t metric = GetMetricIdx(metricInfoList.infoEntries[index].code);
115 uint32_t devcode = GetDeviceCode(code);
116 if (rootDev) {
117 devcode = devcode & ~DMASK;
118 }
119 GPUDEBUG("addMetricToDevice, code 0x%x, group 0x%x, metric 0x%x, devcode 0x%x\n",
120 code, group, metric, devcode);
121 uint32_t i=0;
122 for (i=0; i<num_active_devices; i++) {
123 if (active_devices[i].device_code == devcode) {
124 if (active_devices[i].mgroup_code != group) {
125 // conflict with existing metric group
126 GPUDEBUG("intel_gpu: metrics from more than one group cannot be collected "
127 " in the same device at the same time. "
128 " Failed with return code 0x%x \n", PAPI_ENOSUPP);
129 return -1;
130 }
131 break;
132 }
133 }
134 if (i >= num_avail_devices) {
135 GPUDEBUG("intel_gpu: invalid event code 0x%x\n", code);
136 return -1;
137 }
138
139 DEVICE_HANDLE hd = getHandle(devcode);
140 if (!hd) {
141 GPUDEBUG("intel_gpu: Metric is not supported. For multi devices and/or multi-tiles GPUs, "
142 "metric name should be qualified with :device=0 and/or :tile=0. "
143 "Failed with return code 0x%x \n", PAPI_ENOSUPP);
144 return -1;
145 }
146
147 // add a new device entry
148 DeviceContext *dev = &(active_devices[i]);
149 if (i==num_active_devices) {
150 dev->device_code = devcode;
151 dev->mgroup_code = group;
152 dev->handle = hd;
154 }
155 // add a new metric to collect on this device
156 dev->metric_code[dev->num_metrics++] = metric;
157 return i;
158}
159
160
161/************************* PAPI Functions **********************************/
162
163static int
165{
166 GPUDEBUG("Entering intel_gpu_init_thread\n");
167 MetricContext *mContext = (MetricContext *)ctx;
168 mContext->active_devices = calloc(num_avail_devices, sizeof(uint32_t));
169 return PAPI_OK;
170}
171
172
173static int
175{
176 int retval = PAPI_OK;
177 GPUDEBUG("Entering intel_init_component\n");
178 if (cidx < 0) {
179 return PAPI_EINVAL;
180 }
181 char *errStr = NULL;
183
184 if (putenv("ZET_ENABLE_METRICS=1")) {
185 errStr = "Set ZET_ENABLE_METRICS=1 failed. Cannot access GPU metrics. ";
187 errStr, strlen(errStr));
189 goto fn_fail;
190 }
191 if ( _dl_non_dynamic_init != NULL ) {
192 errStr = "The intel_gpu component does not support statically linking of libc.";
194 errStr, strlen(errStr));
196 goto fn_fail;
197 }
199 errStr = "The intel_gpu component does not detect metrics device.";
201 errStr, strlen(errStr));
203 goto fn_fail;
204 }
205
207
208 char *envStr = NULL;
209 envStr = getenv(ENABLE_API_TRACING);
210 if (envStr != NULL) {
211 if (atoi(envStr) == 1) {
213 }
214 }
215
216 metricInfoList.numEntries = 0;
218 errStr = "The intel_gpu component failed on get all available metrics.";
220 errStr, strlen(errStr));
223 goto fn_fail;
224 };
225 total_metrics = metricInfoList.numEntries;
226 GPUDEBUG("total metrics %d\n", total_metrics);
227
231
232 /* Export the component id */
234
237
238 fn_exit:
239 _papi_hwd[cidx]->cmp_info.disabled = retval;
240 return retval;
241 fn_fail:
242 goto fn_exit;
243}
244
249static int
251{
252 GPUDEBUG("Entering intel_gpu_control_state\n");
253
254 if (!ctl) {
255 return PAPI_EINVAL;
256 }
257
258 MetricCtlState *mCtlSt = (MetricCtlState *)ctl;
260
261 char *envStr = NULL;
263 envStr = getenv(METRICS_SAMPLING_PERIOD);
264 if (envStr) {
265 mCtlSt->interval = atoi(envStr);
266 if (mCtlSt->interval < MINIMUM_SAMPLING_PERIOD) {
268 }
269 }
270 // set default mode (get aggragated value or average value overtime).
271 mCtlSt->mode = DEFAULT_MODE;
272 mCtlSt->loops = DEFAULT_LOOPS;
273
274 return PAPI_OK;
275}
276
277static int
280 int count,
281 hwd_context_t *ctx )
282{
283 GPUDEBUG("Entering intel_gpu_control_state\n");
284 (void)ctl;
285
286 // use local maintained context,
287 if (!count ||!native) {
288 return PAPI_OK;
289 }
290
291 MetricContext *mContext = (MetricContext *)ctx;
292
293#if defined(_DEBUG)
294 for (int i=0; i<count; i++) {
295 GPUDEBUG("\t i=%d, ni_event 0x%x, ni_papi_code 0x%x, ni_position %d, ni_owners %d \n",
296 i, native[i].ni_event, native[i].ni_papi_code,
297 native[i].ni_position, native[i].ni_owners);
298 }
299#endif
300
301 uint32_t nmetrics = mContext->num_metrics;
302 uint32_t midx = 0;
303 int ni = 0;
304 for (ni = 0; ni < count; ni++) {
305 uint32_t index = native[ni].ni_event;
306 // check whether this metric is in the list
307 for (midx=0; midx<nmetrics; midx++) {
308 if (mContext->metric_idx[midx] == index) {
309 GPUDEBUG("metric code %d: already in the list, ignore\n", index);
310 break;
311 }
312 }
313 if (midx < nmetrics) {
314 // already in the list
315 continue;
316 }
317 // whether use root device or subdevice
318 char *envStr = NULL;
319 int useRootDevice = 1;
320 envStr = getenv(ENABLE_SUB_DEVICE);
321 if (envStr != NULL) {
322 useRootDevice = 0;
323 }
324 int idx = addMetricToDevice(index, useRootDevice);
325 if (idx<0) {
326 return PAPI_ENOSUPP;
327 }
328 mContext->metric_idx[nmetrics] = index;
329 mContext->dev_ctx_idx[nmetrics] = idx;
330 mContext->subdev_idx[nmetrics] = GetSDev(index);
331 GPUDEBUG("add metric[%d] code 0x%x, in device[%d] (event subdev[%d])\n",
332 nmetrics, mContext->metric_idx[nmetrics],
333 mContext->dev_ctx_idx[nmetrics], mContext->subdev_idx[nmetrics]);
334
335 uint32_t i = 0;
336 for (i=0; i<mContext->num_devices; i++) {
337 if (mContext->active_devices[i] == (uint32_t)idx) {
338 // already in the list
339 break;
340 }
341 }
342 if (i == mContext->num_devices) {
343 mContext->active_devices[i] = idx;
344 mContext->num_devices++;
345 }
346 native[ni].ni_position = nmetrics;
347 nmetrics++;
348 }
349 // add this metric
350 mContext->num_metrics = nmetrics;
351 return PAPI_OK;
352}
353
354
355static int
357{
358 GPUDEBUG("Entering intel_gpu_start\n");
359
360 MetricCtlState *mCtlSt = (MetricCtlState *)ctl;
361 MetricContext *mContext = (MetricContext *)ctx;
362
363 int ret = PAPI_OK;
364 if (mContext->num_metrics == 0) {
365 GPUDEBUG("intel_gpu_start : No metric selected, abort.\n");
366 return PAPI_EINVAL;
367 }
368
369 char **metrics = calloc(mContext->num_metrics, sizeof(char *));
370 if (!metrics) {
371 GPUDEBUG("intel_gpu_start : insufficient memory, abort.\n");
372 return PAPI_ENOMEM;
373 }
374
375 mContext->num_reports = 0;
376
377 for (uint32_t i=0; i<mContext->num_devices; i++) {
378 uint32_t dev_idx = mContext->active_devices[i];
379 if (dev_idx >= num_active_devices) {
380 ret = PAPI_ENOMEM;
381 break;
382 }
383 DeviceContext *dev = &active_devices[dev_idx];
386 mCtlSt->metrics_type, mCtlSt->interval, mCtlSt->loops)) {
387 GPUDEBUG("intel_gpu_start on EnableMetrics failed, return 0x%x \n", PAPI_ENOSUPP);
388 ret = PAPI_ENOMEM;
389 break;
390 }
391 }
392 return ret;
393}
394
395static int
397{
398 GPUDEBUG("Entering intel_gpu_stop\n");
399
400 MetricContext *mContext = (MetricContext *)ctx;
401 MetricCtlState *mCtlSt = (MetricCtlState *)ctl;
402 int ret = PAPI_OK;
403
404 for (uint32_t i=0; i<mContext->num_devices; i++) {
405 uint32_t dev_idx = mContext->active_devices[i];
406 if (dev_idx < num_active_devices) {
407 DeviceContext *dev = &active_devices[dev_idx];
410 GPUDEBUG("intel_gpu_stop : failed with ret %d\n", ret);
411 ret = PAPI_EINVAL;
412 }
413 }
414 }
415 return ret;
416}
417
418static int
419intel_gpu_read( hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags )
420{
421 GPUDEBUG("Entering intel_gpu_read\n");
422
423 (void)flags;
424
425 MetricCtlState *mCtlSt = (MetricCtlState *)ctl;
426 MetricContext *mContext = (MetricContext *)ctx;
427 MetricData *reports = NULL;
428 uint32_t numReports = 0;
429 int ret = PAPI_OK;
430
431 if (!events) {
432 return PAPI_EINVAL;
433 }
434
435 if (mContext->num_metrics == 0) {
436 GPUDEBUG("intel_gpu_read: no metric is selected\n");
437 return PAPI_OK;
438 }
439 for (uint32_t i=0; i<mContext->num_devices; i++) {
440 uint32_t dc_idx = mContext->active_devices[i];
441 numReports = 0;
442 if (dc_idx >= num_active_devices) {
443 continue;
444 }
445
446 DeviceContext *dc = &active_devices[dc_idx];
448 reports = GPUReadMetricData(handle, mCtlSt->mode, &numReports);
449
450 if (!reports) {
451 GPUDEBUG("intel_gpu_read failed on device 0x%x\n", GetDeviceCode(handle));
452 continue;
453 } else if (!numReports) {
454 GPUFreeMetricData(reports, numReports);
455 GPUDEBUG("intel_gpu_read: no data available on device 0x%x\n", GetDeviceCode(handle));
456 continue;
457 }
458
459 if (dc->data) {
461 }
462 /* take last report, it is expected the numReports is 1 */
463 dc->data = &reports[numReports-1];
464 dc->num_reports = numReports;
465 }
466 for (uint32_t i=0; i<mContext->num_metrics; i++) {
467 uint32_t dc_idx = mContext->dev_ctx_idx[i];
468 DeviceContext *dc = &(active_devices[dc_idx]);
469 int index = GetIdx(mContext->metric_idx[i]);
470 int start_idx = 0;
471 if (!(dc->device_code &DMASK)) { // root device
472 uint32_t dc_sidx = GetSDev(mContext->metric_idx[i]);
473 if (dc_sidx > 0) {
474 dc_sidx--; // zero index
475 }
476 if (dc_sidx < dc->data->numDataSets) {
477 start_idx = dc->data->dataSetStartIdx[dc_sidx];
478 } else {
479 start_idx = -1;
480 }
481 }
482 if ((start_idx < 0) || !dc->data || !dc->num_reports) {
483 mContext->metric_values[i] = 0; // no data available
484 } else {
485 uint32_t midx = GetMetricIdx(metricInfoList.infoEntries[index].code)-1;
486 if (!dc->data->dataEntries[midx].type) {
487 mContext->metric_values[i] =
488 (long long)dc->data->dataEntries[start_idx + midx].value.ival;
489 } else {
490 mContext->metric_values[i] =
491 (long long)dc->data->dataEntries[start_idx + midx].value.fpval;
492 }
493 }
494 }
495
496 mContext->num_reports = numReports;
497 *events = mContext->metric_values;
498 return ret;
499}
500
501static int
503{
504 (void)ctx;
505 GPUDEBUG("Entering intel_gpu_shutdown_thread\n" );
506 return PAPI_OK;
507}
508
509static int
511{
512 GPUDEBUG("Entering intel_gpu_shutdown_component\n");
513 for (uint32_t i=0; i<num_avail_devices; i++) {
516 }
517 return PAPI_OK;
518}
519
520/*
521 * reset function will reset the global accumualted metrics values
522 */
523static int
525{
526
527 (void)ctl;
528 GPUDEBUG("Entering intel_gpu_reset\n");
529 MetricContext *mContext = (MetricContext *)ctx;
530
531 for (uint32_t i=0; i<num_avail_devices; i++) {
532 uint32_t dev_idx = mContext->active_devices[i];
533 if (dev_idx < num_active_devices) {
534 DeviceContext *dev = &active_devices[dev_idx];
536 }
537 }
538 return PAPI_OK;
539}
540
541static int
543{
544 GPUDEBUG("Entering intel_gpu_ctl\n");
545
546 (void) ctx;
547 (void) code;
548 (void) option;
549 return PAPI_OK;
550}
551
552
553static int
555{
556 GPUDEBUG("Entering intel_gpu_set_domain\n");
557
558 if (!ctl) {
559 return PAPI_EINVAL;
560 }
561 MetricCtlState *mCtlSt = (MetricCtlState *)ctl;
562 mCtlSt->domain = domain;
563 return PAPI_OK;
564
565}
566
567static int
568intel_gpu_ntv_enum_events(uint32_t *EventCode, int modifier )
569{
570 GPUDEBUG("Entering intel_gpu_ntv_enum_events\n");
571 int index = 0;
572
573 if (!EventCode) {
574 return PAPI_EINVAL;
575 }
576 switch ( modifier ) {
577 case PAPI_ENUM_FIRST:
578 *EventCode = 0;
579 break;
580 case PAPI_ENUM_EVENTS:
581 index = GetIdx(*EventCode);
582 uint32_t dev_code = GetDeviceCode(*EventCode);
583 if ( (index < 0 ) || (index >= (total_metrics-1)) ) {
584 return PAPI_ENOEVNT;
585 }
586 *EventCode = CreateIdxCode(dev_code, index+1);
587 break;
588 default:
589 return PAPI_EINVAL;
590 }
591 return PAPI_OK;
592}
593
594static int
595intel_gpu_ntv_code_to_name( uint32_t EventCode, char *name, int len )
596{
597 GPUDEBUG("Entering intel_gpu_ntv_code_to_name\n");
598 int index = GetIdx(EventCode);
599
600 if( ( index < 0 ) || ( index >= total_metrics ) || !name || !len ) {
601 return PAPI_EINVAL;
602 }
603
604 memset(name, 0, len);
605 strncpy_se(name, len, metricInfoList.infoEntries[index].name,
606 strlen(metricInfoList.infoEntries[index].name));
607 return PAPI_OK;
608}
609
610static int
611intel_gpu_ntv_code_to_descr( uint32_t EventCode, char *desc, int len )
612{
613 GPUDEBUG("Entering intel_gpu_ntv_code_to_descr\n");
614 int index = GetIdx(EventCode);
615
616 if( ( index < 0 ) || ( index >= total_metrics ) || !desc || !len) {
617 return PAPI_EINVAL;
618 }
619
620 memset(desc, 0, len);
621 strncpy_se(desc, len, metricInfoList.infoEntries[index].desc, MAX_STR_LEN-1);
622 return PAPI_OK;
623}
624
625static int
626intel_gpu_ntv_name_to_code( const char *name, uint32_t *event_code)
627{
628 GPUDEBUG("Entering intel_gpu_ntv_name_to_code\n");
629 if( !name || !event_code) {
630 return PAPI_EINVAL;
631 }
632
633 for (int i=0; i<total_metrics; i++) {
634 if (strncmp(metricInfoList.infoEntries[i].name, name,
635 strlen(metricInfoList.infoEntries[i].name)) == 0) {
636 int devnum = 0;
637 int tilenum = 0;
638 parseMetricName(name, &devnum, &tilenum);
639 uint32_t code = CreateDeviceCode(1, devnum, tilenum);
640 *event_code = CreateIdxCode(code, i);
641 return PAPI_OK;
642 }
643 }
644 return PAPI_ENOEVNT;
645}
646
647static int
649{
650 GPUDEBUG("Entering intel_gpu_ntv_code_to_info\n");
651 int index = GetIdx(EventCode);
652 if( ( index < 0 ) || ( index >= total_metrics ) || !info) {
653 return PAPI_EINVAL;
654 }
655
656 info->event_code = EventCode;
658 metricInfoList.infoEntries[index].name, MAX_STR_LEN-1);
659 // short description could be truncated due to the longer string size of metric name
661 metricInfoList.infoEntries[index].name,
662 strlen(metricInfoList.infoEntries[index].name));
664 metricInfoList.infoEntries[index].desc, MAX_STR_LEN-1);
666 return PAPI_OK;
667}
668
669/* Our component vector */
670
672 .cmp_info = {
673 /* component information (unspecified values initialized to 0) */
674 .name = "intel_gpu",
675 .short_name = "intel_gpu",
676 .version = "1.0",
677 .description = "Intel GPU performance metrics",
678 .default_domain = PAPI_DOM_ALL,
679 .available_domains = PAPI_DOM_USER | PAPI_DOM_KERNEL | PAPI_DOM_SUPERVISOR,
680 .default_granularity = PAPI_GRN_SYS,
681 .available_granularities = PAPI_GRN_SYS,
682 .num_mpx_cntrs = GPU_MAX_COUNTERS,
683
684 /* component specific cmp_info initializations */
685 .fast_virtual_timer = 0,
686 .attach = 0,
687 .attach_must_ptrace = 0,
688 .cpu = 0,
689 .inherit = 0,
690 .cntr_umasks = 0,
691 },
692
693 /* sizes of framework-opaque component-private structures */
694 .size = {
695 .context = sizeof (MetricContext),
696 .control_state = sizeof (MetricCtlState),
697 .reg_value = sizeof ( int ),
698 .reg_alloc = sizeof ( int ),
699 },
700
701 /* function pointers in this component */
702 .init_thread = intel_gpu_init_thread,
703 .init_component = intel_gpu_init_component,
704 .init_control_state = intel_gpu_init_control_state,
705 .update_control_state = intel_gpu_update_control_state,
706 .start = intel_gpu_start,
707 .stop = intel_gpu_stop,
708 .read = intel_gpu_read,
709 .shutdown_thread = intel_gpu_shutdown_thread,
710 .shutdown_component = intel_gpu_shutdown_component,
711 .ctl = intel_gpu_ctl,
712
713 /* these are dummy implementation */
714 .set_domain = intel_gpu_set_domain,
715 .reset = intel_gpu_reset,
716
717 /* from counter name mapper */
718 .ntv_enum_events = intel_gpu_ntv_enum_events,
719 .ntv_code_to_name = intel_gpu_ntv_code_to_name,
720 .ntv_name_to_code = intel_gpu_ntv_name_to_code,
721 .ntv_code_to_descr = intel_gpu_ntv_code_to_descr,
722 .ntv_code_to_info = intel_gpu_ntv_code_to_info,
723};
724
int GPUGetMetricList(DEVICE_HANDLE handle, char *groupName, uint32_t mtype, MetricInfo *data)
list available metrics in the named group. If name is "", list all available metrics in all groups
#define IsDeviceHandle(devcode, handle)
void strncpy_se(char *dest, size_t destSize, char *src, size_t count)
int GPUEnableMetricGroup(DEVICE_HANDLE handle, char *metricGroupName, uint32_t metricGroupCode, uint32_t mtype, uint32_t period, uint32_t numReports)
#define EVENT_BASED
#define CreateIdxCode(devcode, idx)
#define GetDeviceCode(handle)
#define MAX_STR_LEN
#define DMASK
#define METRIC_RESET
#define GetIdx(handle)
int GPUDisableMetricGroup(DEVICE_HANDLE handle, uint32_t mtype)
int GPUDetectDevice(DEVICE_HANDLE **handle, uint32_t *numDevice)
Detect the named device which has performance monitoring feature availale.
MetricData * GPUReadMetricData(DEVICE_HANDLE handle, uint32_t mode, uint32_t *reportCounts)
read metric data
#define GetSDev(handle)
void GPUFreeMetricData(MetricData *data, uint32_t count)
int GPUSetMetricControl(DEVICE_HANDLE handle, uint32_t mode)
set control for metric data collection
int DEVICE_HANDLE
#define GetMetricIdx(code)
#define TIME_BASED
#define GetGroupIdx(code)
#define CreateDeviceCode(drv, dev, sdev)
void GPUFreeDevice(DEVICE_HANDLE handle)
free the resouce related this device handle
static papi_handle_t handle
Definition: Gamum.c:21
int i
static long count
struct papi_vectors * _papi_hwd[]
#define PAPI_DOM_USER
Definition: f90papi.h:174
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_MIN_STR_LEN
Definition: f90papi.h:208
#define PAPI_DOM_KERNEL
Definition: f90papi.h:254
#define PAPI_ENOEVNT
Definition: f90papi.h:139
#define PAPI_DOM_SUPERVISOR
Definition: f90papi.h:109
#define PAPI_EINVAL
Definition: f90papi.h:115
#define PAPI_ENOSUPP
Definition: f90papi.h:244
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
#define PAPI_GRN_SYS
Definition: f90papi.h:43
#define PAPI_ENOMEM
Definition: f90papi.h:16
#define PAPI_HUGE_STR_LEN
Definition: f90papi.h:120
#define PAPI_DOM_ALL
Definition: f90papi.h:261
char events[MAX_EVENTS][BUFSIZ]
void(* _dl_non_dynamic_init)(void)
static int intel_gpu_reset(hwd_context_t *ctx, hwd_control_state_t *ctl)
static DEVICE_HANDLE * avail_devices
static int intel_gpu_start(hwd_context_t *ctx, hwd_control_state_t *ctl)
static int intel_gpu_ntv_code_to_name(uint32_t EventCode, char *name, int len)
static int intel_gpu_init_component(int cidx)
static int intel_gpu_ntv_enum_events(uint32_t *EventCode, int modifier)
static MetricInfo metricInfoList
static uint32_t num_avail_devices
static int intel_gpu_ntv_code_to_descr(uint32_t EventCode, char *desc, int len)
static int intel_gpu_update_control_state(hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
static int intel_gpu_ctl(hwd_context_t *ctx, int code, _papi_int_option_t *option)
#define GPUDEBUG
static int intel_gpu_init_thread(hwd_context_t *ctx)
static int intel_gpu_ntv_code_to_info(uint32_t EventCode, PAPI_event_info_t *info)
static int total_metrics
static uint32_t num_active_devices
static int global_metrics_type
static int intel_gpu_shutdown_component(void)
DeviceContext * active_devices
static int intel_gpu_set_domain(hwd_control_state_t *ctl, int domain)
void parseMetricName(const char *metricName, int *devnum, int *tilenum)
Parser a metric name with qualifiers metricName can be component:::metrcGroup.metricname:device=xx:ti...
#define DEFAULT_MODE
static int intel_gpu_ntv_name_to_code(const char *name, uint32_t *event_code)
papi_vector_t _intel_gpu_vector
static int intel_gpu_init_control_state(hwd_control_state_t *ctl)
Setup a counter control state. In general a control state holds the hardware info for an EventSet.
static int intel_gpu_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
static int intel_gpu_shutdown_thread(hwd_context_t *ctx)
int addMetricToDevice(uint32_t code, int rootDev)
Add a metrics to a certain metric device.
DEVICE_HANDLE getHandle(uint32_t device_code)
Get handle from device code.
#define DEFAULT_LOOPS
static int intel_gpu_read(hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
#define ENABLE_SUB_DEVICE
#define ENABLE_API_TRACING
#define GPU_MAX_COUNTERS
#define DEFAULT_SAMPLING_PERIOD
#define MINIMUM_SAMPLING_PERIOD
#define METRICS_SAMPLING_PERIOD
static int native
static int cidx
const char * name
Definition: rocs.c:225
int
Definition: sde_internal.h:89
long long int long long
Definition: sde_internal.h:85
long long ival
union DataEntry::@1 value
uint32_t metric_code[GPU_MAX_METRICS]
uint32_t dev_ctx_idx[GPU_MAX_METRICS]
uint32_t subdev_idx[GPU_MAX_METRICS]
uint32_t metric_idx[GPU_MAX_METRICS]
long long metric_values[GPU_MAX_METRICS]
DataEntry * dataEntries
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:627
char disabled_reason[PAPI_HUGE_STR_LEN]
Definition: papi.h:634
int component_index
Definition: papi.h:968
unsigned int event_code
Definition: papi.h:958
char short_descr[PAPI_MIN_STR_LEN]
Definition: papi.h:961
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:960
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
int retval
Definition: zero_fork.c:53