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