-
Notifications
You must be signed in to change notification settings - Fork 1
/
Create-ParaSim
executable file
·120 lines (106 loc) · 3.41 KB
/
Create-ParaSim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
#
# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# T2 SDE: scripts/Create-ParaSim
# Copyright (C) 2004 - 2005 The T2 SDE Project
# Copyright (C) 1998 - 2003 ROCK Linux Project
#
# 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 as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- 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