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 : (QUAD_PRECISION ? 1e-29 : 1.0e-10); main_init(&argc, &argv); 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 (verbose >= 0) { /* verbose < 0 disables output */ 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': if (verbose >= 0) 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 (QUAD_PRECISION) ovtpvt("quad\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; }
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; int index; char *short_options = make_short_options(long_options); check_alignment(&tol); report = report_verbose; /* default */ verbose = 0; tol = SINGLE_PRECISION ? 1.0e-3 : 1.0e-10; bench_srand(1); while ((c = getopt_long (argc, argv, short_options, long_options, &index)) != -1) { switch (c) { case 't' : tmin = strtod(optarg, 0); break; case 'r': repeat = atoi(optarg); break; case 's': timer_init(tmin, repeat); speed(optarg); break; case 'd': report_can_do(optarg); break; case 'o': useropt(optarg); break; case 'v': if (optarg) verbose = atoi(optarg); else ++verbose; break; case 'y': verify(optarg, rounds, tol); break; case 'a': accuracy(optarg, arounds, iarounds); break; case 'i': report_info(optarg); break; case 'I': report_info_all(); break; case 'h': usage(argv[0], long_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(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(optarg, 0); break; case 404: /* --random-seed */ bench_srand(atoi(optarg)); break; case 405: /* --accuracy-rounds */ arounds = atoi(optarg); break; case 406: /* --impulse-accuracy-rounds */ iarounds = atoi(optarg); break; case '?': /* `getopt_long' already printed an error message. */ break; default: abort (); } } /* assume that any remaining arguments are problems to be benchmarked */ while (optind < argc) { timer_init(tmin, repeat); speed(argv[optind++]); } cleanup(); bench_free(short_options); return 0; }