59 {
60
61 (void)argc;
62 (void)argv;
63
65 int cid = -1;
66 int numMetrics = 0;
67 int numGroups = 0;
68 int selectedAll = 1;
69 int listGroupOnly = 0;
70 char *metricName = NULL;
71 char *metricGroupName = NULL;
74 char ch;
75
76 while ((ch=getopt(argc, argv, "ahm:g:")) != -1) {
77 switch(ch) {
78 case 'a':
79 listGroupOnly = 1;
80 if (metricGroupName) {
81 printf("list all groups, ignore group name\n");
82 metricGroupName = NULL;
83 }
84 break;
85 case 'h':
86 printf("usage: %s [-a] [-g <metricGroupName>] [-m <metricName>]\n", argv[0]);
87 return 0;
88 case 'm':
89 metricName = optarg;
90 selectedAll = 0;
91 break;
92 case 'g':
93 if (!listGroupOnly) {
94 metricGroupName = optarg;
95 } else {
96 printf("list all groups, ignore group name\n");
97 }
98 break;
99 default:
100 break;
101 }
102 }
103
105
108 fprintf(
stderr,
"PAPI_library_init failed\n" );
109 exit(-1);
110 }
111
113 for (
i=0;
i<numComps;
i++) {
117 break;
118 }
119 }
121 printf(
"Component %s is not supported\n", aComp->
name);
122 return 1;
123 }
124
125 printf(
"Name: %s\n", aComp->
name);
127
128 if (selectedAll || listGroupOnly) {
131 numMetrics = 0;
132 do {
133 memset( &info, 0, sizeof ( info ) );
136 if (listGroupOnly) {
137 if (!metricGroupName || !strstr(info.
symbol, metricGroupName)) {
138 char *pt = index(info.
symbol,
'.');
139 if (pt) {
140 *pt = '\0';
141 }
142 if (metricGroupName) {
143 free(metricGroupName);
144 }
145 metricGroupName = strdup(info.
symbol);
146 printf("%s\n", metricGroupName);
147 numGroups++;
148 }
149 }
else if ((!metricGroupName) || strstr(info.
symbol, metricGroupName)) {
151 numMetrics++;
152 }
153 }
156
158 if (!numMetrics && !numGroups) {
159 fprintf(
stderr,
"Error on enum_cmp_event, abort.\n");
161 }
162 if (listGroupOnly) {
163 printf("Total %d metric groups are supported\n", numGroups);
164 } else {
165 printf("Total %d metrics are supported\n", numMetrics);
166 }
168 return retVal;
169 }
170
171 if (!metricName) {
173 }
174 printf("Query metric by name %s -- ", metricName);
175
178 printf("does not exist, abort.\n");
180 return retVal;
181 } else {
182 printf("is supported.\n");
183 }
184
185 int code = 0;
188 printf("PAPI_event_name_to_code event %s dose not exist, abort.\n", metricName);
190 return retVal;
191 }
192 printf("Named metric %s is enumerated with code 0x%x.\n", metricName, code);
193 printf("Query metric by code 0x%x -- ", code);
196 printf("dose not exist, abort.\n");
198 return retVal;
199 } else {
200 printf("is supported.\n");
201 }
202
204 return 0;
205}
Enumerate PAPI preset or native events for a given component.
Convert a name to a numeric hardware event code.
get information about a specific software component
Get the event's name and description info.
initialize the PAPI library.
Get the number of components available on the system.
Query if PAPI event exists.
Query if a named PAPI event exists.
Finish using PAPI and free all related resources.
char description[PAPI_MAX_STR_LEN]
char name[PAPI_MAX_STR_LEN]
char symbol[PAPI_HUGE_STR_LEN]
char long_descr[PAPI_HUGE_STR_LEN]