73{
74 (void) argv;
75 (void) argc;
76 int retval,cid,powercap_cid=-1,numcmp;
80 int code;
86
90 double elapsed_time;
91
92
94
95
96#if 0
97 int do_wrap = 0;
98 if ( argc > 1 ) {
99 if ( strstr( argv[1], "-w" ) ) {
100 do_wrap = 1;
101 }
102 }
103#endif
104
105
109
110 if ( !
TESTS_QUIET ) printf(
"Trying all powercap events\n" );
111
113
114 for( cid=0; cid<numcmp; cid++ ) {
115
117 test_fail( __FILE__, __LINE__,
"PAPI_get_component_info failed\n", 0 );
118
119 if ( strstr( cmpinfo->
name,
"powercap" ) ) {
120 powercap_cid=cid;
121 if ( !
TESTS_QUIET ) printf(
"Found powercap component at cid %d\n",powercap_cid );
124 printf( "powercap component disabled: %s\n",
126 }
127 test_skip( __FILE__,__LINE__,
"powercap component disabled",0 );
128 }
129 break;
130 }
131 }
132
133
134 if ( cid==numcmp )
135 test_skip( __FILE__,__LINE__,
"No powercap component found\n",0 );
136
137
139 test_skip( __FILE__,__LINE__,
"No counters in the powercap component\n",0 );
140
141
145
146
152 test_fail( __FILE__, __LINE__,
"Error from PAPI_event_code_to_name",
retval );
153
157
160
164
166 break;
168
170 }
171
175
176 if ( !
TESTS_QUIET ) printf(
"\nStarting measurements...\n\n" );
177
178
183
184
186
187
192
194
196 printf( "\nStopping measurements, took %.3fs, gathering results...\n\n", elapsed_time );
197
198 printf( "\n" );
199 printf( "scaled energy measurements:\n" );
203 printf( "%-45s%-20s%4.6f J (Average Power %.1fW)\n",
206 ( (
double )
values[
i]/1.0e6 )/elapsed_time );
207 }
208 }
209 }
210
211 printf( "\n" );
212 printf( "energy counts:\n" );
219 }
220 }
221 }
222
223 printf( "\n" );
224 printf( "long term time window values:\n" );
228 printf( "%-45s%-20s%4f (secs)\n",
231 }
232 }
233 }
234
235 printf( "\n" );
236 printf( "short term time window values:\n" );
240 printf( "%-45s%-20s%4f (secs)\n",
243 }
244 }
245 }
246
247 printf( "\n" );
248 printf( "long term power limit:\n" );
252 printf( "%-45s%-20s%4f (watts)\n",
255 }
256 }
257 }
258
259 printf( "\n" );
260 printf( "short term power limit:\n" );
264 printf( "%-45s%-20s%4f (watts)\n",
267 }
268 }
269 }
270
271 }
272
273
275
279
283
285
286 return 0;
287}
static const char * event_names[2]
add PAPI preset or native hardware event to an event set
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Empty and destroy an 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 the event's name and description info.
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.
#define PAPI_DATATYPE_UINT64
#define PAPI_HUGE_STR_LEN
static long long values[NUM_EVENTS]
int tests_quiet(int argc, char **argv)
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
void PAPI_NORETURN test_pass(const char *filename)
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
int data_type[MAX_EVENTS]
char units[MAX_EVENTS][BUFSIZ]
static long long after_time
static long long before_time
char name[PAPI_MAX_STR_LEN]
char disabled_reason[PAPI_HUGE_STR_LEN]
char units[PAPI_MIN_STR_LEN]
char long_descr[PAPI_HUGE_STR_LEN]
#define MAX_powercap_EVENTS
Tests basic functionality of powercap component.