35#if defined(__cplusplus)
40 "ComputeBasic.GpuTime",
41 "ComputeBasic.GpuCoreClocks",
42 "ComputeBasic.AvgGpuCoreFrequencyMHz",
56 char **metrics = (
char **)calloc(size,
sizeof(
char *));
57 char *token = strtok(metric_list,
",");
61 metrics = (
char **)realloc(metrics, size *
sizeof(
char *));
63 metrics[index++] = token;
64 printf(
"metric[%d]: %s\n", index-1, metrics[index-1]);
65 token = strtok(NULL,
",");
78 char *metric_list = NULL;
79 char *app_targets = NULL;
80 while ((ch=getopt(argc, argv,
"d:l:e:t:m:s")) != -1) {
86 duration = atoi(optarg);
87 if ((duration <= 0) || (duration > 3600)) {
88 printf(
"invalid input on dueation [1, 3600], use default 3 sec.\n");
94 if ((loops <= 0) || (loops > 0x100000)) {
95 printf(
"invalid input on loops [1, 1M], use default 1 loop.\n");
103 metric_list = strdup(optarg);
110 param->
loops = loops;
111 param->
reset = reset;
115 char *str = app_targets;
117 if ((str[
i]==
'd') && (str[
i+1] !=
'\0')) {
119 while ((str[
i] !=
'\0') && ( str[
i] <
'0') && (str[
i] >
'9')) {
123 if ((str[
i] !=
'\0') && (str[
i] ==
't') && (str[
i+1] !=
'\0')) {
140 fprintf(
stderr,
"PAPI_library_init failed\n" );
146 for (
i=0;
i<numComponents && cid<0;
i++) {
149 if (aComponent == NULL) {
157 fprintf(
stderr,
"Failed to find component [%s] in total %i supported components.\n",
170 fprintf(
stderr,
"Error on PAPI_create_eventset, retVal %d\n", retVal);
175 for (
int i=0;
i<num_metrics;
i++) {
178 fprintf(
stderr,
"Error on PAPI_add_named_event %s, retVal %d\n",
179 metric_names[
i], retVal);
190#if defined(__cplusplus)
add PAPI preset or native hardware event by name to an EventSet
Create a new empty PAPI EventSet.
get information about a specific software component
initialize the PAPI library.
Get the number of components available on the system.
Finish using PAPI and free all related resources.
int parseInputParam(int argc, char **argv, InParams *param)
void parseMetricList(char *metric_list, InParams *param)
const char * default_metrics[]
int initMetricSet(char **metric_names, int num_metrics, int *eventSet)
Return codes and api definitions.
char name[PAPI_MAX_STR_LEN]