1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
|
/*
* Copyright (c) 2001 Matteo Frigo
* Copyright (c) 2001 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/* $Id: bench-main.c,v 1.19 2006-02-25 04:13:49 stevenj Exp $ */
#include "bench.h"
#include "my-getopt.h"
#include <stdio.h>
#include <stdlib.h>
int verbose;
static const struct my_option options[] =
{
{"accuracy", REQARG, 'a'},
{"accuracy-rounds", REQARG, 405},
{"impulse-accuracy-rounds", REQARG, 406},
{"can-do", REQARG, 'd'},
{"help", NOARG, 'h'},
{"info", REQARG, 'i'},
{"info-all", NOARG, 'I'},
{"print-precision", NOARG, 402},
{"print-time-min", NOARG, 400},
{"random-seed", REQARG, 404},
{"report-benchmark", NOARG, 320},
{"report-mflops", NOARG, 300},
{"report-time", NOARG, 310},
{"report-verbose", NOARG, 330},
{"speed", REQARG, 's'},
{"setup-speed", REQARG, 'S'},
{"time-min", REQARG, 't'},
{"time-repeat", REQARG, 'r'},
{"user-option", REQARG, 'o'},
{"verbose", OPTARG, 'v'},
{"verify", REQARG, 'y'},
{"verify-rounds", REQARG, 401},
{"verify-tolerance", REQARG, 403},
{0, NOARG, 0}
};
int bench_main(int argc, char *argv[])
{
double tmin = 0.0;
double tol;
int repeat = 0;
int rounds = 10;
int iarounds = 0;
int arounds = 1; /* this is too low for precise results */
int c;
report = report_verbose; /* default */
verbose = 0;
tol = SINGLE_PRECISION ? 1.0e-3 : 1.0e-10;
bench_srand(1);
while ((c = my_getopt (argc, argv, options)) != -1) {
switch (c) {
case 't' :
tmin = strtod(my_optarg, 0);
break;
case 'r':
repeat = atoi(my_optarg);
break;
case 's':
timer_init(tmin, repeat);
speed(my_optarg, 0);
break;
case 'S':
timer_init(tmin, repeat);
speed(my_optarg, 1);
break;
case 'd':
report_can_do(my_optarg);
break;
case 'o':
useropt(my_optarg);
break;
case 'v':
if (my_optarg)
verbose = atoi(my_optarg);
else
++verbose;
break;
case 'y':
verify(my_optarg, rounds, tol);
break;
case 'a':
accuracy(my_optarg, arounds, iarounds);
break;
case 'i':
report_info(my_optarg);
break;
case 'I':
report_info_all();
break;
case 'h':
my_usage(argv[0], options);
break;
case 300: /* --report-mflops */
report = report_mflops;
break;
case 310: /* --report-time */
report = report_time;
break;
case 320: /* --report-benchmark */
report = report_benchmark;
break;
case 330: /* --report-verbose */
report = report_verbose;
break;
case 400: /* --print-time-min */
timer_init(tmin, repeat);
ovtpvt("%g\n", time_min);
break;
case 401: /* --verify-rounds */
rounds = atoi(my_optarg);
break;
case 402: /* --print-precision */
if (SINGLE_PRECISION)
ovtpvt("single\n");
else if (LDOUBLE_PRECISION)
ovtpvt("long-double\n");
else if (DOUBLE_PRECISION)
ovtpvt("double\n");
else
ovtpvt("unknown %d\n", sizeof(bench_real));
break;
case 403: /* --verify-tolerance */
tol = strtod(my_optarg, 0);
break;
case 404: /* --random-seed */
bench_srand(atoi(my_optarg));
break;
case 405: /* --accuracy-rounds */
arounds = atoi(my_optarg);
break;
case 406: /* --impulse-accuracy-rounds */
iarounds = atoi(my_optarg);
break;
case '?':
/* my_getopt() already printed an error message. */
cleanup();
return 1;
default:
abort ();
}
}
/* assume that any remaining arguments are problems to be
benchmarked */
while (my_optind < argc) {
timer_init(tmin, repeat);
speed(argv[my_optind++], 0);
}
cleanup();
return 0;
}
|