X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=glafp-utils%2Frunstdtest%2Frunstdtest.prl;h=1b33388cd25c8b29eeb94ebd1537320cbc9dc01f;hb=5a5747202b4fb5c42bdc1ebcacb9f9b7bf87cdc7;hp=32a79395c1069b164ccb52159b108f75d8837bdc;hpb=25a201e1fc3cb2eabaf536c3bdb62e4092361682;p=ghc-hetmet.git diff --git a/glafp-utils/runstdtest/runstdtest.prl b/glafp-utils/runstdtest/runstdtest.prl index 32a7939..1b33388 100644 --- a/glafp-utils/runstdtest/runstdtest.prl +++ b/glafp-utils/runstdtest/runstdtest.prl @@ -2,7 +2,7 @@ # The perl script requires the following variables to be bound # to something meaningful before it will operate correctly: # -# TMPDIR +# DEFAULT_TMPDIR # CONTEXT_DIFF # RM # @@ -45,13 +45,14 @@ $SaveStderr = 0; $SaveStdout = 0; $Status = 0; @PgmArgs = (); +$PgmFail=0; $PgmExitStatus = 0; $PgmStdinFile = '/dev/null'; if ( $ENV{'TMPDIR'} ) { # where to make tmp file names $TmpPrefix = $ENV{'TMPDIR'}; } else { - $TmpPrefix ="$TMPDIR"; - $ENV{'TMPDIR'} = "$TMPDIR"; # set the env var as well + $TmpPrefix ="$DEFAULT_TMPDIR"; + $ENV{'TMPDIR'} = "$DEFAULT_TMPDIR"; # set the env var as well } $ScriptFile = "$TmpPrefix/run_me$$"; $DefaultStdoutFile = "$TmpPrefix/no_stdout$$"; # can't use /dev/null (e.g. Alphas) @@ -61,9 +62,13 @@ $DefaultStderrFile = "$TmpPrefix/no_stderr$$"; $PreScript = ''; $PostScript = ''; $TimeCmd = ''; +$Heimdall = 0; +$HeimdallPrefix = ''; +$HeimdallStats = "heimdall.summary"; $StatsFile = "$TmpPrefix/stats$$"; +$CacheProfStats = "cacheprof.out.summary"; $SysSpecificTiming = ''; -$SpixTiming = 'no'; +$CacheProf = 'no'; die "$Pgm: program to run not given as first argument\n" if $#ARGV < 0; $ToRun = $ARGV[0]; shift(@ARGV); @@ -86,8 +91,9 @@ arg: while ($_ = $ARGV[0]) { /^-i(.*)/ && do { $PgmStdinFile = &grab_arg_arg('-i',$1); $Status++, print STDERR "$Pgm: bogus -i input file: $PgmStdinFile\n" - if ! -f $PgmStdinFile; + if $PgmStdinFile !~ /^\/dev\/.*$/ && ! -f $PgmStdinFile; next arg; }; + /^-fail/ && do { $PgmFail=1; next arg; }; /^-x(.*)/ && do { $PgmExitStatus = &grab_arg_arg('-x',$1); $Status++ , print STDERR "$Pgm: bogus -x expected exit status: $PgmExitStatus\n" @@ -108,9 +114,13 @@ arg: while ($_ = $ARGV[0]) { next arg; }; /^-(ghc|hbc)-timing$/ && do { $SysSpecificTiming = $1; next arg; }; - /^-spix-timing$/ && do { $SysSpecificTiming = 'ghcspix'; - $SpixTiming = 'yes'; - next arg; }; + /^-cacheprof$/ && do { $SysSpecificTiming = 'ghc-instrs'; + $CacheProf = 'yes'; + next arg }; + /^-heimdall$/ && do { $HeimdallPrefix = 'heimdall_cp '; # must have trailing space! + $SysSpecificTiming = 'ghc-instrs'; + $Heimdall = 1; + next arg; }; /^-t(.*)/ && do { $TimeCmd = &grab_arg_arg('-t', $1); next arg; }; # anything else is taken to be a pgm arg @@ -156,39 +166,11 @@ foreach $a ( @PgmArgs ) { # deal with system-specific timing options $TimingMagic = ''; if ( $SysSpecificTiming =~ /^ghc/ ) { - $TimingMagic = "+RTS -s$StatsFile -RTS" + $TimingMagic = "+RTS -S$StatsFile -RTS" } elsif ( $SysSpecificTiming eq 'hbc' ) { $TimingMagic = "-S$StatsFile"; } -$ToRunOrig = $ToRun; -if ( $SpixTiming eq 'yes' ) { - $ToRun .= '.spix'; - - # gotta find first/last addresses in the mutator code - $FirstSpix = '_callWrapper'; - $LastSpix = '???'; # usually _mpz_get_si, but can't be sure - - open(SPIXNM, "nm -n $ToRunOrig |") || die "nm -n $ToRunOrig open failed!\n"; - spix: while () { - if ( / T +(_freeForeignObj|_([A-Za-z]+)Hook|_xmalloc|_mpz_get_si)$/ ) { - $LastSpix = $1; - last spix; - } - } - close(SPIXNM); # || die "nm -n $ToRunOrig close failed!\n"; - - $SpixifyLine1 = "spix -o $ToRun -t$FirstSpix,$LastSpix $ToRunOrig"; - $SpixstatsLine1 = "spixstats -b $TmpPrefix/runtest$$.3 $ToRunOrig > $ToRunOrig.spixstats1"; - $SpixifyLine2 = "spix -o $ToRun +t$FirstSpix,$LastSpix $ToRunOrig"; - $SpixstatsLine2 = "spixstats -b $TmpPrefix/runtest$$.3 $ToRunOrig > $ToRunOrig.spixstats2"; -} else { - $SpixifyLine1 = ''; - $SpixstatsLine1 = ''; - $SpixifyLine2 = ''; - $SpixstatsLine2 = ''; -} - if ($PreScript ne '') { local($to_do); $PreScriptLines = `cat $PreScript`; @@ -217,9 +199,14 @@ cat /dev/null > $DefaultStdoutFile cat /dev/null > $DefaultStderrFile $PreScriptLines $SpixifyLine1 -$TimeCmd /bin/sh -c \'$ToRun $TimingMagic @PgmArgs < $PgmStdinFile 1> $TmpPrefix/runtest$$.1 2> $TmpPrefix/runtest$$.2 3> $TmpPrefix/runtest$$.3\' +$TimeCmd /bin/sh -c \'$HeimdallPrefix$ToRun $TimingMagic @PgmArgs < $PgmStdinFile 1> $TmpPrefix/runtest$$.1 2> $TmpPrefix/runtest$$.2 3> $TmpPrefix/runtest$$.3\' progexit=\$? -if [ \$progexit -ne $PgmExitStatus ]; then +if [ \$progexit -eq 0 ] && [ $PgmFail -ne 0 ]; then + echo $ToRun @PgmArgs \\< $PgmStdinFile + echo "****" expected a failure, but was successful + myexit=1 +fi +if [ \$progexit -ne $PgmExitStatus ] && [ $PgmFail -eq 0 ]; then echo $ToRun @PgmArgs \\< $PgmStdinFile echo "****" expected exit status $PgmExitStatus not seen \\; got \$progexit myexit=1 @@ -240,7 +227,7 @@ else myexit=\$? diffsShown=1 fi - if [ $SaveStdout = 1 ] && [ \$progexit = $PgmExitStatus ] && + if [ $SaveStdout = 1 ] && [ $PgmStdoutFile[0] != $DefaultStdoutFile ] && [ -s $TmpPrefix/runtest$$.1 ]; then echo Saving away stdout output in $PgmStdoutFile[0] ... if [ -f $PgmStdoutFile[0] ]; then @@ -252,6 +239,9 @@ else fi egrep -v '^ld\.so:.*has older revision than expected' < $TmpPrefix/runtest$$.2 > $TmpPrefix/runtest$$.2b mv -f $TmpPrefix/runtest$$.2b $TmpPrefix/runtest$$.2 +egrep '^=== HEIMDALL: ' < $TmpPrefix/runtest$$.2 > $HeimdallStats +egrep -v '^=== HEIMDALL: ' < $TmpPrefix/runtest$$.2 > $TmpPrefix/runtest$$.2b +mv -f $TmpPrefix/runtest$$.2b $TmpPrefix/runtest$$.2 hit='NO' for out_file in @PgmStderrFile ; do @@ -268,7 +258,7 @@ if [ \$hit = 'NO' ] ; then myexit=\$? diffsShown=1 fi -if [ $SaveStderr = 1 ] && [ \$progexit = $PgmExitStatus ] && +if [ $SaveStderr = 1 ] && [ $PgmStderrFile[0] != $DefaultStderrFile ] && [ -s $TmpPrefix/runtest$$.2 ]; then echo Saving away stderr output in $PgmStderrFile[0] ... if [ -f $PgmStderrFile[0] ]; then @@ -277,13 +267,6 @@ if [ $SaveStderr = 1 ] && [ \$progexit = $PgmExitStatus ] && fi; cp $TmpPrefix/runtest$$.2 $PgmStderrFile[0] fi -$SpixstatsLine1 - -if [ $SpixTiming = 'yes' -a \$myexit = 0 ] ; then - $SpixifyLine2 - $TimeCmd /bin/sh -c \'$ToRun $TimingMagic @PgmArgs < $PgmStdinFile 1> /dev/null 2> /dev/null 3> $TmpPrefix/runtest$$.3\' - $SpixstatsLine2 -fi ${RM} core $ToRunOrig.spix $DefaultStdoutFile $DefaultStderrFile $TmpPrefix/runtest$$.1 $TmpPrefix/runtest$$.2 $TmpPrefix/runtest$$.3 exit \$myexit @@ -306,18 +289,17 @@ if ( $SysSpecificTiming eq '' ) { } &process_stats_file(); -&process_spixstats_files() if $SpixTiming eq 'yes'; +&process_cacheprof_files() if $CacheProf eq 'yes'; +&process_heimdall_file() if $Heimdall; # print out what we found -if ( $SpixTiming ne 'yes' ) { - print STDERR "<<$SysSpecificTiming: ", - "$BytesAlloc bytes, $GCs GCs, $AvgResidency/$MaxResidency avg/max bytes residency ($ResidencySamples samples), ${TotMem}M in use, $InitTime INIT ($InitElapsed elapsed), $MutTime MUT ($MutElapsed elapsed), $GcTime GC ($GcElapsed elapsed)", - " :$SysSpecificTiming>>\n"; +print STDERR "<<$SysSpecificTiming: "; +if ( $CacheProf ne 'yes' && !$Heimdall) { + print STDERR "$BytesAlloc bytes, $GCs GCs, $AvgResidency/$MaxResidency avg/max bytes residency ($ResidencySamples samples), $GCWork bytes GC work, ${TotMem}M in use, $InitTime INIT ($InitElapsed elapsed), $MutTime MUT ($MutElapsed elapsed), $GcTime GC ($GcElapsed elapsed)"; } else { - print STDERR "<<$SysSpecificTiming: ", - "$BytesAlloc bytes, $GCs GCs, $AvgResidency/$MaxResidency avg/max bytes residency ($ResidencySamples samples), $TotalInsns[1]/$TotalInsns[2] instructions, $LoadInsns[1]/$LoadInsns[2] loads, $StoreInsns[1]/$StoreInsns[2] stores, $BranchInsns[1]/$BranchInsns[2] branches, $OtherInsns[1]/$OtherInsns[2] others", - " :$SysSpecificTiming>>\n"; -} + print STDERR "$BytesAlloc bytes, $GCs GCs, $AvgResidency/$MaxResidency avg/max bytes residency ($ResidencySamples samples), $GCWork bytes GC work, ${TotMem}M in use, $InitTime INIT ($InitElapsed elapsed), $MutTime MUT ($MutElapsed elapsed), $GcTime GC ($GcElapsed elapsed), $TotInstrs instructions, $TotReads memory reads, $TotWrites memory writes"; +}; +print STDERR " :$SysSpecificTiming>>\n"; # OK, party over unlink $StatsFile; @@ -381,6 +363,7 @@ sub process_stats_file { } $BytesAlloc = $1 if /^\s*([0-9,]+) bytes allocated in the heap/; + $GCWork = $1 if /^\s*([0-9,]+) bytes copied during GC/; # if ( /^\s*([0-9,]+) bytes maximum residency .* (\d+) sample/ ) { # $MaxResidency = $1; $ResidencySamples = $2; @@ -392,11 +375,11 @@ sub process_stats_file { $TotMem = $1; } - if ( /^\s*INIT\s+time\s*(\d+\.\d\d)s\s*\(\s*(\d+\.\d\d)s elapsed\)/ ) { + if ( /^\s*INIT\s+time\s*(-*\d+\.\d\d)s\s*\(\s*(-*\d+\.\d\d)s elapsed\)/ ) { $InitTime = $1; $InitElapsed = $2; - } elsif ( /^\s*MUT\s+time\s*(\d+\.\d\d)s\s*\(\s*(\d+\.\d\d)s elapsed\)/ ) { + } elsif ( /^\s*MUT\s+time\s*(-*\d+\.\d\d)s\s*\(\s*(-*\d+\.\d\d)s elapsed\)/ ) { $MutTime = $1; $MutElapsed = $2; - } elsif ( /^\s*GC\s+time\s*(\d+\.\d\d)s\s*\(\s*(\d+\.\d\d)s elapsed\)/ ) { + } elsif ( /^\s*GC\s+time\s*(-*\d+\.\d\d)s\s*\(\s*(-*\d+\.\d\d)s elapsed\)/ ) { $GcTime = $1; $GcElapsed = $2; } } @@ -441,6 +424,7 @@ sub process_stats_file { print STDERR "Warning: GcTime inot found in stats file\n" unless defined($GcTime); print STDERR "Warning: GcElapsed not found in stats file\n" unless defined($GcElapsed); print STDERR "Warning: total memory not found in stats file\n" unless defined($TotMem); + print STDERR "Warning: GC work not found in stats file\n" unless defined($GCWork); # things we didn't necessarily expect to find $MaxResidency = 0 unless defined($MaxResidency); @@ -449,6 +433,7 @@ sub process_stats_file { # a bit of tidying $BytesAlloc =~ s/,//g; + $GCWork =~ s/,//g; $MaxResidency =~ s/,//g; $GCs =~ s/,//g; $InitTime =~ s/,//g; @@ -459,47 +444,39 @@ sub process_stats_file { $GcElapsed =~ s/,//g; } -sub process_spixstats_files { # 2 of them; one for mutator, one for GC - - @TotalInsns = (); - @LoadInsns = (); - @StoreInsns = (); - @BranchInsns= (); - @OtherInsns = (); - - foreach $f (1, 2) { - - open(STATS, "< $ToRunOrig.spixstats$f") || die "Failed when opening $ToRunOrig.spixstats$f\n"; - while () { - last if /^OPCODES \(STATIC\):/; # party over +sub process_cacheprof_files { - next if /^OPCODES \(DYNAMIC\):/; - next if /^$/; - next if /^opcode\s+#executed/; - next if /^SUBTOTAL/; + open(STATS, "< $CacheProfStats") || die("Can't open $CacheProfStats\n"); - if ( /^ld\S*\s+(\d+)/ ) { - $LoadInsns[$f] += $1; - - } elsif ( /^st\S*\s+(\d+)/ ) { - $StoreInsns[$f] += $1; - - } elsif ( /^(jmpl|call|b\S*)\s+(\d+)/ ) { - $BranchInsns[$f] += $2; + # the format of the info in this file is: + # OTHER(intrs,reads,writes,read-misses,write-misses) + # where read-misses and write-misses will both be zero if we're + # just counting instructions. + while () { + /OTHER\(\s*([0-9]+),\s*([0-9]+),\s*([0-9]+),\s*([0-9]+),\s*([0-9]+)\)/ && do { + $TotInstrs = $1; + $TotReads = $2; + $TotWrites = $3; + } + } + close(STATS); +} - } elsif ( /^TOTAL\s+(\d+)/ ) { - $TotalInsns[$f] = $1; - print STDERR "TotalInsns doesn't match categories total!\n" - if $TotalInsns[$f] != - ($LoadInsns[$f] + $StoreInsns[$f] + $BranchInsns[$f] + $OtherInsns[$f]); +sub process_heimdall_file { - } elsif ( /^\S+\s+(\d+)/ ) { - $OtherInsns[$f] += $1; + open(STATS, "< $HeimdallStats") || die("Can't open $HeimdallStats\n"); - } else { - die "Funny line?? $_"; - } + # instruction counts from Julian Seward's HEIMDALL: + # + # === HEIMDALL: instruction counts: 815000 instrs, 230040 reads, 138692 writes + while () { + /^=== HEIMDALL: instruction counts: ([0-9]+) instrs, ([0-9]+) reads, ([0-9]+) writes/ + && do { + $TotInstrs = $1; + $TotReads = $2; + $TotWrites = $3; } - close(STATS) || die "Failed when closing $ToRunOrig.spixstats\n"; - } + } + close(STATS); } +