diff --git a/contrib/scaling/scaling.pl b/contrib/scaling/scaling.pl index d3885b9831..77e98290b1 100755 --- a/contrib/scaling/scaling.pl +++ b/contrib/scaling/scaling.pl @@ -15,7 +15,11 @@ my $usedvm = 0; my $usesrun = 0; my $usempirun = 0; my $useaprun = 0; +my $useaprun = 0; +my $myapp; my $runall = 0; +my $myresults; +my @csvrow; my @tests = qw(/bin/true ./orte_no_op ./mpi_no_op ./mpi_no_op); my @options = ("", "", "", "-mca mpi_add_procs_cutoff 0 -mca pmix_base_async_modex 1"); @@ -23,7 +27,7 @@ my @starters = qw(mpirun orte-submit srun aprun orterun); my @starteroptions = ("-npernode 1 --novm", "--hnp file:dvm_uri -pernode", "--distribution=cyclic", - "-N 1" + "-N 1", "-npernode 1 --novm"); # Set to true if the script should merely print the cmds @@ -43,7 +47,9 @@ GetOptions( "srun" => \$usesrun, "aprun" => \$useaprun, "mpirun" => \$usempirun, + "myapp=s" => \$myapp, "all" => \$runall, + "results=s" => \$myresults, ) or die "unable to parse options, stopped"; if ($HELP) { @@ -53,12 +59,14 @@ $0 [options] --help | -h This help message --quiet | -q Only output critical messages to stdout --showme Show the actual commands without executing them ---reps Number of times to run each test (for statistics) +--reps=s Number of times to run each test (for statistics) --mpirun Use only mpirun (or its equivalent orterun) --dvm Use only orte-dvm to execute the test --srun Use only srun (if available) to execute the test --arpun Use only aprun (if available) to execute the test +--myapp=s In addition to the standard tests, run this specific application (including any args) --all Use all available start commands [default] +--results=file File where results are to stored in comma-separated value format EOT exit(0); } @@ -72,7 +80,6 @@ my @lines; my $line; my @results; my $res; -my $toggle; my $idx; my $option; my $havedvm = 0; @@ -151,6 +158,16 @@ if (scalar @starters == 0) { exit; } +# if they gave us an app, add it to the list of tests +if ($myapp) { + push @tests, $myapp; +} + +if ($myresults) { + # open the results file + open FILE, ">$myresults" || die "file could not be opened"; +} + # if we are going to use the dvm, then we # need to start it if (-e "dvm_uri") { @@ -174,19 +191,52 @@ foreach $starter (@starters) { # determine the number of nodes - doesn't # matter which starter we use $cmd = $starters[0] . " " . $starteroptions[0] . " hostname"; +print "CMD: $cmd\n"; $output = `$cmd`; +print "$output\n"; @lines = split(/\n/, $output); $num_nodes = $#lines + 1; +# collect the complete list of starters +my $mystarters; +$idx=1; +$mystarters = $starters[0]; +while ($idx < $#starters) { + $mystarters = $mystarters . "," . $starters[$idx]; + $idx = $idx + 1; +} +# get the local date and time +my ($sec,$min,$hour,$day,$month,$yr19,@rest) = localtime(time); + +# start by printing out the resulting configuration print "\n--------------------------------------------------\n"; +print "\nTest configuration:\n"; +print "\tDate:\t" . "$day-".++$month. "-".($yr19+1900) . " " . sprintf("%02d",$hour).":".sprintf("%02d",$min).":".sprintf("%02d",$sec) . "\n";; +print "\tNum nodes:\t" . $num_nodes . "\n"; +print "\tStarters:\t" . $mystarters . "\n"; +print "\n--------------------------------------------------\n"; + +# and tag the output file as well +if ($myresults) { + print FILE "Test configuration:\n"; + print FILE "Date:\t" . "$day-".++$month. "-".($yr19+1900) . " " . sprintf("%02d",$hour).":".sprintf("%02d",$min).":".sprintf("%02d",$sec) . "\n";; + print FILE "Num nodes:\t" . $num_nodes . "\n"; + print FILE "Starters:\t" . $mystarters . "\n"; +} my $index = 0; foreach $starter (@starters) { + if ($myresults) { + print FILE "\n\n$starter\n\n"; + } my $testnum = 0; foreach $test (@tests) { $option = $options[$testnum]; if (-e $test) { + if ($myresults) { + print FILE "#nodes,$test\n"; + } if (!$SHOWME) { # pre-position the executable $cmd = $starter . $starteroptions[$index] . " $test 2>&1"; @@ -194,38 +244,70 @@ foreach $starter (@starters) { } $n = 1; while ($n <= $num_nodes) { + push @csvrow,$n; $cmd = "time " . $starter . " " . $starteroptions[$index] . " -n $n $option $test 2>&1"; print $cmd . "\n"; if (!$SHOWME) { for (1..$reps) { - $toggle = 1; $output = `$cmd`; - print $output . "\n"; + # print $output . "\n"; @lines = split(/\n/, $output); foreach $line (@lines) { - if (0 <= index($line, "user") || - 0 <= index($line, "sys") || - 0 <= index($line, "real") || + if (0 <= index($line, "real") || 0 <= index($line, "elapsed")) { + # we know that at least one item of interest is + # in this line, so let's look for it - start + # by getting rid of any leading whitespace + $line =~ s/^\s+//; + @results = split (/ +/,$line); $idx = 0; - @results = split(/\s+/,$line, 4); foreach $res (@results) { - if ($idx < 3) { - print $res; - if (0 == $toggle) { - print " "; - $toggle = 1; + # we are only interested in the real or elapsed time + my $strloc = index($res, "real"); + if (0 <= $strloc) { + # some systems put the number in front of + # this word, and some append the word to + # the number - consider both cases + if (0 == $strloc) { + # it must be in the prior location + push @csvrow,$results[$idx-1]; } else { - print " "; - $toggle = 0; + # take the portion of the string up to the tag + push @csvrow,substr($res, 0, $strloc); + } + } else { + $strloc = index($res, "elapsed"); + if (0 <= $strloc) { + # some systems put the number in front of + # this word, and some append the word to + # the number - consider both cases + if (0 == $strloc) { + # it must be in the prior location + push @csvrow,$results[$idx-1]; + } else { + # take the portion of the string up to the tag + push @csvrow,substr($res, 0, $strloc); + } } } $idx = $idx + 1; } - print "\n"; } } } + # we have now completed all the reps, so log the results + if ($myresults) { + my $myout; + my $mycnt=1; + $myout = $csvrow[0]; + while ($mycnt < $#csvrow) { + $myout = $myout . "," . $csvrow[$mycnt]; + $mycnt = $mycnt + 1; + } + print FILE "$myout\n"; + # clear the array + @csvrow = (); + } print "\n"; } $n = 2 * $n; @@ -234,12 +316,68 @@ foreach $starter (@starters) { $cmd = "time " . $starter . " " . $starteroptions[$index] . " $option $test 2>&1"; print $cmd . "\n"; if (!$SHOWME) { + push @csvrow,$num_nodes; for (1..$reps) { $output = `$cmd`; - $output =~ s/(.+)\n.*/$1/; - @results = split(/\s+/,$output); - print $results[0] . " " . $results[1] . " " . $results[2] . "\n"; + # print $output . "\n"; + @lines = split(/\n/, $output); + foreach $line (@lines) { + if (0 <= index($line, "real") || + 0 <= index($line, "elapsed")) { + # we know that at least one item of interest is + # in this line, so let's look for it - start + # by getting rid of any leading whitespace + $line =~ s/^\s+//; + @results = split (/ +/,$line); + $idx = 0; + foreach $res (@results) { + # we are only interested in the real or elapsed time + my $strloc = index($res, "real"); + if (0 <= $strloc) { + # some systems put the number in front of + # this word, and some append the word to + # the number - consider both cases + if (0 == $strloc) { + # it must be in the prior location + push @csvrow,$results[$idx-1]; + } else { + # take the portion of the string up to the tag + push @csvrow,substr($res, 0, $strloc); + } + } else { + $strloc = index($res, "elapsed"); + if (0 <= $strloc) { + # some systems put the number in front of + # this word, and some append the word to + # the number - consider both cases + if (0 == $strloc) { + # it must be in the prior location + push @csvrow,$results[$idx-1]; + } else { + # take the portion of the string up to the tag + push @csvrow,substr($res, 0, $strloc); + } + } + } + $idx = $idx + 1; + } + } + } } + # we have now completed all the reps, so log the results + if ($myresults) { + my $myout; + my $mycnt=1; + $myout = $csvrow[0]; + while ($mycnt <= $#csvrow) { + $myout = $myout . "," . $csvrow[$mycnt]; + $mycnt = $mycnt + 1; + } + print FILE "$myout\n"; + # clear the output + @csvrow = (); + } + print "\n"; } } print "\n--------------------------------------------------\n";