Skip to content

Commit

Permalink
Update function to append default device qualifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
Treece Burgess committed Feb 12, 2025
1 parent b69fe75 commit b19ea13
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/components/cuda/cupti_profiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -2578,8 +2578,9 @@ static int evt_name_to_basename(const char *name, char *base, int len)
}

/** @class evt_name_to_device
* @brief Take a Cuda native event name with a device qualifer appended to
* it and collect the device number.
* @brief Return the device number for a user provided Cuda native event.
* This can be done with a device qualifier present (:device=#) or
* we internally find the first device the native event exists for.
* @param *name
* Cuda native event name with a device qualifier appended.
* @param *device
Expand All @@ -2588,11 +2589,27 @@ static int evt_name_to_basename(const char *name, char *base, int len)
static int evt_name_to_device(const char *name, int *device)
{
char *p = strstr(name, ":device=");
// User did provide :device=# qualifier
if (p) {
*device = (int) strtol(p + strlen(":device="), NULL, 10);
}
// User did not provide :device=# qualifier
else {
*device = 0;
int i, htable_errno;
cuptiu_event_t *event;

htable_errno = htable_find(cuptiu_table_p->htable, name, (void **) &event);
if (htable_errno != HTABLE_SUCCESS) {
return PAPI_EINVAL;
}

// Search for the first device the event exists for.
for (i = 0; i < num_gpus; ++i) {
if (cuptiu_dev_check(event->device_map, i)) {
*device = i;
break;
}
}
}
return PAPI_OK;
}

0 comments on commit b19ea13

Please sign in to comment.