blob: 7818fe112b6a58ad3bab670791831ef8d108baf2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#!/usr/local/bin/bash
##############################################################################
# Time-stamp: <Wed Jul 24 1996 20:53:36 Stardate: [-31]7859.14 hwloidl>
#
# Usage: gr2ap [options] <gr-file>
#
# Create a per-thread activity graph from a GrAnSim (or GUM) profile.
# Transform the log file of a GrAnSim run (a .gr file) into a quasi-parallel
# profile (a .qp file) using gr2qp and then into a PostScript file using qp2ap.
# The generated PostScript file shows one horizontal line for each task. The
# thickness of the line indicates the state of the thread:
# thick ... active, medium ... suspended, thin ... fetching remote data
#
# Options:
# -o <file> ... write .ps file to <file>
# -m ... create mono PostScript file instead a color one.
# -O ... optimise i.e. try to minimise the size of the .ps file.
# -v ... be talkative.
# -h ... print help message (this header).
#
##############################################################################
progname="`basename $0`"
args="$*"
verb=0
help=0
mono=""
apfile=""
optimise=""
scale=""
width=""
getopts "hvmo:s:w:OD" name
while [ "$name" != "?" ] ; do
case $name in
h) help=1;;
v) verb=1;;
m) mono="-m";;
o) apfile="$OPTARG";;
s) scale="-s $OPTARG";;
w) width="-w $OPTARG";;
O) optimise="-O";;
D) debug="-D";;
esac
getopts "hvmo:s:w:OD" name
done
opts="$mono $optimise $scale $width"
shift $[ $OPTIND - 1 ]
if [ $help -eq 1 ]
then no_of_lines=`cat $0 | awk 'BEGIN { n = 0; } \
/^$/ { print n; \
exit; } \
{ n++; }'`
echo "`head -$no_of_lines $0`"
exit
fi
if [ -z "$1" ]
then echo "Usage: $progname [options] file[.gr]"
echo "Use -h option for details"
exit 1;
fi
f="`basename $1 .gr`"
grfile="$f".gr
qpfile="${TMPDIR:-.}/$f".qp
ppfile="${TMPDIR:-.}/$f".pp
if [ -z "$apfile" ]
then apfile="$f"_ap.ps
fi
if [ $verb -eq 1 ]
then echo "Input file: $grfile"
echo "Quasi-parallel file: $qpfile"
echo "PostScript file: $apfile"
echo "Options forwarded to qp2ap: $opts"
if [ "$mono" = "-m" ]
then echo "Producing monochrome PS file"
else echo "Producing color PS file"
fi
if [ "$debug" = "-D" ]
then echo "Debugging is turned ON"
else echo "Debugging is turned OFF"
fi
fi
# unset noclobber
if [ ! -f "$grfile" ]
then
echo "$grfile does not exist"
exit 1
else
# rm -f "$qpfile" "$apfile"
prog=`head -1 "$grfile" | sed -e 's/Granularity Simulation for //'`
echo "$prog" >| "$qpfile"
if [ $verb -eq 1 ]
then echo "Executed program: $prog"
fi
date >> "$qpfile"
#date="`date`" # This is the date of running the script
date="`tail +2 $grfile | head -1 | sed -e 's/Start time: //'`"
cat "$grfile" | gr2qp >> "$qpfile"
# Sorting is part of gr2qp now.
# | ghc-fool-sort | sort -n +0 -1 | ghc-unfool-sort >> "$qpfile"
# max=`tail -2 "$qpfile" | awk '!/^Number of threads:/ { print $1; }'`
xmax=`tail -1 "$qpfile" | awk '{ print $2; }'`
ymax=`tail -1 "$qpfile" | awk '{ print $8; }'`
if [ $verb -eq 1 ]
then echo "Total runtime: $xmax"
echo "Total number of tasks: $ymax"
fi
tail +3 "$qpfile" | qp2ap $opts "$xmax" "$ymax" "$prog" "$date" >| "$apfile"
rm -f "$qpfile"
# Old: qp2ap.pl $mono $max "$prog" "$date" < "$qpfile" > "$apfile"
fi
|