Skip to content

Commit

Permalink
rocm: fix instanced events
Browse files Browse the repository at this point in the history
Some events have multiple instances. The way the component was handling
those events was wrong, causing such events to not work. This patch
fixes the problem.
  • Loading branch information
gcongiu committed Aug 18, 2023
1 parent 3dcc8b1 commit 66fab4e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/rocm/rocp.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
typedef struct {
char *name;
char *descr;
char *feature;
unsigned int ntv_dev;
unsigned int ntv_id;
int instance;
Expand Down Expand Up @@ -819,8 +820,15 @@ get_ntv_events_cb(const rocprofiler_info_data_t info, void *ntv_arg)
}

for (instance = 0; instance < instances; ++instance) {
char feature[PAPI_MAX_STR_LEN] = { 0 };
if (instances > 1) {
sprintf(feature, "%s[%d]", info.metric.name, instance);
} else {
sprintf(feature, "%s", info.metric.name);
}
events[*count].name = strdup(info.metric.name);
events[*count].descr = strdup(info.metric.description);
events[*count].feature = strdup(feature);
events[*count].ntv_dev = arg->dev_id;
events[*count].ntv_id = *count;
events[*count].instance = (instances > 1) ? (int) instance : -1;
Expand Down Expand Up @@ -1049,6 +1057,7 @@ shutdown_event_table(void)
for (i = 0; i < ntv_table_p->count; ++i) {
papi_free(ntv_table_p->events[i].name);
papi_free(ntv_table_p->events[i].descr);
papi_free(ntv_table_p->events[i].feature);
}

ntv_table_p->count = 0;
Expand Down Expand Up @@ -1290,10 +1299,9 @@ init_features(unsigned int *events_id, int num_events,

int i;
for (i = 0; i < num_events; ++i) {
char *name = ntv_table_p->events[events_id[i]].name;
features[i].kind =
(rocprofiler_feature_kind_t) ROCPROFILER_INFO_KIND_METRIC;
features[i].name = (const char *) name;
features[i].name = (const char *) ntv_table_p->events[events_id[i]].feature;
}

return papi_errno;
Expand Down

0 comments on commit 66fab4e

Please sign in to comment.