comparison src/fftw-3.3.5/libbench2/bench-main.c @ 42:2cd0e3b3e1fd

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