2
##############################################################################
3
# Time-stamp: <Wed Jul 24 1996 20:53:36 Stardate: [-31]7859.14 hwloidl>
5
# Usage: gr2ap [options] <gr-file>
7
# Create a per-thread activity graph from a GrAnSim (or GUM) profile.
8
# Transform the log file of a GrAnSim run (a .gr file) into a quasi-parallel
9
# profile (a .qp file) using gr2qp and then into a PostScript file using qp2ap.
10
# The generated PostScript file shows one horizontal line for each task. The
11
# thickness of the line indicates the state of the thread:
12
# thick ... active, medium ... suspended, thin ... fetching remote data
15
# -o <file> ... write .ps file to <file>
16
# -m ... create mono PostScript file instead a color one.
17
# -O ... optimise i.e. try to minimise the size of the .ps file.
18
# -v ... be talkative.
19
# -h ... print help message (this header).
21
##############################################################################
23
progname="`basename $0`"
34
getopts "hvmo:s:w:OD" name
35
while [ "$name" != "?" ] ; do
41
s) scale="-s $OPTARG";;
42
w) width="-w $OPTARG";;
46
getopts "hvmo:s:w:OD" name
49
opts="$mono $optimise $scale $width"
51
shift $[ $OPTIND - 1 ]
54
then no_of_lines=`cat $0 | awk 'BEGIN { n = 0; } \
58
echo "`head -$no_of_lines $0`"
64
then echo "Usage: $progname [options] file[.gr]"
65
echo "Use -h option for details"
71
qpfile="${TMPDIR:-.}/$f".qp
72
ppfile="${TMPDIR:-.}/$f".pp
75
then apfile="$f"_ap.ps
79
then echo "Input file: $grfile"
80
echo "Quasi-parallel file: $qpfile"
81
echo "PostScript file: $apfile"
82
echo "Options forwarded to qp2ap: $opts"
84
then echo "Producing monochrome PS file"
85
else echo "Producing color PS file"
87
if [ "$debug" = "-D" ]
88
then echo "Debugging is turned ON"
89
else echo "Debugging is turned OFF"
98
echo "$grfile does not exist"
101
# rm -f "$qpfile" "$apfile"
102
prog=`head -1 "$grfile" | sed -e 's/Granularity Simulation for //'`
103
echo "$prog" >| "$qpfile"
105
then echo "Executed program: $prog"
108
#date="`date`" # This is the date of running the script
109
date="`tail +2 $grfile | head -1 | sed -e 's/Start time: //'`"
110
cat "$grfile" | gr2qp >> "$qpfile"
111
# Sorting is part of gr2qp now.
112
# | ghc-fool-sort | sort -n +0 -1 | ghc-unfool-sort >> "$qpfile"
113
# max=`tail -2 "$qpfile" | awk '!/^Number of threads:/ { print $1; }'`
114
xmax=`tail -1 "$qpfile" | awk '{ print $2; }'`
115
ymax=`tail -1 "$qpfile" | awk '{ print $8; }'`
117
then echo "Total runtime: $xmax"
118
echo "Total number of tasks: $ymax"
120
tail +3 "$qpfile" | qp2ap $opts "$xmax" "$ymax" "$prog" "$date" >| "$apfile"
122
# Old: qp2ap.pl $mono $max "$prog" "$date" < "$qpfile" > "$apfile"