54 if ( strcmp( info.
derived, type) == 0 ) {
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");
296 array = (
long long * ) malloc( (
size_t )
num_iters *
sizeof (
long long ) );
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");
int PAPI_stop(int EventSet, long long *values)
static int find_derived_add(int i)
int PAPI_add_event(int EventSet, int EventCode)
int PAPI_reset(int EventSet)
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_help(void)
static double array[ARRAYSIZE]
int PAPI_enum_event(int *EventCode, int modifier)
char derived[PAPI_MIN_STR_LEN]
static int find_derived_postfix(int i)
Return codes and api definitions.
static void print_dist(long long min, long long max, int bins, int *d)
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
double do_stats(long long *array, long long *min, long long *max, double *average)
static int find_derived(int i, char *type)
int PAPI_accum(int EventSet, long long *values)
int PAPI_library_init(int version)
static void print_percentile(long long percent25, long long percent50, long long percent75, long long percent99)
char symbol[PAPI_HUGE_STR_LEN]
static void print_std_dev(int *s)
static void print_stats(int i, long long min, long long max, double average, double std)
int PAPI_cleanup_eventset(int EventSet)
int PAPI_create_eventset(int *EventSet)
void do_dist(long long *a, long long min, long long max, int bins, int *d)
int main(int argc, char **argv)
int PAPI_query_event(int EventCode)
int PAPI_read_ts(int EventSet, long long *values, long long *cycles)
void do_std_dev(long long *a, int *s, double std, double ave)
long long PAPI_get_real_cyc(void)
int PAPI_read(int EventSet, long long *values)
int PAPI_start(int EventSet)
static long long values[NUM_EVENTS]
int PAPI_set_debug(int level)
int do_percentile(long long *a, long long *percent25, long long *percent50, long long *percent75, long long *percent99)