X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=glafp-utils%2Frunstdtest%2Frunstdtest.prl;h=1b1af9fb4da4c649c3243d19f641abe89129562e;hb=21044c2db566270297baef26c0a8d9228e66af7c;hp=d32297b05620b681dd12bb0da28c7bdf8c7a3884;hpb=4764726c520c6f979f092b9b7b7f263d53dd68f9;p=ghc-hetmet.git diff --git a/glafp-utils/runstdtest/runstdtest.prl b/glafp-utils/runstdtest/runstdtest.prl index d32297b..1b1af9f 100644 --- a/glafp-utils/runstdtest/runstdtest.prl +++ b/glafp-utils/runstdtest/runstdtest.prl @@ -54,6 +54,13 @@ if ( $ENV{'TMPDIR'} ) { # where to make tmp file names $TmpPrefix ="$DEFAULT_TMPDIR"; $ENV{'TMPDIR'} = "$DEFAULT_TMPDIR"; # set the env var as well } +# If this is Cygwin, ignore eol and CR characters. +# Perhaps required for MSYS too, although the cygpath +# bit is hopefully unnecessary. +if ( `uname | grep CYGWIN` ) { + $CONTEXT_DIFF=$CONTEXT_DIFF . " --strip-trailing-cr" ; + $TmpPrefix = `cygpath -m $TmpPrefix | tr -d \\\\n`; +} $ScriptFile = "$TmpPrefix/run_me$$"; $DefaultStdoutFile = "$TmpPrefix/no_stdout$$"; # can't use /dev/null (e.g. Alphas) $DefaultStderrFile = "$TmpPrefix/no_stderr$$"; @@ -62,13 +69,10 @@ $DefaultStderrFile = "$TmpPrefix/no_stderr$$"; $PreScript = ''; $PostScript = ''; $TimeCmd = ''; -$Heimdall = 0; -$HeimdallPrefix = ''; -$HeimdallStats = "heimdall.summary"; $StatsFile = "$TmpPrefix/stats$$"; -$CacheProfStats = "cacheprof.out.summary"; +$CachegrindStats = "cachegrind.out.summary"; $SysSpecificTiming = ''; -$CacheProf = 'no'; +$Cachegrind = 'no'; die "$Pgm: program to run not given as first argument\n" if $#ARGV < 0; $ToRun = $ARGV[0]; shift(@ARGV); @@ -114,13 +118,9 @@ arg: while ($_ = $ARGV[0]) { next arg; }; /^-(ghc|hbc)-timing$/ && do { $SysSpecificTiming = $1; 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; }; + /^-cachegrind$/ && do { $SysSpecificTiming = 'ghc-instrs'; + $Cachegrind = 'yes'; + next arg }; /^-t(.*)/ && do { $TimeCmd = &grab_arg_arg('-t', $1); next arg; }; # anything else is taken to be a pgm arg @@ -174,6 +174,7 @@ if ( $SysSpecificTiming =~ /^ghc/ ) { if ($PreScript ne '') { local($to_do); $PreScriptLines = `cat $PreScript`; + $PreScriptLines =~ s/\r//g; } else { $PreScriptLines = ''; } @@ -181,6 +182,7 @@ if ($PreScript ne '') { if ($PostScript ne '') { local($to_do); $PostScriptLines = `cat $PostScript`; + $PostScriptLines =~ s/\r//g; $* = 1; $PostScriptLines =~ s#\$o1#$TmpPrefix/runtest$$.1#g; $PostScriptLines =~ s#\$o2#$TmpPrefix/runtest$$.2#g; @@ -190,6 +192,12 @@ if ($PostScript ne '') { # OK, so we're gonna do the normal thing... +if ($Cachegrind eq 'yes') { + $CachegrindPrefix = "valgrind --tool=cachegrind --log-fd=9 9>$CachegrindStats"; +} else { + $CachegrindPrefix = ''; +} + $Script = < $DefaultStdoutFile cat /dev/null > $DefaultStderrFile $PreScriptLines $SpixifyLine1 -$TimeCmd /bin/sh -c \'$HeimdallPrefix$ToRun $TimingMagic @PgmArgs < $PgmStdinFile 1> $TmpPrefix/runtest$$.1 2> $TmpPrefix/runtest$$.2 3> $TmpPrefix/runtest$$.3\' +echo $TimeCmd /bin/sh -c \'$CachegrindPrefix $ToRun $TimingMagic @PgmArgs < $PgmStdinFile 1> $TmpPrefix/runtest$$.1 2> $TmpPrefix/runtest$$.2 3> $TmpPrefix/runtest$$.3\' +$TimeCmd /bin/sh -c \'$CachegrindPrefix $ToRun $TimingMagic @PgmArgs < $PgmStdinFile 1> $TmpPrefix/runtest$$.1 2> $TmpPrefix/runtest$$.2 3> $TmpPrefix/runtest$$.3\' progexit=\$? if [ \$progexit -eq 0 ] && [ $PgmFail -ne 0 ]; then echo $ToRun @PgmArgs \\< $PgmStdinFile @@ -237,11 +246,6 @@ else cp $TmpPrefix/runtest$$.1 $PgmStdoutFile[0] fi fi -if [ "$Heimdall" = "1" ]; then - egrep '^=== HEIMDALL: ' < $TmpPrefix/runtest$$.2 > $HeimdallStats -fi -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 @@ -289,15 +293,14 @@ if ( $SysSpecificTiming eq '' ) { } &process_stats_file(); -&process_cacheprof_files() if $CacheProf eq 'yes'; -&process_heimdall_file() if $Heimdall; +&process_cachegrind_files() if $Cachegrind eq 'yes'; # print out what we found print STDERR "<<$SysSpecificTiming: "; -if ( $CacheProf ne 'yes' && !$Heimdall) { +if ( $Cachegrind ne 'yes') { 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 "$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 "$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, $TotMisses L2 cache misses"; }; print STDERR " :$SysSpecificTiming>>\n"; @@ -309,7 +312,7 @@ exit 0; sub grab_arg_arg { local($option, $rest_of_arg) = @_; - if ($rest_of_arg) { + if ($rest_of_arg ne "") { return($rest_of_arg); } elsif ($#ARGV >= 0) { local($temp) = $ARGV[0]; shift(@ARGV); @@ -355,6 +358,7 @@ sub process_stats_file { local($tot_live) = 0; # for calculating residency stuff local($tot_samples) = 0; + $GCWork = 0; while () { if (! /Gen:\s+0/ && /^\s*\d+\s+\d+\s+(\d+)\s+\d+\.\d+/ ) { $max_live = $1 if $max_live < $1; @@ -363,7 +367,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/; + $GCWork += $1 if /^\s*([0-9,]+) bytes copied during GC/; # if ( /^\s*([0-9,]+) bytes maximum residency .* (\d+) sample/ ) { # $MaxResidency = $1; $ResidencySamples = $2; @@ -444,39 +448,28 @@ sub process_stats_file { $GcElapsed =~ s/,//g; } -sub process_cacheprof_files { - - open(STATS, "< $CacheProfStats") || die("Can't open $CacheProfStats\n"); - - # 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); -} - -sub process_heimdall_file { +sub process_cachegrind_files { - open(STATS, "< $HeimdallStats") || die("Can't open $HeimdallStats\n"); + open(STATS, "< $CachegrindStats") || die("Can't open $CachegrindStats\n"); - # 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 { + /^==\d+==\s+I\s+refs:\s+([0-9,]*)/ && do { $TotInstrs = $1; - $TotReads = $2; - $TotWrites = $3; - } - } - close(STATS); + $TotInstrs =~ s/,//g; + }; + + /^==\d+==\s+D\s+refs:\s+[0-9,]+\s+\(([0-9,]+)\s+rd\s+\+\s+([0-9,]+)\s+wr/ && do { + $TotReads = $1; + $TotWrites = $2; + $TotReads =~ s/,//g; + $TotWrites =~ s/,//g; + }; + + /^==\d+==\s+L2d\s+misses:\s+([0-9,]+)/ && do { + $TotMisses = $1; + $TotMisses =~ s/,//g; + }; + } + close(STATS); }