Mercurial > hg > sv-dependency-builds
comparison src/fftw-3.3.5/tests/check.pl @ 127:7867fa7e1b6b
Current fftw source
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 18 Oct 2016 13:40:26 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
126:4a7071416412 | 127:7867fa7e1b6b |
---|---|
1 #! /usr/bin/perl -w | |
2 | |
3 $program = "./bench"; | |
4 $default_options = ""; | |
5 $verbose = 0; | |
6 $paranoid = 0; | |
7 $exhaustive = 0; | |
8 $patient = 0; | |
9 $estimate = 0; | |
10 $wisdom = 0; | |
11 $nthreads = 1; | |
12 $rounds = 0; | |
13 $maxsize = 60000; | |
14 $maxcount = 100; | |
15 $do_0d = 0; | |
16 $do_1d = 0; | |
17 $do_2d = 0; | |
18 $do_random = 0; | |
19 $keepgoing = 0; | |
20 $flushcount = 42; | |
21 | |
22 $mpi = 0; | |
23 $mpi_transposed_in = 0; | |
24 $mpi_transposed_out = 0; | |
25 | |
26 sub make_options { | |
27 my $options = $default_options; | |
28 $options = "--verify-rounds=$rounds $options" if $rounds; | |
29 $options = "--verbose=$verbose $options" if $verbose; | |
30 $options = "-o paranoid $options" if $paranoid; | |
31 $options = "-o exhaustive $options" if $exhaustive; | |
32 $options = "-o patient $options" if $patient; | |
33 $options = "-o estimate $options" if $estimate; | |
34 $options = "-o wisdom $options" if $wisdom; | |
35 $options = "-o nthreads=$nthreads $options" if ($nthreads > 1); | |
36 $options = "-obflag=30 $options" if $mpi_transposed_in; | |
37 $options = "-obflag=31 $options" if $mpi_transposed_out; | |
38 return $options; | |
39 } | |
40 | |
41 @list_of_problems = (); | |
42 | |
43 sub flush_problems { | |
44 my $options = shift; | |
45 my $problist = ""; | |
46 | |
47 if ($#list_of_problems >= 0) { | |
48 for (@list_of_problems) { | |
49 $problist = "$problist --verify '$_'"; | |
50 } | |
51 print "Executing \"$program $options $problist\"\n" | |
52 if $verbose; | |
53 | |
54 system("$program $options $problist"); | |
55 $exit_value = $? >> 8; | |
56 $signal_num = $? & 127; | |
57 $dumped_core = $? & 128; | |
58 | |
59 if ($signal_num == 1) { | |
60 print "hangup\n"; | |
61 exit 0; | |
62 } | |
63 if ($signal_num == 2) { | |
64 print "interrupted\n"; | |
65 exit 0; | |
66 } | |
67 if ($signal_num == 9) { | |
68 print "killed\n"; | |
69 exit 0; | |
70 } | |
71 | |
72 if ($exit_value != 0 || $dumped_core || $signal_num) { | |
73 print "FAILED $program: $problist\n"; | |
74 if ($signal_num) { print "received signal $signal_num\n"; } | |
75 exit 1 unless $keepgoing; | |
76 } | |
77 @list_of_problems = (); | |
78 } | |
79 } | |
80 | |
81 sub do_problem { | |
82 my $problem = shift; | |
83 my $doablep = shift; | |
84 my $options = &make_options; | |
85 | |
86 if ($problem =~ /\// && $problem =~ /r/ | |
87 && ($problem =~ /i.*x/ | |
88 || $problem =~ /v/ || $problem =~ /\*/)) { | |
89 return; # cannot do real split inplace-multidimensional or vector | |
90 } | |
91 | |
92 # in --mpi mode, restrict to problems supported by MPI code | |
93 if ($mpi) { | |
94 if ($problem =~ /\//) { return; } # no split | |
95 if ($problem =~ /\*/) { return; } # no non-contiguous vectors | |
96 if ($problem =~ /r/ && $problem !~ /x/) { return; } # no 1d r2c | |
97 if ($problem =~ /k/ && $problem !~ /x/) { return; } # no 1d r2r | |
98 if ($mpi_transposed_in || $problem =~ /\[/) { | |
99 if ($problem !~ /x/) { return; } # no 1d transposed_in | |
100 if ($problem =~ /r/ && $problem !~ /b/) { return; } # only c2r | |
101 } | |
102 if ($mpi_transposed_out || $problem =~ /\]/) { | |
103 if ($problem !~ /x/) { return; } # no 1d transposed_out | |
104 if ($problem =~ /r/ && $problem =~ /b/) { return; } # only r2c | |
105 } | |
106 } | |
107 | |
108 # size-1 redft00 is not defined/doable | |
109 return if ($problem =~ /[^0-9]1e00/); | |
110 | |
111 if ($doablep) { | |
112 @list_of_problems = ($problem, @list_of_problems); | |
113 &flush_problems($options) if ($#list_of_problems > $flushcount); | |
114 } else { | |
115 print "Executing \"$program $options --can-do $problem\"\n" | |
116 if $verbose; | |
117 $result=`$program $options --can-do $problem`; | |
118 if ($result ne "#f\n" && $result ne "#f\r\n") { | |
119 print "FAILED $program: $problem is not undoable\n"; | |
120 exit 1 unless $keepgoing; | |
121 } | |
122 } | |
123 } | |
124 | |
125 # given geometry, try both directions and in place/out of place | |
126 sub do_geometry { | |
127 my $geom = shift; | |
128 my $doablep = shift; | |
129 do_problem("if$geom", $doablep); | |
130 do_problem("of$geom", $doablep); | |
131 do_problem("ib$geom", $doablep); | |
132 do_problem("ob$geom", $doablep); | |
133 do_problem("//if$geom", $doablep); | |
134 do_problem("//of$geom", $doablep); | |
135 do_problem("//ib$geom", $doablep); | |
136 do_problem("//ob$geom", $doablep); | |
137 } | |
138 | |
139 # given size, try all transform kinds (complex, real, etc.) | |
140 sub do_size { | |
141 my $size = shift; | |
142 my $doablep = shift; | |
143 do_geometry("c$size", $doablep); | |
144 do_geometry("r$size", $doablep); | |
145 } | |
146 | |
147 sub small_0d { | |
148 for ($i = 0; $i <= 16; ++$i) { | |
149 for ($j = 0; $j <= 16; ++$j) { | |
150 for ($vl = 1; $vl <= 5; ++$vl) { | |
151 my $ivl = $i * $vl; | |
152 my $jvl = $j * $vl; | |
153 do_problem("o1v${i}:${vl}:${jvl}x${j}:${ivl}:${vl}x${vl}:1:1", 1); | |
154 do_problem("i1v${i}:${vl}:${jvl}x${j}:${ivl}:${vl}x${vl}:1:1", 1); | |
155 do_problem("ok1v${i}:${vl}:${jvl}x${j}:${ivl}:${vl}x${vl}:1:1", 1); | |
156 do_problem("ik1v${i}:${vl}:${jvl}x${j}:${ivl}:${vl}x${vl}:1:1", 1); | |
157 } | |
158 } | |
159 } | |
160 } | |
161 | |
162 sub small_1d { | |
163 do_size (0, 0); | |
164 for ($i = 1; $i <= 100; ++$i) { | |
165 do_size ($i, 1); | |
166 } | |
167 do_size (128, 1); | |
168 do_size (256, 1); | |
169 do_size (512, 1); | |
170 do_size (1024, 1); | |
171 do_size (2048, 1); | |
172 do_size (4096, 1); | |
173 } | |
174 | |
175 sub small_2d { | |
176 do_size ("0x0", 0); | |
177 for ($i = 1; $i <= 100; ++$i) { | |
178 my $ub = 900/$i; | |
179 $ub = 100 if $ub > 100; | |
180 for ($j = 1; $j <= $ub; ++$j) { | |
181 do_size ("${i}x${j}", 1); | |
182 } | |
183 } | |
184 } | |
185 | |
186 sub rand_small_factors { | |
187 my $l = shift; | |
188 my $n = 1; | |
189 my $maxfactor = 13; | |
190 my $f = int(rand($maxfactor) + 1); | |
191 while ($n * $f < $l) { | |
192 $n *= $f; | |
193 $f = int(rand($maxfactor) + 1); | |
194 }; | |
195 return $n; | |
196 } | |
197 | |
198 # way too complicated... | |
199 sub one_random_test { | |
200 my $q = int(2 + rand($maxsize)); | |
201 my $rnk = int(1 + rand(4)); | |
202 my $vtype = int(rand(3)); | |
203 my $g = int(2 + exp(log($q) / ($rnk + ($vtype > 0)))); | |
204 my $first = 1; | |
205 my $sz = ""; | |
206 my $is_r2r = shift; | |
207 my @r2r_kinds = ("f", "b", "h", | |
208 "e00", "e01", "e10", "e11", "o00", "o01", "o10", "o11"); | |
209 | |
210 while ($q > 1 && $rnk > 0) { | |
211 my $r = rand_small_factors(int(rand($g) + 10)); | |
212 if ($r > 1) { | |
213 $sz = "${sz}x" if (!$first); | |
214 $first = 0; | |
215 $sz = "${sz}${r}"; | |
216 if ($is_r2r) { | |
217 my $k = $r2r_kinds[int(1 + rand($#r2r_kinds))]; | |
218 $sz = "${sz}${k}"; | |
219 } | |
220 $q = int($q / $r); | |
221 if ($g > $q) { $g = $q; } | |
222 --$rnk; | |
223 } | |
224 } | |
225 if ($vtype > 0 && $g > 1) { | |
226 my $v = int(1 + rand($g)); | |
227 $sz = "${sz}*${v}" if ($vtype == 1); | |
228 $sz = "${sz}v${v}" if ($vtype == 2); | |
229 } | |
230 if ($mpi) { | |
231 my $stype = int(rand(3)); | |
232 $sz = "]${sz}" if ($stype == 1); | |
233 $sz = "[${sz}" if ($stype == 2); | |
234 } | |
235 $sz = "d$sz" if (int(rand(3)) == 0); | |
236 if ($is_r2r) { | |
237 do_problem("ik$sz", 1); | |
238 do_problem("ok$sz", 1); | |
239 } | |
240 else { | |
241 do_size($sz, 1); | |
242 } | |
243 } | |
244 | |
245 sub random_tests { | |
246 my $i; | |
247 for ($i = 0; $i < $maxcount; ++$i) { | |
248 &one_random_test(0); | |
249 &one_random_test(1); | |
250 } | |
251 } | |
252 | |
253 sub parse_arguments (@) | |
254 { | |
255 local (@arglist) = @_; | |
256 | |
257 while (@arglist) | |
258 { | |
259 if ($arglist[0] eq '-v') { ++$verbose; } | |
260 elsif ($arglist[0] eq '--verbose') { ++$verbose; } | |
261 elsif ($arglist[0] eq '-p') { ++$paranoid; } | |
262 elsif ($arglist[0] eq '--paranoid') { ++$paranoid; } | |
263 elsif ($arglist[0] eq '--exhaustive') { ++$exhaustive; } | |
264 elsif ($arglist[0] eq '--patient') { ++$patient; } | |
265 elsif ($arglist[0] eq '--estimate') { ++$estimate; } | |
266 elsif ($arglist[0] eq '--wisdom') { ++$wisdom; } | |
267 elsif ($arglist[0] =~ /^--nthreads=(.+)$/) { $nthreads = $1; } | |
268 elsif ($arglist[0] eq '-k') { ++$keepgoing; } | |
269 elsif ($arglist[0] eq '--keep-going') { ++$keepgoing; } | |
270 elsif ($arglist[0] =~ /^--verify-rounds=(.+)$/) { $rounds = $1; } | |
271 elsif ($arglist[0] =~ /^--count=(.+)$/) { $maxcount = $1; } | |
272 elsif ($arglist[0] =~ /^-c=(.+)$/) { $maxcount = $1; } | |
273 elsif ($arglist[0] =~ /^--flushcount=(.+)$/) { $flushcount = $1; } | |
274 elsif ($arglist[0] =~ /^--maxsize=(.+)$/) { $maxsize = $1; } | |
275 | |
276 elsif ($arglist[0] eq '--mpi') { ++$mpi; } | |
277 elsif ($arglist[0] eq '--mpi-transposed-in') { | |
278 ++$mpi; ++$mpi_transposed_in; } | |
279 elsif ($arglist[0] eq '--mpi-transposed-out') { | |
280 ++$mpi; ++$mpi_transposed_out; } | |
281 | |
282 elsif ($arglist[0] eq '-0d') { ++$do_0d; } | |
283 elsif ($arglist[0] eq '-1d') { ++$do_1d; } | |
284 elsif ($arglist[0] eq '-2d') { ++$do_2d; } | |
285 elsif ($arglist[0] eq '-r') { ++$do_random; } | |
286 elsif ($arglist[0] eq '--random') { ++$do_random; } | |
287 elsif ($arglist[0] eq '-a') { | |
288 ++$do_0d; ++$do_1d; ++$do_2d; ++$do_random; | |
289 } | |
290 | |
291 else { $program=$arglist[0]; } | |
292 shift (@arglist); | |
293 } | |
294 } | |
295 | |
296 # MAIN PROGRAM: | |
297 | |
298 &parse_arguments (@ARGV); | |
299 | |
300 &random_tests if $do_random; | |
301 &small_0d if $do_0d; | |
302 &small_1d if $do_1d; | |
303 &small_2d if $do_2d; | |
304 | |
305 { | |
306 my $options = &make_options; | |
307 &flush_problems($options); | |
308 } |