2 ##############################################################################
4 # Usage: gr2ps [options] <gr-file>
6 # Transform the log file of a GrAnSim run (a .gr file) into a quasi-parallel
7 # profile (a .qp file) and then into a PostScript file, showing essentially
8 # the total number of running, runnable and blocked tasks.
11 # -o <file> ... write PS file to <file>
12 # -i <int> ... info level from 1 to 7; number of queues to display
13 # -m ... create mono PostScript file instead a color one.
14 # -O ... optimize the produced .ps w.r.t. size
15 # NB: With this option info is lost. If there are several values
16 # with same x value only the first one is printed, all
18 # -s <str> ... print <str> in the top right corner of the generated graph
19 # -v ... be talkative.
20 # -h ... print help message (this header).
22 ##############################################################################
24 ##############################################################################
26 # ----------------------------------------------------------------------
27 # This version works on both Suns and Alphas -- KH
28 # Any volunteers to convert it to /bin/sh?
29 # Next time somebody calls for volunteers I'd better keep my mouth shut ... HWL
30 ##############################################################################
32 progname="`basename $0`"
45 getopts "hvmDOSs:o:i:I:" name
46 while [ "$name" != "?" ] ; do
55 i) info_level=$OPTARG;;
56 I) info_mask=$OPTARG;;
59 getopts "hvmDOSs:o:i:I:" name
62 shift $[ $OPTIND - 1 ]
65 then echo "usage: $progname [-m] file[.gr]"
79 then no_of_lines=`cat $0 | awk 'BEGIN { n = 0; } \
83 echo "`head -$no_of_lines $0`"
88 then echo "Input file: $grfile"
89 echo "Quasi-parallel file: $qpfile"
90 echo "PP file: $ppfile"
91 echo "PostScript file: $psfile"
93 then echo "Producing monochrome PS file"
94 else echo "Producing color PS file"
96 if [ "$optimize" = "-O" ]
97 then echo "Optimization is ON"
98 else echo "Optimization is OFF"
100 if [ "$debug" = "-D" ]
101 then echo "Debugging is turned ON"
102 else echo "Debugging is turned OFF"
108 if [ ! -f "$grfile" ]
110 echo "$grfile does not exist"
113 rm -f "$qpfile" "$psfile"
114 prog=`head -1 "$grfile" | sed -e 's/Granularity Simulation for //'`
115 echo "$prog" >| "$qpfile"
116 if [ $verb -eq 1 ]; then echo "Executed program: $prog"; fi
119 cat "$grfile" | gr2qp | ghc-fool-sort | sort -n +0 -1 | ghc-unfool-sort >> "$qpfile"
120 # max=`tail -2 "$qpfile" | awk '!/^Number of threads:/ { print $1; }'`
121 max=`tail -1 "$qpfile" | awk '{ print $1; }'`
122 if [ $verb -eq 1 ]; then echo "Total runtime: $max"; fi
124 if [ $info_level -gt 0 ]
125 then opts="-i $info_level";
127 if [ -n "$info_mask" ]
128 then opts="-I $info_mask";
130 tail +3 "$qpfile" | qp2ps $debug $optimize $mono $lines "-s" "$string" $opts "$max" "$prog" "$date" >| "$psfile"