25{
26
27 int retval,cid,host_micpower_cid=-1,numcmp;
30 int i,code,enum_retval;
33 double elapsed_time,total_time;
34 double energy = 0.0;
36
37
40 fprintf(
stderr,
"PAPI_library_init failed\n");
41 exit(1);
42 }
43
45
46 for(cid=0; cid<numcmp; cid++) {
47
49 fprintf(
stderr,
"PAPI_get_component_info failed\n");
50 exit(1);
51 }
52
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);
56
58 fprintf(
stderr,
"No host_micpower events found: %s\n",
60 exit(1);
61 }
62 break;
63 }
64 }
65
66
67 if (cid==numcmp) {
68 fprintf(
stderr,
"No host_micpower component found\n");
69 exit(1);
70 }
71
72
74
76
77 while ( enum_retval ==
PAPI_OK ) {
78
81 printf("Error translating %#x\n",code);
82 exit(1);
83 }
84
89
92 exit(1);
93 }
94
96
97 }
98
100 printf("Error! No host_micpower events found!\n");
101 exit(1);
102 }
103
104
109 exit(1);
110 }
111 }
112
113
114
117 fprintf(
stderr,
"Error creating eventset!\n");
118 }
119
121
125 }
126 }
127
128
129
131
132 while(1) {
133
134
138 fprintf(
stderr,
"PAPI_start() failed\n");
139 exit(1);
140 }
141
142
143 usleep(100000);
144
145
149 fprintf(
stderr,
"PAPI_start() failed\n");
150 }
151
152 total_time=((double)(
after_time-start_time))/1.0e9;
154
156 if( (strstr(
events[
i],
"vccp") != NULL) ||
157 (strstr(
events[
i],
"vddg") != NULL) ||
158 (strstr(
events[
i],
"vddq") != NULL) ) {
159
160 fprintf(
fff[
i],
"%.4f %.1f (* Average Voltage (Volt) for %s *)\n",
161 total_time,
164 } else {
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",
168 total_time,
170 energy/1.0e3,
172 } else {
173 fprintf(
fff[
i],
"%.4f %.1f (* Average Power (Watt) for %s *)\n",
174 total_time,
177 }
178 }
180 }
181 }
182
183 return 0;
184}
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]
static long long after_time
static long long before_time
char name[PAPI_MAX_STR_LEN]
char disabled_reason[PAPI_HUGE_STR_LEN]