12#define MAX_DEVICES (32)
13#define EVENTS_PER_DEVICE 10
15#define MAX_EVENTS (MAX_DEVICES*EVENTS_PER_DEVICE)
24int main (
int argc,
char **argv)
27 int retval,cid,host_micpower_cid=-1,numcmp;
30 int i,code,enum_retval;
33 double elapsed_time,total_time;
40 fprintf(
stderr,
"PAPI_library_init failed\n");
46 for(cid=0; cid<numcmp; cid++) {
49 fprintf(
stderr,
"PAPI_get_component_info failed\n");
53 if (strstr(cmpinfo->
name,
"host_micpower")) {
54 host_micpower_cid=cid;
55 printf(
"Found host_micpower component at cid %d\n", host_micpower_cid);
58 fprintf(
stderr,
"No host_micpower events found: %s\n",
68 fprintf(
stderr,
"No host_micpower component found\n");
77 while ( enum_retval ==
PAPI_OK ) {
81 printf(
"Error translating %#x\n",code);
100 printf(
"Error! No host_micpower events found!\n");
117 fprintf(
stderr,
"Error creating eventset!\n");
138 fprintf(
stderr,
"PAPI_start() failed\n");
149 fprintf(
stderr,
"PAPI_start() failed\n");
152 total_time=((double)(
after_time-start_time))/1.0e9;
156 if( (strstr(
events[
i],
"vccp") != NULL) ||
157 (strstr(
events[
i],
"vddg") != NULL) ||
158 (strstr(
events[
i],
"vddq") != NULL) ) {
160 fprintf(
fff[
i],
"%.4f %.1f (* Average Voltage (Volt) for %s *)\n",
165 if( strstr(
events[
i],
"tot0") != NULL ){
166 energy += elapsed_time*((double)
values[
i]/1.0e6);
167 fprintf(
fff[
i],
"%.4f %.1f %.1f (* Average Power (Watt) and Energy consumption (kWs) for %s *)\n",
173 fprintf(
fff[
i],
"%.4f %.1f (* Average Power (Watt) for %s *)\n",
add PAPI preset or native hardware event by name to an EventSet
Create a new empty PAPI EventSet.
Enumerate PAPI preset or native events for a given component.
Convert a numeric hardware event code to a name.
get information about a specific software component
Get real time counter value in nanoseconds.
initialize the PAPI library.
Get the number of components available on the system.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
char event_name[2][PAPI_MAX_STR_LEN]
char events[MAX_EVENTS][BUFSIZ]
char filenames[MAX_EVENTS][BUFSIZ]
static long long values[NUM_EVENTS]
Return codes and api definitions.
static long long after_time
static long long before_time
char name[PAPI_MAX_STR_LEN]
char disabled_reason[PAPI_HUGE_STR_LEN]