| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 | #!/bin/sh# StarPU --- Runtime system for heterogeneous multicore architectures.## Copyright (C) 2010-2020  Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria## StarPU is free software; you can redistribute it and/or modify# it under the terms of the GNU Lesser General Public License as published by# the Free Software Foundation; either version 2.1 of the License, or (at# your option) any later version.## StarPU is distributed in the hope that it will be useful, but# WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.## See the GNU Lesser General Public License in COPYING.LGPL for more details.#PROGNAME=$0usage(){    echo "Offline tool to display the activity of the workers during the execution."    echo ""    echo "  The starpu_fxt_tool utility now generates a file named 'activity.data' which"    echo "  can be processed by this script to generate a plot named activity.eps"    echo ""    echo "  Typical usage:"    echo "     ./starpu_fxt_tool -i /tmp/prof_file_foo"    echo "     $PROGNAME activity.data"    echo ""    echo "Options:"    echo "	-h, --help          display this help and exit"    echo "	-v, --version       output version information and exit"    echo ""    echo "Report bugs to <@PACKAGE_BUGREPORT@>"    exit 0}if [ "$1" = "-v" ] || [ "$1" = "--version" ] ; then    echo "$PROGNAME (@PACKAGE_NAME@) @PACKAGE_VERSION@"    exit 0fiif [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "" ] ; then    usagefiif [ ! -f $1 ] ; then    echo "Error. File <$1> not found"    echo ""    usagefi# The input file must be generated by the starpu_fxt_tool commandinputfile_with_counters=$1# We extract the counters out of the input fileinputfile=.$inputfile_with_counters.activityinputfile_cnt_ready=.$1.cnt_readyinputfile_cnt_submitted=.$1.cnt_submittedset_profiling_list=.$1.set_profiling_listnames=.$1.namesgrep "^set_profiling" $inputfile_with_counters > $set_profiling_listgrep "0$" $set_profiling_list | cut -f 2 | sort -n > $set_profiling_list.disablegrep "1$" $set_profiling_list | cut -f 2 | sort -n > $set_profiling_list.enablegrep "^name" $inputfile_with_counters > $namesgrep -v "^cnt" $inputfile_with_counters | grep -v "^set_profiling" | grep -v "^name" > $inputfilegrep "^cnt_ready" $inputfile_with_counters > $inputfile_cnt_readygrep "^cnt_submitted" $inputfile_with_counters > $inputfile_cnt_submitted# Count the number of workers in the traceworkers=`cut -f1 $inputfile | sort -n | uniq`nworkers=`cut -f1 $inputfile | sort -n | uniq|wc -l`# size of the entire graphwidth=1.5heigth=0.40total_heigth=$(echo "$heigth + ($heigth * $nworkers)"|bc -l)# In case 3 arguments are provided, the 2nd (resp. 3rd) indicates the start# (resp. the end) of the interval to be displayed.if [ $# -ge 3 ]; thenstarttime=$2endtime=$3else#if profiling is explicitely enabled (resp. disabled) at some point, we set the# default start (rest. end) point when we enable (resp. disable) profiling for# the first time.profiling_enable_cnt=`wc -l $set_profiling_list.enable|sed -e "s/\(.*\) .*/\1/"`if [ $profiling_enable_cnt -ge 1 ]; thenstarttime=`head -1 $set_profiling_list.enable`elsestarttime=$(cut -f 2 $inputfile |sort -n|head -1)fi# TODO test if last disable > first enableprofiling_disable_cnt=$(wc -l $set_profiling_list.disable|sed -e "s/\(.*\) .*/\1/")if [ $profiling_disable_cnt -ge 1 ]; thenendtime=`tail -1 $set_profiling_list.disable`elseendtime=$(cut -f 2 $inputfile |sort -n|tail -1)fi# The values in the file are in ms, we display secondsstarttime=$(echo "$starttime * 0.001 "| bc -l)endtime=$(echo "$endtime * 0.001 "| bc -l)fiecho "START $starttime END $endtime"# Gnuplot headercat > gnuplotcmd << EOFset term postscript eps enhanced colorset output "activity.eps"set xrange [$starttime:$endtime]set size $width,$total_heigthset multiplot;set origin 0.0,0.0;set size $width,$heigth;set logscale yplot "$inputfile_cnt_submitted" using (\$2/1000):3 with filledcurves lt rgb "#999999" title "submitted",\	"$inputfile_cnt_ready" using (\$2/1000):3 with filledcurves lt rgb "#000000" title "ready"set nologscale yEOFcnt=0for worker in $workersdo	grep "^$worker\s" $inputfile > .tmp.$worker	starty=$(echo "$heigth + ($heigth * $cnt)"|bc -l)cat >> gnuplotcmd << EOFset origin 0.0,$starty;set size $width,$heigth;set key offset yrange [0:100]set ylabel "$(cut -f2- $names |grep "^$worker$" | cut -f2)"plot ".tmp.$worker" using (\$2/1000):(100) with filledcurves y1=0.0 lt rgb "#000000" notitle,\	 ".tmp.$worker" using (\$2/1000):((100*(\$4+\$5))/\$3) with filledcurves y1=0.0 lt rgb "#ff0000" notitle,\	 ".tmp.$worker" using (\$2/1000):((100*\$4)/\$3) with filledcurves y1=0.0 lt rgb "#00ff00" notitleEOF	cnt=$(($cnt+1))	donecat >> gnuplotcmd << EOFunset multiplotEOFgnuplot < gnuplotcmdrm gnuplotcmdrm $inputfilerm $inputfile_cnt_readyrm $inputfile_cnt_submittedrm $set_profiling_listrm $set_profiling_list.enablerm $set_profiling_list.disable#rm $namesfor worker in $workersdo	rm .tmp.$workerdone
 |