|
3 | 3 | # Copyright (c) 2012 Los Alamos National Security, Inc. |
4 | 4 | # All rights reserved. |
5 | 5 | # Copyright (c) 2015-2016 Intel, Inc. All rights reserved. |
| 6 | +# Copyright (c) 2017-2018 The University of Tennessee and The University |
| 7 | +# of Tennessee Research Foundation. All rights |
| 8 | +# reserved. |
| 9 | + |
6 | 10 |
|
7 | 11 | use strict; |
8 | 12 | use Getopt::Long; |
|
21 | 25 | my $rawoutput = 0; |
22 | 26 | my $myresults = "myresults"; |
23 | 27 | my $ppn = 1; |
| 28 | +my $npmin = 1; |
24 | 29 | my @csvrow; |
25 | 30 |
|
26 | 31 | my @tests = qw(/bin/true ./orte_no_op ./mpi_no_op ./mpi_no_op ./mpi_no_op); |
27 | 32 | my @options = ("", "", "", "-mca mpi_add_procs_cutoff 0 -mca pmix_base_async_modex 1", "-mca mpi_add_procs_cutoff 0 -mca pmix_base_async_modex 1 -mca async_mpi_init 1 -mca async_mpi_finalize 1"); |
28 | 33 | my @starterlist = qw(mpirun prun srun aprun); |
29 | 34 | my @starteroptionlist = ("--novm", |
30 | 35 | "", |
31 | | - "--distribution=cyclic -N", |
32 | | - "-N"); |
| 36 | + "--distribution=cyclic", |
| 37 | + ""); |
33 | 38 |
|
34 | 39 | # Set to true if the script should merely print the cmds |
35 | 40 | # it would run, but don't run them |
|
52 | 57 | "results=s" => \$myresults, |
53 | 58 | "rawout" => \$rawoutput, |
54 | 59 | "ppn=s" => \$ppn, |
| 60 | + "npmin=s" => \$npmin, |
55 | 61 | ) or die "unable to parse options, stopped"; |
56 | 62 |
|
57 | 63 | if ($HELP) { |
|
69 | 75 | --results=file File where results are to be stored in comma-separated value format |
70 | 76 | --rawout Provide raw timing output to the file |
71 | 77 | --ppn=n Run n procs/node |
| 78 | +--npmin=n Minimal number of nodes |
72 | 79 | "; |
73 | 80 | exit(0); |
74 | 81 | } |
|
126 | 133 | push @starteroptions, $opt; |
127 | 134 | } elsif ($useaprun && $starter eq "aprun") { |
128 | 135 | push @starters, $starter; |
129 | | - $opt = $starteroptionlist[$idx] . " " . $ppn; |
| 136 | + $opt = $starteroptionlist[$idx] . " -N " . $ppn; |
130 | 137 | push @starteroptions, $opt; |
131 | 138 | } elsif ($usesrun && $starter eq "srun") { |
132 | 139 | push @starters, $starter; |
133 | | - $opt = $starteroptionlist[$idx] . " " . $ppn; |
| 140 | + $opt = $starteroptionlist[$idx] . " --ntasks-per-node " . $ppn; |
134 | 141 | push @starteroptions, $opt; |
135 | 142 | } |
136 | 143 | } |
|
184 | 191 |
|
185 | 192 | sub runcmd() |
186 | 193 | { |
| 194 | + my $rc; |
187 | 195 | for (1..$reps) { |
188 | 196 | $output = `$cmd`; |
| 197 | + # Check the error code of the command; if the error code is alright |
| 198 | + # just add a 0 in front of the number to neutraly mark the success; |
| 199 | + # If the code is not correct, add a ! in front of the number to mark |
| 200 | + # it invalid. |
| 201 | + if($? != 0) { |
| 202 | + $rc = "0"; |
| 203 | + } |
| 204 | + else { |
| 205 | + $rc = "!"; |
| 206 | + } |
189 | 207 | if ($myresults && $rawoutput) { |
190 | | - print FILE $n . " " . $output . "\n"; |
| 208 | + print FILE $n . " " . $output . " $rc\n"; |
191 | 209 | } |
192 | 210 | @lines = split(/\n/, $output); |
193 | 211 | foreach $line (@lines) { |
|
209 | 227 | if (0 == $strloc) { |
210 | 228 | if (0 == $idx) { |
211 | 229 | # it must be in the next location |
212 | | - push @csvrow,$results[1]; |
| 230 | + push @csvrow,join $rc,$results[1]; |
213 | 231 | } else { |
214 | 232 | # it must be in the prior location |
215 | | - push @csvrow,$results[$idx-1]; |
| 233 | + push @csvrow,join $rc,$results[$idx-1]; |
216 | 234 | } |
217 | 235 | } else { |
218 | 236 | # take the portion of the string up to the tag |
219 | | - push @csvrow,substr($res, 0, $strloc); |
| 237 | + push @csvrow,join $rc,substr($res, 0, $strloc); |
220 | 238 | } |
221 | 239 | } else { |
222 | 240 | $strloc = index($res, "elapsed"); |
|
227 | 245 | if (0 == $strloc) { |
228 | 246 | if (0 == $idx) { |
229 | 247 | # it must be in the next location |
230 | | - push @csvrow,$results[1]; |
| 248 | + push @csvrow,join $rc,$results[1]; |
231 | 249 | } else { |
232 | 250 | # it must be in the prior location |
233 | | - push @csvrow,$results[$idx-1]; |
| 251 | + push @csvrow,join $rc,$results[$idx-1]; |
234 | 252 | } |
235 | 253 | } else { |
236 | 254 | # take the portion of the string up to the tag |
237 | | - push @csvrow,substr($res, 0, $strloc); |
| 255 | + push @csvrow,join $rc,substr($res, 0, $strloc); |
238 | 256 | } |
239 | 257 | } |
240 | 258 | } |
|
263 | 281 | } |
264 | 282 |
|
265 | 283 | foreach $starter (@starters) { |
| 284 | + my $dvmout; |
266 | 285 | print "STARTER: $starter\n"; |
267 | 286 | # if we are going to use the dvm, then we |
268 | 287 | if ($starter eq "prun") { |
269 | 288 | # need to start it |
270 | | - $cmd = "orte-dvm -mca pmix_system_server 1 2>&1 &"; |
| 289 | + $cmd = "orte-dvm -mca pmix_system_server 1"; |
| 290 | + print "##DVM: Launching $cmd\n"; |
271 | 291 | if ($myresults) { |
272 | 292 | print FILE "\n\n$cmd\n"; |
273 | 293 | } |
274 | 294 | if (!$SHOWME) { |
275 | | - system($cmd); |
276 | | - $havedvm = 1; |
| 295 | + $havedvm = open($dvmout, $cmd."|") or die "##DVM: Spawn error $!\n"; |
| 296 | + print "##DVM: pid=$havedvm\n"; |
| 297 | + # Wait that the dvm reports that it is ready |
| 298 | + my $waitready = <$dvmout>; |
| 299 | + if($waitready =~ /DVM ready/i) { |
| 300 | + print "##DVM: $waitready\n"; |
| 301 | + } |
| 302 | + else { |
| 303 | + die "##DVM: error: $waitready\n"; |
| 304 | + } |
277 | 305 | } |
278 | | - # give it a couple of seconds to start |
279 | | - sleep 2; |
280 | 306 | } |
281 | 307 |
|
282 | 308 | if ($myresults) { |
|
285 | 311 | my $testnum = 0; |
286 | 312 | foreach $test (@tests) { |
287 | 313 | $option = $options[$testnum]; |
| 314 | + if ($starter eq "aprun") { |
| 315 | + $option =~ s/-mca\s+(\S+)\s+(\S+)/-e OMPI_MCA_$1=$2/g; |
| 316 | + } |
| 317 | + if ($starter eq "srun") { |
| 318 | + $option =~ s/-mca\s+(\S+)\s+(\S+)\s*/OMPI_MCA_$1=$2,/g; |
| 319 | + $option =~ s/\s*(OMPI_MCA\S+)/ --export=$1ALL/g; |
| 320 | + } |
288 | 321 | if (-e $test) { |
289 | 322 | if ($myresults) { |
290 | 323 | print FILE "#nodes,$test,$option\n"; |
|
294 | 327 | $cmd = $starter . $starteroptions[$index] . " $test 2>&1"; |
295 | 328 | system($cmd); |
296 | 329 | } |
297 | | - $n = 1; |
| 330 | + $n = $npmin; |
298 | 331 | while ($n <= $num_nodes) { |
299 | 332 | push @csvrow,$n; |
300 | | - if ($starter eq "prun" or $starter eq "mpirun") { |
301 | | - $cmd = "time " . $starter . " " . $starteroptions[$index] . " $option -n $n $test 2>&1"; |
| 333 | + if ($starter eq "prun" or $starter eq "mpirun" or $starter eq "aprun") { |
| 334 | + my $np = $n * $ppn; |
| 335 | + $cmd = "time " . $starter . " " . $starteroptions[$index] . " $option -n $np $test 2>&1"; |
302 | 336 | } else { |
303 | 337 | $cmd = "time " . $starter . " " . $starteroptions[$index] . " $option -N $n $test 2>&1"; |
304 | 338 | } |
|
326 | 360 | if (!$SHOWME) { |
327 | 361 | $cmd = "prun --terminate"; |
328 | 362 | system($cmd); |
| 363 | + waitpid($havedvm, 0); |
329 | 364 | } |
330 | 365 | } |
331 | 366 | $index = $index + 1; |
|
0 commit comments