PAPI 7.1.0.0
Loading...
Searching...
No Matches
linux_intel_gpu_metrics.c File Reference
Include dependency graph for linux_intel_gpu_metrics.c:

Go to the source code of this file.

Macros

#define DEFAULT_LOOPS   0
 
#define DEFAULT_MODE   METRIC_SUMMARY
 
#define GPUDEBUG   SUBDBG
 

Functions

void parseMetricName (const char *metricName, int *devnum, int *tilenum)
 Parser a metric name with qualifiers metricName can be component:::metrcGroup.metricname:device=xx:tile=yy or metrcGroup.metricname:device=xx:tile=yy.
 
DEVICE_HANDLE getHandle (uint32_t device_code)
 Get handle from device code.
 
int addMetricToDevice (uint32_t code, int rootDev)
 Add a metrics to a certain metric device.
 
static int intel_gpu_init_thread (hwd_context_t *ctx)
 
static int intel_gpu_init_component (int cidx)
 
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_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
 
static int intel_gpu_start (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int intel_gpu_stop (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int intel_gpu_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
 
static int intel_gpu_shutdown_thread (hwd_context_t *ctx)
 
static int intel_gpu_shutdown_component (void)
 
static int intel_gpu_reset (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int intel_gpu_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
static int intel_gpu_set_domain (hwd_control_state_t *ctl, int domain)
 
static int intel_gpu_ntv_enum_events (uint32_t *EventCode, int modifier)
 
static int intel_gpu_ntv_code_to_name (uint32_t EventCode, char *name, int len)
 
static int intel_gpu_ntv_code_to_descr (uint32_t EventCode, char *desc, int len)
 
static int intel_gpu_ntv_name_to_code (const char *name, uint32_t *event_code)
 
static int intel_gpu_ntv_code_to_info (uint32_t EventCode, PAPI_event_info_t *info)
 

Variables

static uint32_t num_avail_devices = 0
 
static DEVICE_HANDLEavail_devices
 
static uint32_t num_active_devices = 0
 
DeviceContextactive_devices
 
static MetricInfo metricInfoList
 
static int total_metrics = 0
 
static int global_metrics_type = TIME_BASED
 
papi_vector_t _intel_gpu_vector
 

Macro Definition Documentation

◆ DEFAULT_LOOPS

#define DEFAULT_LOOPS   0

Definition at line 37 of file linux_intel_gpu_metrics.c.

◆ DEFAULT_MODE

#define DEFAULT_MODE   METRIC_SUMMARY

Definition at line 38 of file linux_intel_gpu_metrics.c.

◆ GPUDEBUG

#define GPUDEBUG   SUBDBG

Definition at line 40 of file linux_intel_gpu_metrics.c.

Function Documentation

◆ addMetricToDevice()

int addMetricToDevice ( uint32_t  code,
int  rootDev 
)

Definition at line 107 of file linux_intel_gpu_metrics.c.

107 {
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}
#define GetDeviceCode(handle)
#define GetIdx(handle)
int DEVICE_HANDLE
#define GetMetricIdx(code)
#define GetGroupIdx(code)
int i
#define PAPI_ENOSUPP
Definition: f90papi.h:244
static MetricInfo metricInfoList
static uint32_t num_avail_devices
#define GPUDEBUG
static int total_metrics
static uint32_t num_active_devices
DeviceContext * active_devices
DEVICE_HANDLE getHandle(uint32_t device_code)
Get handle from device code.
uint32_t metric_code[GPU_MAX_METRICS]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHandle()

DEVICE_HANDLE getHandle ( uint32_t  device_code)

Definition at line 93 of file linux_intel_gpu_metrics.c.

93 {
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}
#define IsDeviceHandle(devcode, handle)
static DEVICE_HANDLE * avail_devices
Here is the caller graph for this function:

◆ intel_gpu_ctl()

static int intel_gpu_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
)
static

Definition at line 542 of file linux_intel_gpu_metrics.c.

543{
544 GPUDEBUG("Entering intel_gpu_ctl\n");
545
546 (void) ctx;
547 (void) code;
548 (void) option;
549 return PAPI_OK;
550}
#define PAPI_OK
Definition: f90papi.h:73

◆ intel_gpu_init_component()

static int intel_gpu_init_component ( int  cidx)
static

Definition at line 174 of file linux_intel_gpu_metrics.c.

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}
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
void strncpy_se(char *dest, size_t destSize, char *src, size_t count)
#define EVENT_BASED
int GPUDetectDevice(DEVICE_HANDLE **handle, uint32_t *numDevice)
Detect the named device which has performance monitoring feature availale.
void GPUFreeDevice(DEVICE_HANDLE handle)
free the resouce related this device handle
static papi_handle_t handle
Definition: Gamum.c:21
struct papi_vectors * _papi_hwd[]
#define PAPI_EINVAL
Definition: f90papi.h:115
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
void(* _dl_non_dynamic_init)(void)
static int global_metrics_type
papi_vector_t _intel_gpu_vector
#define ENABLE_API_TRACING
#define GPU_MAX_COUNTERS
static int cidx
char disabled_reason[PAPI_HUGE_STR_LEN]
Definition: papi.h:634
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:

◆ intel_gpu_init_control_state()

static int intel_gpu_init_control_state ( hwd_control_state_t ctl)
static

Definition at line 250 of file linux_intel_gpu_metrics.c.

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}
#define DEFAULT_MODE
#define DEFAULT_LOOPS
#define DEFAULT_SAMPLING_PERIOD
#define MINIMUM_SAMPLING_PERIOD
#define METRICS_SAMPLING_PERIOD

◆ intel_gpu_init_thread()

static int intel_gpu_init_thread ( hwd_context_t ctx)
static

Definition at line 164 of file linux_intel_gpu_metrics.c.

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}

◆ intel_gpu_ntv_code_to_descr()

static int intel_gpu_ntv_code_to_descr ( uint32_t  EventCode,
char *  desc,
int  len 
)
static

Definition at line 611 of file linux_intel_gpu_metrics.c.

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}
#define MAX_STR_LEN
Here is the call graph for this function:

◆ intel_gpu_ntv_code_to_info()

static int intel_gpu_ntv_code_to_info ( uint32_t  EventCode,
PAPI_event_info_t info 
)
static

Definition at line 648 of file linux_intel_gpu_metrics.c.

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}
#define PAPI_MIN_STR_LEN
Definition: f90papi.h:208
#define PAPI_HUGE_STR_LEN
Definition: f90papi.h:120
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
Here is the call graph for this function:

◆ intel_gpu_ntv_code_to_name()

static int intel_gpu_ntv_code_to_name ( uint32_t  EventCode,
char *  name,
int  len 
)
static

Definition at line 595 of file linux_intel_gpu_metrics.c.

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}
const char * name
Definition: rocs.c:225
Here is the call graph for this function:

◆ intel_gpu_ntv_enum_events()

static int intel_gpu_ntv_enum_events ( uint32_t *  EventCode,
int  modifier 
)
static

Definition at line 568 of file linux_intel_gpu_metrics.c.

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}
#define CreateIdxCode(devcode, idx)
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_ENOEVNT
Definition: f90papi.h:139

◆ intel_gpu_ntv_name_to_code()

static int intel_gpu_ntv_name_to_code ( const char *  name,
uint32_t *  event_code 
)
static

Definition at line 626 of file linux_intel_gpu_metrics.c.

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}
#define CreateDeviceCode(drv, dev, sdev)
void parseMetricName(const char *metricName, int *devnum, int *tilenum)
Parser a metric name with qualifiers metricName can be component:::metrcGroup.metricname:device=xx:ti...
Here is the call graph for this function:

◆ intel_gpu_read()

static int intel_gpu_read ( hwd_context_t ctx,
hwd_control_state_t ctl,
long long **  events,
int  flags 
)
static

Definition at line 419 of file linux_intel_gpu_metrics.c.

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}
#define DMASK
MetricData * GPUReadMetricData(DEVICE_HANDLE handle, uint32_t mode, uint32_t *reportCounts)
read metric data
#define GetSDev(handle)
void GPUFreeMetricData(MetricData *data, uint32_t count)
char events[MAX_EVENTS][BUFSIZ]
long long int long long
Definition: sde_internal.h:85
long long ival
union DataEntry::@1 value
uint32_t dev_ctx_idx[GPU_MAX_METRICS]
uint32_t metric_idx[GPU_MAX_METRICS]
long long metric_values[GPU_MAX_METRICS]
DataEntry * dataEntries
Here is the call graph for this function:

◆ intel_gpu_reset()

static int intel_gpu_reset ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 524 of file linux_intel_gpu_metrics.c.

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}
#define METRIC_RESET
int GPUSetMetricControl(DEVICE_HANDLE handle, uint32_t mode)
set control for metric data collection
Here is the call graph for this function:

◆ intel_gpu_set_domain()

static int intel_gpu_set_domain ( hwd_control_state_t ctl,
int  domain 
)
static

Definition at line 554 of file linux_intel_gpu_metrics.c.

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}

◆ intel_gpu_shutdown_component()

static int intel_gpu_shutdown_component ( void  )
static

Definition at line 510 of file linux_intel_gpu_metrics.c.

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}
Here is the call graph for this function:

◆ intel_gpu_shutdown_thread()

static int intel_gpu_shutdown_thread ( hwd_context_t ctx)
static

Definition at line 502 of file linux_intel_gpu_metrics.c.

503{
504 (void)ctx;
505 GPUDEBUG("Entering intel_gpu_shutdown_thread\n" );
506 return PAPI_OK;
507}

◆ intel_gpu_start()

static int intel_gpu_start ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 356 of file linux_intel_gpu_metrics.c.

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}
int GPUEnableMetricGroup(DEVICE_HANDLE handle, char *metricGroupName, uint32_t metricGroupCode, uint32_t mtype, uint32_t period, uint32_t numReports)
#define PAPI_ENOMEM
Definition: f90papi.h:16
Here is the call graph for this function:

◆ intel_gpu_stop()

static int intel_gpu_stop ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 396 of file linux_intel_gpu_metrics.c.

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}
int GPUDisableMetricGroup(DEVICE_HANDLE handle, uint32_t mtype)
Here is the call graph for this function:

◆ intel_gpu_update_control_state()

static int intel_gpu_update_control_state ( hwd_control_state_t ctl,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)
static

Definition at line 278 of file linux_intel_gpu_metrics.c.

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}
static long count
int addMetricToDevice(uint32_t code, int rootDev)
Add a metrics to a certain metric device.
#define ENABLE_SUB_DEVICE
static int native
uint32_t subdev_idx[GPU_MAX_METRICS]
Here is the call graph for this function:

◆ parseMetricName()

void parseMetricName ( const char *  metricName,
int devnum,
int tilenum 
)
Parameters
INmetricName – metric name in the above format
OUTdevnum – device id
OUTtilenum – tile id

Definition at line 66 of file linux_intel_gpu_metrics.c.

66 {
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}
Here is the caller graph for this function:

Variable Documentation

◆ _intel_gpu_vector

papi_vector_t _intel_gpu_vector

Definition at line 54 of file linux_intel_gpu_metrics.c.

◆ active_devices

DeviceContext* active_devices

Definition at line 48 of file linux_intel_gpu_metrics.c.

◆ avail_devices

DEVICE_HANDLE* avail_devices
static

Definition at line 44 of file linux_intel_gpu_metrics.c.

◆ global_metrics_type

int global_metrics_type = TIME_BASED
static

Definition at line 52 of file linux_intel_gpu_metrics.c.

◆ metricInfoList

MetricInfo metricInfoList
static

Definition at line 50 of file linux_intel_gpu_metrics.c.

◆ num_active_devices

uint32_t num_active_devices = 0
static

Definition at line 47 of file linux_intel_gpu_metrics.c.

◆ num_avail_devices

uint32_t num_avail_devices = 0
static

Definition at line 43 of file linux_intel_gpu_metrics.c.

◆ total_metrics

int total_metrics = 0
static

Definition at line 51 of file linux_intel_gpu_metrics.c.