87 printf(
"This is the PAPI cost program.\n" );
88 printf(
"It computes min / max / mean / std. deviation for PAPI start/stop pairs; for PAPI reads, and for PAPI_accums. Usage:\n\n" );
89 printf(
" cost [options] [parameters]\n" );
90 printf(
" cost TESTS_QUIET\n\n" );
91 printf(
"Options:\n\n" );
92 printf(
" -b BINS set the number of bins for the graphical distribution of costs. Default: 100\n" );
93 printf(
" -d show a graphical distribution of costs\n" );
94 printf(
" -h print this help message\n" );
95 printf(
" -p print 25/50/75th percentile results for making boxplots\n");
96 printf(
" -s show number of iterations above the first 10 std deviations\n" );
97 printf(
" -t THRESHOLD set the threshold for the number of iterations. Default: 1,000,000\n" );
107 "PAPI_start/stop (2 counters)",
108 "PAPI_read (2 counters)",
109 "PAPI_read_ts (2 counters)",
110 "PAPI_accum (2 counters)",
111 "PAPI_reset (2 counters)",
112 "PAPI_read (1 derived_postfix counter)",
113 "PAPI_read (1 derived_[add|sub] counter)"
116 printf(
"\nTotal cost for %s over %d iterations\n",
118 printf(
"min cycles : %lld\nmax cycles : %lld\n"
119 "mean cycles : %lf\nstd deviation: %lf\n",
120 min, max, average, std );
129 printf(
" --------# Standard Deviations Above the Mean--------\n" );
130 printf(
"0-------1-------2-------3-------4-------5-------6-------7-------8-------9-----10\n" );
131 for (
i = 0;
i < 10;
i++ )
132 printf(
" %d\t",
s[
i] );
140 int step = (
int ) ( max -
min ) / bins;
142 printf(
"\nCost distribution profile\n\n" );
143 for (
i = 0;
i < bins;
i++ ) {
144 printf(
"%8d:", (
int )
min + ( step *
i ) );
146 printf(
"**************************** %d counts ****************************",
149 for ( j = 0; j < d[
i]; j++ )
158 long long percent75,
long long percent99)
160 printf(
"25%% cycles : %lld\n50%% cycles : %lld\n"
161 "75%% cycles : %lld\n99%% cycles : %lld\n",
162 percent25,percent50,percent75,percent99);
167 int show_dist,
int show_percentile )
172 long long percent25,percent50,percent75,percent99;
177 if (show_percentile) {
182 if ( show_std_dev ) {
189 d = calloc( bins ,
sizeof (
int ) );
201 int retval_start,retval_stop;
203 int show_dist = 0, show_std_dev = 0, show_percent = 0;
204 long long totcyc,
values[2];
212 while ( (
c=getopt(argc, argv,
"hb:dpst:") ) != -1) {
242 printf(
"Cost of execution for PAPI start/stop, read and accum.\n" );
243 printf(
"This test takes a while. Please be patient...\n" );
247 fprintf(
stderr,
"PAPI_library_init\n");
252 fprintf(
stderr,
"PAPI_set_debug\n");
257 fprintf(
stderr,
"PAPI_query_event\n");
262 fprintf(
stderr,
"PAPI_query_event\n");
267 fprintf(
stderr,
"PAPI_create_eventset\n");
272 fprintf(
stderr,
"PAPI_add_event\n");
279 fprintf(
stderr,
"PAPI_add_event\n");
288 fprintf(
stderr,
"PAPI_start");
292 fprintf(
stderr,
"PAPI_stop");
297 if (
array == NULL ) {
298 fprintf(
stderr,
"Error allocating memory for results\n");
304 printf(
"\nPerforming loop latency test...\n" );
312 do_output( 0,
array, bins, show_std_dev, show_dist, show_percent );
316 printf(
"\nPerforming start/stop test...\n" );
324 if (retval_start || retval_stop) {
325 fprintf(
stderr,
"PAPI start/stop\n");
330 do_output( 1,
array, bins, show_std_dev, show_dist, show_percent );
333 printf(
"\nPerforming read test...\n" );
336 fprintf(
stderr,
"PAPI_start");
348 fprintf(
stderr,
"PAPI_stop");
352 do_output( 2,
array, bins, show_std_dev, show_dist, show_percent );
355 printf(
"\nPerforming read with timestamp test...\n" );
358 fprintf(
stderr,
"PAPI_start");
367 fprintf(
stderr,
"PAPI_stop");
377 do_output( 3,
array, bins, show_std_dev, show_dist, show_percent );
380 printf(
"\nPerforming accum test...\n" );
383 fprintf(
stderr,
"PAPI_start");
395 fprintf(
stderr,
"PAPI_stop");
399 do_output( 4,
array, bins, show_std_dev, show_dist, show_percent );
402 printf(
"\nPerforming reset test...\n" );
405 fprintf(
stderr,
"PAPI_start");
416 fprintf(
stderr,
"PAPI_stop");
420 do_output( 5,
array, bins, show_std_dev, show_dist, show_percent );
431 printf(
"\nPerforming DERIVED_POSTFIX "
432 "PAPI_read(%d counters) test (%s)...",
437 fprintf(
stderr,
"PAPI_add_event");
443 fprintf(
stderr,
"PAPI_start");
458 fprintf(
stderr,
"PAPI_stop");
462 do_output( 6,
array, bins, show_std_dev, show_dist, show_percent );
465 printf(
"\tI was unable to find a DERIVED_POSTFIX preset event "
466 "to test on this architecture, skipping.\n");
478 printf(
"\nPerforming DERIVED_[ADD|SUB] "
479 "PAPI_read(%d counters) test (%s)...",
484 fprintf(
stderr,
"PAPI_add_event\n");
490 fprintf(
stderr,
"PAPI_start");
505 fprintf(
stderr,
"PAPI_stop");
509 do_output( 7,
array, bins, show_std_dev, show_dist, show_percent );
511 printf(
"\tI was unable to find a suitable DERIVED_[ADD|SUB] "
512 "event to test, skipping.\n");
Accumulate and reset counters in an EventSet.
add PAPI preset or native hardware event to an event set
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Enumerate PAPI preset or native events.
Get the event's name and description info.
get real time counter value in clock cycles Returns the total real time passed since some arbitrary s...
initialize the PAPI library.
Query if PAPI event exists.
Read hardware counters with a timestamp.
Read hardware counters from an event set.
Reset the hardware event counts in an event set.
Set the current debug level for error output from PAPI.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
double do_stats(long long *array, long long *min, long long *max, double *average)
void do_std_dev(long long *a, int *s, double std, double ave)
void do_dist(long long *a, long long min, long long max, int bins, int *d)
int do_percentile(long long *a, long long *percent25, long long *percent50, long long *percent75, long long *percent99)
static long long values[NUM_EVENTS]
static double c[MATRIX_SIZE][MATRIX_SIZE]
Return codes and api definitions.
static void print_percentile(long long percent25, long long percent50, long long percent75, long long percent99)
static void print_dist(long long min, long long max, int bins, int *d)
static int find_derived(int i, char *type)
static int find_derived_add(int i)
static void print_std_dev(int *s)
static void do_output(int test_type, long long *array, int bins, int show_std_dev, int show_dist, int show_percentile)
static void print_stats(int i, long long min, long long max, double average, double std)
static int find_derived_postfix(int i)
static void print_help(void)
static double array[ARRAYSIZE]
char symbol[PAPI_HUGE_STR_LEN]
char derived[PAPI_MIN_STR_LEN]