2 ##############################################################################
3 # Time-stamp: <Wed Jul 24 1996 22:11:13 Stardate: [-31]7859.41 hwloidl>
5 # Usage: gr2ps [options] <gr-file>
7 # Create an overall 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 qp2ps.
10 # The generated PostScript file shows essentially the number of running,
11 # runnable and blocked tasks during the execution of the program.
14 # -o <file> ... write .ps file to <file>
15 # -I <str> ... queues to be displayed (in the given order) with the encoding
16 # 'a' ... active (running)
22 # (e.g. -I "arb" shows active, runnable, blocked tasks)
23 # -i <int> ... info level from 1 to 7; number of queues to display
24 # -m ... create mono PostScript file instead a color one.
25 # -O ... optimise the produced .ps w.r.t. size
26 # NB: With this option info is lost. If there are several values
27 # with same x value only the first one is printed, all
29 # -s <str> ... print <str> in the top right corner of the generated graph
30 # -S ... improved version of sorting events
31 # -l <int> ... length of slice in the .ps file; (default: 100)
32 # small value => less memory consumption of .ps file & script
33 # -d ... Print date instead of average parallelism
34 # -v ... be talkative.
35 # -h ... print help message (this header).
37 ##############################################################################
39 progname="`basename $0`"
55 getopts "hvmDCOHSdl:s:o:i:I:" name
56 while [ "$name" != "?" ] ; do
66 S) improved_sort="-S";;
67 s) string="-s $OPTARG";;
68 l) length="-l $OPTARG";;
69 i) info_level="-i $OPTARG";;
70 I) info_mask="-I $OPTARG";;
73 getopts "hvmDCOHSdl:s:o:i:I:" name
76 opts_qp="$debug $info_level $info_mask $improved_sort "
77 opts_ps="$debug $check $optimise $mono $string $length $info_level $info_mask $force_date $hack "
79 shift $[ $OPTIND - 1 ]
82 then no_of_lines=`cat $0 | awk 'BEGIN { n = 0; } \
86 echo "`head -$no_of_lines $0`"
91 then echo "Usage: $progname [options] file[.gr]"
92 echo "Use -h option for details"
98 qpfile="${TMPDIR:-.}/$f".qp
99 ppfile="${TMPDIR:-.}/$f".pp
106 then echo "Input file: $grfile"
107 echo "Quasi-parallel file: $qpfile"
108 echo "PP file: $ppfile"
109 echo "PostScript file: $psfile"
111 then echo "Producing monochrome PS file"
112 else echo "Producing color PS file"
114 if [ -n "$optimise" ]
115 then echo "Optimisation is ON"
116 else echo "Optimisation is OFF"
119 then echo "Debugging is turned ON"
120 else echo "Debugging is turned OFF"
122 if [ -n "$improved_sort" ]
123 then echo "Improved sort is turned ON"
124 else echo "Improved sort is turned OFF"
127 opts_qp="${opts_qp} $verb_opt "
128 opts_ps="${opts_ps} $verb_opt "
129 echo "Options for gr2qp: ${opts_qp}"
130 echo "Options for qp2ps: ${opts_ps}"
135 if [ ! -f "$grfile" ]
137 echo "$grfile does not exist"
140 rm -f "$qpfile" "$psfile"
141 prog=`head -1 "$grfile" | sed -e 's/Granularity Simulation for //'`
142 echo "$prog" >| "$qpfile"
144 then echo "Executed program: $prog"
147 #date="`date`" # This is the date of running the script
148 date="`tail +2 $grfile | head -1 | sed -e 's/Start time: //'`"
149 cat "$grfile" | gr2qp ${opts_qp} >> "$qpfile"
150 # Sorting is part of gr2qp now.
151 # | ghc-fool-sort | sort -n +0 -1 | ghc-unfool-sort >> "$qpfile"
152 # max=`tail -2 "$qpfile" | awk '!/^Number of threads:/ { print $1; }'`
153 xmax=`tail -1 "$qpfile" | awk '{ print $2; }'`
154 ymax=`tail -1 "$qpfile" | awk '{ print $4; }'`
156 then echo "Total runtime: $xmax"
157 echo "Maximal number of tasks: $ymax"
159 tail +3 "$qpfile" | qp2ps ${opts_ps} "$xmax" "$ymax" "$prog" "$date" >| "$psfile"
162 then echo "Scaling (maybe): ps-scale-y $psfile "