|
Packit Service |
c5cf8c |
#! /usr/bin/perl
|
|
Packit Service |
c5cf8c |
# -*- Mode: perl; -*-
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# In Progress script to make the default log files more readable.
|
|
Packit Service |
c5cf8c |
# This indents the routine enter/exit lines, and applies that indent to
|
|
Packit Service |
c5cf8c |
# other lines. It also simplifies the lines, removing all but the message
|
|
Packit Service |
c5cf8c |
# and location (and computing the time within each function)
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# Set defaults
|
|
Packit Service |
c5cf8c |
my $whichrank = -1;
|
|
Packit Service |
c5cf8c |
my $filenameTrim = "default";
|
|
Packit Service |
c5cf8c |
my %elideCall = ();
|
|
Packit Service |
c5cf8c |
my $infile = "";
|
|
Packit Service |
c5cf8c |
my $isThreaded = 1;
|
|
Packit Service |
c5cf8c |
my $onlyRoutine = 0;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
for (@ARGV) {
|
|
Packit Service |
c5cf8c |
if (/^--?rank=(\d+)/) {
|
|
Packit Service |
c5cf8c |
$whichrank = $1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
elsif (/^--?srcdir=(.*)/) {
|
|
Packit Service |
c5cf8c |
$filenameTrim = $1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
elsif (/^--?elide=(.*)/) {
|
|
Packit Service |
c5cf8c |
# This must exactly match the function name recorded
|
|
Packit Service |
c5cf8c |
$elideCall{$1} = 1;
|
|
Packit Service |
c5cf8c |
$elideCall{"MPID_STATE_$1"} = 1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
elsif (/^-/) {
|
|
Packit Service |
c5cf8c |
print STDERR
|
|
Packit Service |
c5cf8c |
"getfuncstack [ -rank=n ] [-srcdir=path] [-elide=name] < logfile\n";
|
|
Packit Service |
c5cf8c |
exit(1);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
else {
|
|
Packit Service |
c5cf8c |
$infile = $_;
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
@ARGV = ();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Set initial values
|
|
Packit Service |
c5cf8c |
my $linecount = 0;
|
|
Packit Service |
c5cf8c |
my $nestlevel = 0;
|
|
Packit Service |
c5cf8c |
my $curstate = "";
|
|
Packit Service |
c5cf8c |
my @routineStack = ();
|
|
Packit Service |
c5cf8c |
my @routineTime = ();
|
|
Packit Service |
c5cf8c |
my $inElide = 0;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
while (<>) {
|
|
Packit Service |
c5cf8c |
my $spaces = "";
|
|
Packit Service |
c5cf8c |
my $tottime = "";
|
|
Packit Service |
c5cf8c |
my $extraMsg = "";
|
|
Packit Service |
c5cf8c |
$linecount++;
|
|
Packit Service |
c5cf8c |
($world,$rank,$thread,$class,$time,$file,$line,$msg) = split( /\t/, $_ );
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# # Check for validity
|
|
Packit Service |
c5cf8c |
# Removed for now - best to use on separate file output
|
|
Packit Service |
c5cf8c |
# if ((!$isThreaded && $thread != 0) || $class < 0) {
|
|
Packit Service |
c5cf8c |
# # These should really be checks for is-int as well
|
|
Packit Service |
c5cf8c |
# next;
|
|
Packit Service |
c5cf8c |
# }
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Discard unwanted ranks
|
|
Packit Service |
c5cf8c |
if ($whichrank >= 0 && ($rank != $whichrank || $world > 0) ) { next; }
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Automatically choose the default filename trim
|
|
Packit Service |
c5cf8c |
if ($filenameTrim eq "default") {
|
|
Packit Service |
c5cf8c |
$filenameTrim = $file;
|
|
Packit Service |
c5cf8c |
$filenameTrim =~ s/(.*\/mpich[^\/]*\/src\/).*/\1/;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if ($filenameTrim ne "" && $file =~ /^$filenameTrim/) {
|
|
Packit Service |
c5cf8c |
$file =~ s/^$filenameTrim//;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Update nesting level
|
|
Packit Service |
c5cf8c |
if ($msg =~ /^Entering (.*)/) {
|
|
Packit Service |
c5cf8c |
$curstate = $1;
|
|
Packit Service |
c5cf8c |
if (defined($elideCall{$curstate})) {
|
|
Packit Service |
c5cf8c |
$inElide = 1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
elsif (!$inElide) {
|
|
Packit Service |
c5cf8c |
$spaces = &indent($nestlevel++) . ">";
|
|
Packit Service |
c5cf8c |
$routineStack[$#routineStack+1] = $curstate;
|
|
Packit Service |
c5cf8c |
$routineTime[$#routineTime+1] = $time;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
elsif ($msg =~ /^Leaving (.*)/) {
|
|
Packit Service |
c5cf8c |
$curstate = $1;
|
|
Packit Service |
c5cf8c |
if ($nestlevel > 0) {
|
|
Packit Service |
c5cf8c |
if (defined($elideCall{$curstate})) {
|
|
Packit Service |
c5cf8c |
$inElide = 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
elsif (!$inElide) {
|
|
Packit Service |
c5cf8c |
$spaces = &indent(--$nestlevel) . "<";
|
|
Packit Service |
c5cf8c |
my $expected = $routineStack[$#routineStack];
|
|
Packit Service |
c5cf8c |
$#routineStack--;
|
|
Packit Service |
c5cf8c |
if ($expected ne $curstate) {
|
|
Packit Service |
c5cf8c |
print STDERR "Expected state $expected but found $curstate\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
# Get the total time in this routine
|
|
Packit Service |
c5cf8c |
$tottime = $time - $routineTime[$#routineTime];
|
|
Packit Service |
c5cf8c |
$#routineTime--;
|
|
Packit Service |
c5cf8c |
# Round totaltime to a few digits
|
|
Packit Service |
c5cf8c |
$tottime = sprintf("%.3g",$tottime);
|
|
Packit Service |
c5cf8c |
$tottime = "($tottime)";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
else {
|
|
Packit Service |
c5cf8c |
if ($onlyRoutine) {
|
|
Packit Service |
c5cf8c |
print STDERR "Malformed line $linecount: $_";
|
|
Packit Service |
c5cf8c |
next;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
$spaces = &indent($nestlevel);
|
|
Packit Service |
c5cf8c |
$extraMsg = $msg;
|
|
Packit Service |
c5cf8c |
$extraMsg =~ s/\r?\n//;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Strip common text off of state
|
|
Packit Service |
c5cf8c |
$curstate =~ s/^MPID_STATE_//;
|
|
Packit Service |
c5cf8c |
$curstate =~ s/\r?\n//g;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (! $inElide) {
|
|
Packit Service |
c5cf8c |
my $baseinfo = $spaces;
|
|
Packit Service |
c5cf8c |
if ($extraMsg ne "") {
|
|
Packit Service |
c5cf8c |
$baseinfo .= $extraMsg;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
else {
|
|
Packit Service |
c5cf8c |
$baseinfo .= $curstate . "$tottime";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
my $location = "$file\[$line\]";
|
|
Packit Service |
c5cf8c |
my $pad = 40 - length($baseinfo);
|
|
Packit Service |
c5cf8c |
for (my $i=0; $i<$pad; $i++) { $baseinfo .= " "; }
|
|
Packit Service |
c5cf8c |
print "$baseinfo $location\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
sub indent {
|
|
Packit Service |
c5cf8c |
my $num = $_[0];
|
|
Packit Service |
c5cf8c |
my $spaces = "";
|
|
Packit Service |
c5cf8c |
for (my $i=0; $i<=$num; $i++) {
|
|
Packit Service |
c5cf8c |
$spaces .= " ";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
return $spaces;
|
|
Packit Service |
c5cf8c |
}
|