#!/usr/bin/env bash # # --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: scripts/Create-ParaSim # Copyright (C) 2004 - 2023 The T2 SDE Project # Copyright (C) 1998 - 2003 ROCK Linux Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2. # --- T2-COPYRIGHT-NOTE-END --- config=default jobs="" x11=0 while [ "$1" ]; do case "$1" in -cfg) config=$2; shift; shift ;; -jobs) jobs=$2 ; shift; shift ;; -x11) x11=1 ; shift ;; *) echo "Usage: $0 [ -cfg config ] [ -x11 ]" \ "[ -jobs 1,4,8 ]" exit 1 ;; esac done . scripts/parse-config dir=src.parasim.$(cksum config/$config/packages | cut -f1 -d' ') echo "Building parasim in $dir" if [ "$jobs" ]; then maxjobs=0 for x in $(echo $jobs | tr , ' '); do [ $maxjobs -lt $x ] && maxjobs=$x if [ ! -f "$dir/parasim_$x.dat" ]; then rm -rf $dir/logs_$x perl scripts/parasim2.pl $dir $config $x else echo "Using cached data in $dir/parasim_$x.dat" fi done { jobstotal=$(echo `wc -l < $dir/parasim_$maxjobs.dat`) echo 'set data style lines' echo 'set title "T2 Parallel Build' \ 'Simulation ('$jobstotal' Jobs Total)"' echo 'set xlabel "Hours (on reference hardware)"' echo 'set ylabel "Parallel Jobs"' echo "plot [0:*] [0:$(($maxjobs + 1))] \\" next="" for x in $(echo $jobs | tr , ' '); do tm=$(tail -n 1 $dir/parasim_$x.dat | cut -f1 | awk -F. '{ printf("%02d:%02d\n", $1, 60*("0." $2)); }') echo -en "$next"; next=', \\\n' echo -n " \"parasim_$x.dat\" title \"Build with" \ "$x parallel jobs ($tm)\" with steps lw 3" done } > $dir/parasim_$jobs.gnuplot cmd="perl scripts/parasim3.pl" for x in $(echo $jobs | tr , ' ') do cmd="$cmd $dir/parasim_$x.dat"; done eval "$cmd" > $dir/parasim_$jobs.txt if [ "$x11" = 1 ]; then cd $dir; gnuplot -persist parasim_$jobs.gnuplot else cat $dir/parasim_$jobs.txt fi exit fi mkdir -p $dir/logs if [ ! -f $dir/parasim.dat ]; then echo -n "Simulation running" rm -rf $dir/logs $dir/parasim.new mkdir -p $dir/logs while scripts/Create-PkgQueue -cfg $config \ -logdir $dir/logs | sort -r -n -k2 > $dir/queue.txt [ -s $dir/queue.txt ] do next="`head -n 1 $dir/queue.txt`"; set $next qid="$1-$6"; touch $dir/logs/$qid.log printf "%5d %5d %-30s %s\n" $(wc -l < $dir/queue.txt) \ $2 $qid "$(cut -f1,7 -d' ' $dir/queue.txt | tail -n +2 | tr '\n ' ' -')" >> $dir/parasim.new echo -n . done mv $dir/parasim.new $dir/parasim.dat echo else echo "Using cached data in $dir/parasim.dat" fi jobstotal=$(echo `wc -l < $dir/parasim.dat`) cat > $dir/parasim.gnuplot <<- EOT set title "T2 Parallel Build Simulation ($jobstotal Jobs Total)" set xlabel "Number of Jobs build so far" set ylabel "Possible Parallel Jobs" plot 'parasim.dat' using 1 title "Parallel Jobs" with steps lw 3 EOT perl scripts/parasim1.pl $dir/parasim.dat 0 > $dir/parasim.txt if [ "$x11" = 1 ]; then cd $dir; gnuplot -persist parasim.gnuplot else cat $dir/parasim.txt fi