* updated kmime (21.12.1 -> 21.12.2), untested
[t2-trunk.git] / scripts / Create-ParaSim
blob15aa20c598d8a6d5d0da1273163403eff566ff82
1 #!/bin/bash
3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # This copyright note is auto-generated by scripts/Create-CopyPatch.
5 #
6 # T2 SDE: scripts/Create-ParaSim
7 # Copyright (C) 2004 - 2021 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 ROCK Linux Project
9 #
10 # More information can be found in the files COPYING and README.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; version 2 of the License. A copy of the
15 # GNU General Public License can be found in the file COPYING.
16 # --- T2-COPYRIGHT-NOTE-END ---
18 config=default
19 jobs=""; x11=0
21 while [ "$1" ]; do
22 case "$1" in
23 -cfg) config=$2; shift; shift ;;
24 -jobs) jobs=$2 ; shift; shift ;;
25 -x11) x11=1 ; shift ;;
26 *) echo "Usage: $0 [ -cfg config ] [ -x11 ]" \
27 "[ -jobs 1,4,8 ]"
28 exit 1 ;;
29 esac
30 done
32 . scripts/parse-config
34 dir=src.parasim.$(cksum config/$config/packages | cut -f1 -d' ')
35 echo "Building parasim in $dir"
37 if [ "$jobs" ]; then
38 maxjobs=0
39 for x in $( echo $jobs | tr , ' ' ); do
40 [ $maxjobs -lt $x ] && maxjobs=$x
41 if [ ! -f "$dir/parasim_$x.dat" ]; then
42 rm -rf $dir/logs_$x
43 perl scripts/parasim2.pl $dir $config $x
44 else
45 echo "Using cached data in $dir/parasim_$x.dat"
47 done
49 jobstotal=$( echo `wc -l < $dir/parasim_$maxjobs.dat` )
50 echo 'set data style lines'
51 echo 'set title "T2 Parallel Build' \
52 'Simulation ('$jobstotal' Jobs Total)"'
53 echo 'set xlabel "Hours (on reference hardware)"'
54 echo 'set ylabel "Parallel Jobs"'
55 echo "plot [0:*] [0:$(( $maxjobs + 1 ))] \\"
56 next=""
57 for x in $( echo $jobs | tr , ' ' ); do
58 tm=$( tail -n 1 $dir/parasim_$x.dat | cut -f1 | \
59 awk -F. '{ printf("%02d:%02d\n",
60 $1, 60*("0." $2)); }' )
61 echo -en "$next"; next=', \\\n'
62 echo -n " \"parasim_$x.dat\" title \"Build with" \
63 "$x parallel jobs ($tm)\" with steps lw 3"
64 done
65 } > $dir/parasim_$jobs.gnuplot
67 cmd="perl scripts/parasim3.pl"
68 for x in $( echo $jobs | tr , ' ' )
69 do cmd="$cmd $dir/parasim_$x.dat"; done
70 eval "$cmd" > $dir/parasim_$jobs.txt
72 if [ "$x11" = 1 ]; then
73 cd $dir; gnuplot -persist parasim_$jobs.gnuplot
74 else
75 cat $dir/parasim_$jobs.txt
77 exit
80 mkdir -p $dir/logs
82 if [ ! -f $dir/parasim.dat ]; then
83 echo -n "Simulation running"
84 rm -rf $dir/logs $dir/parasim.new
85 mkdir -p $dir/logs
86 while
87 scripts/Create-PkgQueue -cfg $config \
88 -logdir $dir/logs | sort -r -n -k2 > $dir/queue.txt
89 [ -s $dir/queue.txt ]
91 next="`head -n 1 $dir/queue.txt`"; set $next
92 qid="$1-$6"; touch $dir/logs/$qid.log
94 printf "%5d %5d %-30s %s\n" $(wc -l < $dir/queue.txt) \
95 $2 $qid "$( cut -f1,7 -d' ' $dir/queue.txt | \
96 tail -n +2 | tr '\n ' ' -' )" >> $dir/parasim.new
98 echo -n .
99 done
100 mv $dir/parasim.new $dir/parasim.dat
101 echo
102 else
103 echo "Using cached data in $dir/parasim.dat"
106 jobstotal=$( echo `wc -l < $dir/parasim.dat` )
107 cat > $dir/parasim.gnuplot <<- EOT
108 set title "T2 Parallel Build Simulation ($jobstotal Jobs Total)"
109 set xlabel "Number of Jobs build so far"
110 set ylabel "Possible Parallel Jobs"
111 plot 'parasim.dat' using 1 title "Parallel Jobs" with steps lw 3
114 perl scripts/parasim1.pl $dir/parasim.dat 0 > $dir/parasim.txt
116 if [ "$x11" = 1 ]; then
117 cd $dir; gnuplot -persist parasim.gnuplot
118 else
119 cat $dir/parasim.txt