37#define DEFAULT_LOOPS 0
38#define DEFAULT_MODE METRIC_SUMMARY
40#define GPUDEBUG SUBDBG
67 char *
name = strdup(metricName);
73 if ((*param !=
'\0') && (ptr=strstr(param,
":"))) {
74 if ((ptr=strstr(param,
":device="))) {
78 if ((ptr=strstr(param,
":tile="))) {
83 *devnum = (dnum)?dnum:1;
84 *tilenum = (tnum)?tnum:0;
117 devcode = devcode & ~DMASK;
119 GPUDEBUG(
"addMetricToDevice, code 0x%x, group 0x%x, metric 0x%x, devcode 0x%x\n",
120 code, group, metric, devcode);
126 GPUDEBUG(
"intel_gpu: metrics from more than one group cannot be collected "
127 " in the same device at the same time. "
135 GPUDEBUG(
"intel_gpu: invalid event code 0x%x\n", code);
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. "
166 GPUDEBUG(
"Entering intel_gpu_init_thread\n");
177 GPUDEBUG(
"Entering intel_init_component\n");
184 if (putenv(
"ZET_ENABLE_METRICS=1")) {
185 errStr =
"Set ZET_ENABLE_METRICS=1 failed. Cannot access GPU metrics. ";
187 errStr, strlen(errStr));
192 errStr =
"The intel_gpu component does not support statically linking of libc.";
194 errStr, strlen(errStr));
199 errStr =
"The intel_gpu component does not detect metrics device.";
201 errStr, strlen(errStr));
210 if (envStr != NULL) {
211 if (atoi(envStr) == 1) {
218 errStr =
"The intel_gpu component failed on get all available metrics.";
220 errStr, strlen(errStr));
252 GPUDEBUG(
"Entering intel_gpu_control_state\n");
283 GPUDEBUG(
"Entering intel_gpu_control_state\n");
295 GPUDEBUG(
"\t i=%d, ni_event 0x%x, ni_papi_code 0x%x, ni_position %d, ni_owners %d \n",
304 for (ni = 0; ni <
count; ni++) {
305 uint32_t index =
native[ni].ni_event;
307 for (midx=0; midx<nmetrics; midx++) {
309 GPUDEBUG(
"metric code %d: already in the list, ignore\n", index);
313 if (midx < nmetrics) {
319 int useRootDevice = 1;
321 if (envStr != NULL) {
331 GPUDEBUG(
"add metric[%d] code 0x%x, in device[%d] (event subdev[%d])\n",
346 native[ni].ni_position = nmetrics;
358 GPUDEBUG(
"Entering intel_gpu_start\n");
365 GPUDEBUG(
"intel_gpu_start : No metric selected, abort.\n");
369 char **metrics = calloc(mContext->
num_metrics,
sizeof(
char *));
371 GPUDEBUG(
"intel_gpu_start : insufficient memory, abort.\n");
398 GPUDEBUG(
"Entering intel_gpu_stop\n");
410 GPUDEBUG(
"intel_gpu_stop : failed with ret %d\n", ret);
421 GPUDEBUG(
"Entering intel_gpu_read\n");
428 uint32_t numReports = 0;
436 GPUDEBUG(
"intel_gpu_read: no metric is selected\n");
453 }
else if (!numReports) {
463 dc->
data = &reports[numReports-1];
476 if (dc_sidx < dc->data->numDataSets) {
505 GPUDEBUG(
"Entering intel_gpu_shutdown_thread\n" );
512 GPUDEBUG(
"Entering intel_gpu_shutdown_component\n");
528 GPUDEBUG(
"Entering intel_gpu_reset\n");
544 GPUDEBUG(
"Entering intel_gpu_ctl\n");
556 GPUDEBUG(
"Entering intel_gpu_set_domain\n");
570 GPUDEBUG(
"Entering intel_gpu_ntv_enum_events\n");
576 switch ( modifier ) {
581 index =
GetIdx(*EventCode);
597 GPUDEBUG(
"Entering intel_gpu_ntv_code_to_name\n");
598 int index =
GetIdx(EventCode);
604 memset(
name, 0, len);
613 GPUDEBUG(
"Entering intel_gpu_ntv_code_to_descr\n");
614 int index =
GetIdx(EventCode);
616 if( ( index < 0 ) || ( index >=
total_metrics ) || !desc || !len) {
620 memset(desc, 0, len);
628 GPUDEBUG(
"Entering intel_gpu_ntv_name_to_code\n");
629 if( !
name || !event_code) {
650 GPUDEBUG(
"Entering intel_gpu_ntv_code_to_info\n");
651 int index =
GetIdx(EventCode);
675 .short_name =
"intel_gpu",
677 .description =
"Intel GPU performance metrics",
685 .fast_virtual_timer = 0,
687 .attach_must_ptrace = 0,
697 .reg_value =
sizeof (
int ),
698 .reg_alloc =
sizeof (
int ),
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 CreateIdxCode(devcode, idx)
#define GetDeviceCode(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
void GPUFreeMetricData(MetricData *data, uint32_t count)
int GPUSetMetricControl(DEVICE_HANDLE handle, uint32_t mode)
set control for metric data collection
#define GetMetricIdx(code)
#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
struct papi_vectors * _papi_hwd[]
#define PAPI_DOM_SUPERVISOR
#define PAPI_HUGE_STR_LEN
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)
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 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...
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.
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 DEFAULT_SAMPLING_PERIOD
#define MINIMUM_SAMPLING_PERIOD
#define METRICS_SAMPLING_PERIOD
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]
uint32_t * active_devices
char name[PAPI_MAX_STR_LEN]
char disabled_reason[PAPI_HUGE_STR_LEN]
char short_descr[PAPI_MIN_STR_LEN]
char symbol[PAPI_HUGE_STR_LEN]
char long_descr[PAPI_HUGE_STR_LEN]
PAPI_component_info_t cmp_info