Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024.10.17 preset extensions #284

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/components/cuda/cupti_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ void cuptid_disabled_reason_get(const char **msg)
cuptic_disabled_reason_get(msg);
}

int cuptid_get_chip_name(int dev_num, char *name)
{
return get_chip_name(dev_num, name);
}

int cuptid_device_get_count(int *num_gpus)
{
return cuptic_device_get_count(num_gpus);
}

int cuptid_init(void)
{
int papi_errno;
Expand Down
2 changes: 2 additions & 0 deletions src/components/cuda/cupti_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ int cuptid_thread_info_destroy(cuptid_info_t *info);

/* misc. */
void cuptid_disabled_reason_get(const char **msg);
int cuptid_get_chip_name(int dev_num, char *name);
int cuptid_device_get_count(int *num_gpus);

#endif /* __CUPTI_DISPATCH_H__ */
22 changes: 0 additions & 22 deletions src/components/cuda/cupti_profiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ static int begin_profiling(cuptip_gpu_state_t *gpu_ctl);
static int end_profiling(cuptip_gpu_state_t *gpu_ctl);

/* NVIDIA chip functions */
static int get_chip_name(int dev_num, char* chipName);
static int find_same_chipname(int gpu_id);

/* functions to check if a cuda native event requires multiple passes */
Expand Down Expand Up @@ -195,7 +194,6 @@ NVPA_Status ( *NVPW_MetricsContext_GetCounterNames_BeginPtr ) (NVPW_MetricsConte
NVPA_Status ( *NVPW_MetricsContext_GetCounterNames_EndPtr ) (NVPW_MetricsContext_GetCounterNames_End_Params* pParams);

/* cupti function pointers */
CUptiResult ( *cuptiDeviceGetChipNamePtr ) (CUpti_Device_GetChipName_Params* params);
CUptiResult ( *cuptiProfilerInitializePtr ) (CUpti_Profiler_Initialize_Params* params);
CUptiResult ( *cuptiProfilerDeInitializePtr ) (CUpti_Profiler_DeInitialize_Params* params);
CUptiResult ( *cuptiProfilerCounterDataImageCalculateSizePtr ) (CUpti_Profiler_CounterDataImage_CalculateSize_Params* params);
Expand Down Expand Up @@ -229,7 +227,6 @@ static int load_cupti_perf_sym(void)
goto fn_fail;
}

cuptiDeviceGetChipNamePtr = DLSYM_AND_CHECK(dl_cupti, "cuptiDeviceGetChipName");
cuptiProfilerInitializePtr = DLSYM_AND_CHECK(dl_cupti, "cuptiProfilerInitialize");
cuptiProfilerDeInitializePtr = DLSYM_AND_CHECK(dl_cupti, "cuptiProfilerDeInitialize");
cuptiProfilerCounterDataImageCalculateSizePtr = DLSYM_AND_CHECK(dl_cupti, "cuptiProfilerCounterDataImageCalculateSize");
Expand Down Expand Up @@ -266,7 +263,6 @@ static int unload_cupti_perf_sym(void)
dlclose(dl_cupti);
dl_cupti = NULL;
}
cuptiDeviceGetChipNamePtr = NULL;
cuptiProfilerInitializePtr = NULL;
cuptiProfilerDeInitializePtr = NULL;
cuptiProfilerCounterDataImageCalculateSizePtr = NULL;
Expand Down Expand Up @@ -469,24 +465,6 @@ static int initialize_perfworks_api(void)
}


static int get_chip_name(int dev_num, char* chipName)
{
int papi_errno;
CUpti_Device_GetChipName_Params getChipName = {
.structSize = CUpti_Device_GetChipName_Params_STRUCT_SIZE,
.pPriv = NULL,
.deviceIndex = 0
};
getChipName.deviceIndex = dev_num;
papi_errno = cuptiDeviceGetChipNamePtr(&getChipName);
if (papi_errno != CUPTI_SUCCESS) {
ERRDBG("CUPTI error %d: Failed to get chip name for device %d\n", papi_errno, dev_num);
return PAPI_EMISC;
}
strcpy(chipName, getChipName.pChipName);
return PAPI_OK;
}

/** @class get_event_names_rmr
* @brief For a Cuda native event name collect raw metrics and count
* of raw metrics for collection. Raw Metrics are one layer of the Metric API
Expand Down
37 changes: 37 additions & 0 deletions src/components/cuda/linux-cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static int cuda_init_thread(hwd_context_t *ctx);
static int cuda_init_control_state(hwd_control_state_t *ctl);
static int cuda_shutdown_thread(hwd_context_t *ctx);
static int cuda_shutdown_component(void);
static int cuda_init_comp_presets(void);

/* set and update component state */
static int cuda_update_control_state(hwd_control_state_t *ctl,
Expand Down Expand Up @@ -117,6 +118,7 @@ papi_vector_t _cuda_vector = {

.init_thread = cuda_init_thread,
.shutdown_thread = cuda_shutdown_thread,
.init_comp_presets = cuda_init_comp_presets,

.ntv_enum_events = cuda_ntv_enum_events,
.ntv_code_to_name = cuda_ntv_code_to_name,
Expand Down Expand Up @@ -314,6 +316,41 @@ static int cuda_shutdown_thread(hwd_context_t *ctx)
return PAPI_OK;
}

static int cuda_init_comp_presets(void)
{
int cidx = _cuda_vector.cmp_info.CmpIdx;
char *cname = _cuda_vector.cmp_info.name;

/* Setup presets. */
char arch_name[PAPI_2MAX_STR_LEN];
int devIdx = -1;
int numDevices = 0;

int retval = cuptid_device_get_count(&numDevices);
if ( retval != PAPI_OK ) {
return PAPI_EMISC;
}

/* Load preset table for every device type available on the system.
* As long as one of the cards has presets defined, then they should
* be available. */
for( devIdx = 0; devIdx < numDevices; ++devIdx ) {
retval = cuptid_get_chip_name(devIdx, arch_name);
if ( retval == PAPI_OK ) {
break;
}
}

if ( devIdx > -1 && devIdx < numDevices ) {
retval = _papi_load_preset_table_component( cname, arch_name, cidx );
if ( retval != PAPI_OK ) {
return PAPI_ENOEVNT;
}
}

return PAPI_OK;
}

static int cuda_init_control_state(hwd_control_state_t __attribute__((unused)) *ctl)
{
COMPDBG("Entering.\n");
Expand Down
139 changes: 139 additions & 0 deletions src/components/cuda/papi_cuda_presets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#ifndef __PAPI_CUDA_PRESETS_H__
#define __PAPI_CUDA_PRESETS_H__

#define PAPI_MAX_cuda_PRESETS 128

hwi_presets_t _cuda_presets[PAPI_MAX_cuda_PRESETS] = {
/* 0 */ {"PAPI_CUDA_FP16_FMA",
"CUDA FP16 FMA instr",
"CUDA Half precision (FP16) FMA instructions", 0,
0, PAPI_PRESET_BIT_MSC,
NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 1 */ {"PAPI_CUDA_BF16_FMA",
"CUDA BF16 FMA instr",
"CUDA Half precision (BF16) FMA instructions", 0,
0, PAPI_PRESET_BIT_MSC,
NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 2 */ {"PAPI_CUDA_FP32_FMA",
"CUDA FP32 FMA instr",
"CUDA Single precision (FP32) FMA instructions", 0,
0, PAPI_PRESET_BIT_MSC,
NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 3 */ {"PAPI_CUDA_FP64_FMA",
"CUDA FP64 FMA instr",
"CUDA Double precision (FP64) FMA instructions", 0,
0, PAPI_PRESET_BIT_MSC,
NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 4 */ {"PAPI_CUDA_FMA",
"CUDA FMA instr",
"CUDA FMA instructions", 0,
0, PAPI_PRESET_BIT_MSC,
NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 4 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 5 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 6 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 7 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 8 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 9 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 10 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 11 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 12 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 13 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 14 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 15 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 16 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 17 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 18 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 19 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 21 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 22 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 23 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 24 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 25 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 26 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 27 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 28 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 29 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 30 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 31 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 32 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 33 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 34 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 35 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 36 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 37 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 38 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 39 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 40 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 41 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 42 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 43 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 44 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 45 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 46 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 47 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 48 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 49 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 50 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 51 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 52 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 53 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 54 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 55 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 56 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 57 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 58 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 59 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 60 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 61 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 62 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 63 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 64 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 65 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 66 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 67 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 68 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 69 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 70 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 71 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 72 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 73 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 74 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 75 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 76 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 77 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 78 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 79 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 80 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 81 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 82 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 83 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 84 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 85 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 86 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 87 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 88 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 89 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 90 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 91 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 92 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 93 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 94 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 95 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 96 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 97 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 98 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/* 99 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/*100 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/*110 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/*120 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/*121 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/*122 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/*123 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/*124 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/*125 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/*126 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
/*127 */ {NULL, NULL, NULL, 0, 0, 0, NULL, {0}, {NULL}, {NULL}, {0}, {NULL}, NULL, 0, 0, {NULL}, {NULL}},
};

#endif /* __PAPI_CUDA_PRESETS_H__ */
22 changes: 22 additions & 0 deletions src/components/cuda/papi_cupti_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <link.h>
#include <libgen.h>
#include <papi.h>
#include <cupti_target.h>
#include "papi_memory.h"

#include "cupti_config.h"
Expand Down Expand Up @@ -52,6 +53,7 @@ cudaError_t ( *cudaRuntimeGetVersionPtr ) (int *);

/* cupti function pointer */
CUptiResult ( *cuptiGetVersionPtr ) (uint32_t* );
CUptiResult ( *cuptiDeviceGetChipNamePtr ) (CUpti_Device_GetChipName_Params* params);

/**@class load_cuda_sym
* @brief Search for libcuda.so.
Expand Down Expand Up @@ -278,6 +280,7 @@ static int load_cupti_common_sym(void)
}

cuptiGetVersionPtr = DLSYM_AND_CHECK(dl_cupti, "cuptiGetVersion");
cuptiDeviceGetChipNamePtr = DLSYM_AND_CHECK(dl_cupti, "cuptiDeviceGetChipName");

Dl_info info;
dladdr(cuptiGetVersionPtr, &info);
Expand All @@ -294,6 +297,7 @@ static int unload_cupti_common_sym(void)
dl_cupti = NULL;
}
cuptiGetVersionPtr = NULL;
cuptiDeviceGetChipNamePtr = NULL;
return PAPI_OK;
}

Expand Down Expand Up @@ -764,3 +768,21 @@ int cuptiu_dev_check(cuptiu_bitmap_t bitmap, int i)
{
return (bitmap & (1ULL << i));
}

int get_chip_name(int dev_num, char* chipName)
{
int papi_errno;
CUpti_Device_GetChipName_Params getChipName = {
.structSize = CUpti_Device_GetChipName_Params_STRUCT_SIZE,
.pPriv = NULL,
.deviceIndex = 0
};
getChipName.deviceIndex = dev_num;
papi_errno = cuptiDeviceGetChipNamePtr(&getChipName);
if (papi_errno != CUPTI_SUCCESS) {
ERRDBG("CUPTI error %d: Failed to get chip name for device %d\n", papi_errno, dev_num);
return PAPI_EMISC;
}
strcpy(chipName, getChipName.pChipName);
return PAPI_OK;
}
3 changes: 3 additions & 0 deletions src/components/cuda/papi_cupti_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ int cuptic_device_release(cuptiu_event_table_t *evt_table);
int cuptiu_dev_set(cuptiu_bitmap_t *bitmap, int i);
int cuptiu_dev_check(cuptiu_bitmap_t bitmap, int i);

/* misc. */
int get_chip_name(int dev_num, char* chipName);

#define DLSYM_AND_CHECK( dllib, name ) dlsym( dllib, name ); \
if (dlerror() != NULL) { \
ERRDBG("A CUDA required function '%s' was not found in lib '%s'.\n", name, #dllib); \
Expand Down
Loading
Loading