changes
[IRC.git] / Robust / src / Benchmarks / Prefetch / run.sh
1 #!/bin/sh 
2
3 #set -x
4 MACHINELIST='dc-1.calit2.uci.edu dc-2.calit2.uci.edu dc-3.calit2.uci.edu dc-4.calit2.uci.edu dc-5.calit2.uci.edu dc-6.calit2.uci.edu dc-7.calit2.uci.edu dc-8.calit2.uci.edu'
5 #benchmarks='40962dconv 1200mmver moldynverB 1600fft2d 1152fft2d 10lookup rainforest'
6 #benchmarks='40962dconv'
7 #benchmarks='10lookup'
8 #benchmarks='rainforest'
9 #benchmarks='1152fft2d'
10 benchmarks='moldynverC'
11 #benchmarks='40962dconv 1200mmver 1152fft2d moldynverA 10lookup rainforest'
12
13 LOGDIR=~/research/Robust/src/Benchmarks/Prefetch/runlog
14 TOPDIR=`pwd`
15
16 function run {
17   i=0;
18   DIR=`pwd`
19   HOSTNAME=`hostname`
20   while [ $i -lt $1 ]; do
21     echo "$DIR" > ~/.tmpdir
22     echo "bin=$3" > ~/.tmpvars
23     ct=0
24     MACHINES=''
25     for j in $MACHINELIST; do
26       if [ $ct -lt $2 ]; then
27         if [ "$j" != "$HOSTNAME" ]; then
28           MACHINES="$MACHINES $j"
29         fi
30       fi
31       let ct=$ct+1
32     done
33
34     rm dstm.conf
35     DSTMDIR=${HOME}/research/Robust/src/Benchmarks/Prefetch/config
36     if [ $2 -eq 2 ]; then 
37       arg=$ARGS2
38       ln -s ${DSTMDIR}/dstm_2.conf dstm.conf
39     fi
40     if [ $2 -eq 3 ]; then 
41       arg=$ARGS3
42       ln -s ${DSTMDIR}/dstm_3.conf dstm.conf
43     fi
44     if [ $2 -eq 4 ]; then 
45       arg=$ARGS4
46       ln -s ${DSTMDIR}/dstm_4.conf dstm.conf
47     fi
48     if [ $2 -eq 5 ]; then 
49       arg=$ARGS5
50       ln -s ${DSTMDIR}/dstm_5.conf dstm.conf
51     fi
52     if [ $2 -eq 6 ]; then 
53       arg=$ARGS6
54       ln -s ${DSTMDIR}/dstm_6.conf dstm.conf
55     fi
56     if [ $2 -eq 7 ]; then 
57       arg=$ARGS7
58       ln -s ${DSTMDIR}/dstm_7.conf dstm.conf
59     fi
60     if [ $2 -eq 8 ]; then 
61       arg=$ARGS8
62       ln -s ${DSTMDIR}/dstm_8.conf dstm.conf
63     fi
64     chmod +x ~/.tmpvars
65     for machine in `echo $MACHINES`
66     do
67       ssh ${machine} 'cd `cat ~/.tmpdir`; source ~/.tmpvars; ./$bin' &
68       echo ""
69     done
70     sleep 2
71     perl -x${TOPDIR} ${TOPDIR}/switch/fetch_stat.pl clear_stats settings=switch/clearsettings.txt
72     /usr/bin/time -f "%e" ./$3 master $arg 2> ${LOGDIR}/tmp
73     perl -x${TOPDIR} ${TOPDIR}/switch/fetch_stat.pl settings=switch/settings.txt
74     cat ${LOGDIR}/tmp >> ${LOGDIR}/${3}_${2}Thrd_${EXTENSION}.txt
75     if [ $i -eq 0 ];then echo "<h3> Benchmark=${3} Thread=${2} Extension=${EXTENSION}</h3><br>" > ${LOGDIR}/${3}_${EXTENSION}_${2}Thrd_a.html  ;fi
76     cat ${LOGDIR}/tmp >> ${LOGDIR}/${3}_${EXTENSION}_${2}Thrd_a.html
77     echo "<a href=\"${3}_${2}Thrd_${EXTENSION}_${i}.html\">Network Stats</a><br>" >> ${LOGDIR}/${3}_${EXTENSION}_${2}Thrd_a.html
78     mv ${TOPDIR}/html/dell.html ${LOGDIR}/${3}_${2}Thrd_${EXTENSION}_${i}.html
79     echo "Terminating ... "
80     for machine in `echo $MACHINES`
81     do
82       ssh ${machine} 'source ~/.tmpvars; killall $bin'
83     done
84     sleep 2
85     i=`expr $i + 1`
86   done
87 }
88
89 function runallstats {
90   i=0;
91   DIR=`pwd`
92   HOSTNAME=`hostname`
93   while [ $i -lt $1 ]; do
94     echo "$DIR" > ~/.tmpdir
95     echo "bin=$3" > ~/.tmpvars
96     ct=0
97     MACHINES=''
98     for j in $MACHINELIST; do
99       if [ $ct -lt $2 ]; then
100         if [ "$j" != "$HOSTNAME" ]; then
101           MACHINES="$MACHINES $j"
102         fi
103       fi
104       let ct=$ct+1
105     done
106
107     rm dstm.conf
108     DSTMDIR=${HOME}/research/Robust/src/Benchmarks/Prefetch/config
109     if [ $2 -eq 2 ]; then 
110       arg=$ARGS2
111       ln -s ${DSTMDIR}/dstm_2.conf dstm.conf
112     fi
113     if [ $2 -eq 3 ]; then 
114       arg=$ARGS3
115       ln -s ${DSTMDIR}/dstm_3.conf dstm.conf
116     fi
117     if [ $2 -eq 4 ]; then 
118       arg=$ARGS4
119       ln -s ${DSTMDIR}/dstm_4.conf dstm.conf
120     fi
121     if [ $2 -eq 5 ]; then 
122       arg=$ARGS5
123       ln -s ${DSTMDIR}/dstm_5.conf dstm.conf
124     fi
125     if [ $2 -eq 6 ]; then 
126       arg=$ARGS6
127       ln -s ${DSTMDIR}/dstm_6.conf dstm.conf
128     fi
129     if [ $2 -eq 7 ]; then 
130       arg=$ARGS7
131       ln -s ${DSTMDIR}/dstm_7.conf dstm.conf
132     fi
133     if [ $2 -eq 8 ]; then 
134       arg=$ARGS8
135       ln -s ${DSTMDIR}/dstm_8.conf dstm.conf
136     fi
137     chmod +x ~/.tmpvars
138     for machine in `echo $MACHINES`
139     do
140       ssh ${machine} 'cd `cat ~/.tmpdir`; source ~/.tmpvars; ./$bin' &
141       echo ""
142     done
143     sleep 2
144     perl -x${TOPDIR} ${TOPDIR}/switch/fetch_stat.pl clear_stats settings=switch/clearsettings.txt
145     /usr/bin/time -f "%e" ./$3 master $arg 2> ${LOGDIR}/tmp
146     perl -x${TOPDIR} ${TOPDIR}/switch/fetch_stat.pl settings=switch/settings.txt
147     cat ${LOGDIR}/tmp >> ${LOGDIR}/${3}_${2}Thrd_${EXTENSION}.txt
148     if [ $i -eq 0 ];then echo "<h3> Benchmark=${3} Thread=${2} Extension=${EXTENSION}</h3><br>" > ${LOGDIR}/${3}_${EXTENSION}_${2}Thrd_a.html  ;fi
149     cat ${LOGDIR}/tmp >> ${LOGDIR}/${3}_${EXTENSION}_${2}Thrd_a.html
150     echo "<a href=\"${3}_${2}Thrd_${EXTENSION}_${i}.html\">Network Stats</a><br>" >> ${LOGDIR}/${3}_${EXTENSION}_${2}Thrd_a.html
151     mv ${TOPDIR}/html/dell.html ${LOGDIR}/${3}_${2}Thrd_${EXTENSION}_${i}.html
152     echo "Terminating ... "
153     pwd
154     rm client_stats.log
155     HOSTNAME=`hostname`
156     for machine in `echo $MACHINES`
157     do
158       if [ "$machine" != "$HOSTNAME" ]; then
159         ssh ${machine} 'source ~/.tmpvars; binpid=`ps aux | grep $bin | grep -v grep | cut -f2`; kill -USR1 $binpid'
160       fi 
161     done
162     sleep 2
163     i=`expr $i + 1`
164   done
165 }
166
167 function oneremote {
168   i=0;
169   DIR=`pwd` 
170   while [ $i -lt $1 ]; do
171     echo "$DIR" > ~/.tmpdir
172     echo "bin=$3" > ~/.tmpvars
173     echo "arg='$ARGS1'" > ~/.tmpargs
174     echo "logd=$LOGDIR" > ~/.tmplogdir
175     echo "ext=$EXTENSION" > ~/.tmpext
176     ./$3 &
177     ssh $MACHINES2 'cd `cat ~/.tmpdir`; source ~/.tmpvars; source ~/.tmpargs; source ~/.tmplogdir; source ~/.tmpext; /usr/bin/time -f "%e" ./$bin master $arg 2>> ${logd}/${bin}_remote_${ext}.txt'
178     echo "Terminating ... "
179     killall $3
180     sleep 2
181     i=`expr $i + 1`
182   done
183 }
184
185 function localrun {
186   i=0;
187 #while [ $i -lt $1 ]; do
188 #    /usr/bin/time -f "%e" ./${NONPREFETCH} master $ARGS1 2>> ${LOGDIR}/${NONPREFETCH}_local_${EXTENSION}.txt
189 #   sleep 4
190 #   i=`expr $i + 1`
191 # done
192   i=0;
193
194   DSTMDIR=${HOME}/research/Robust/src/Benchmarks/Prefetch/config
195   rm dstm.conf
196   ln -s ${DSTMDIR}/dstm_1.conf dstm.conf
197
198   while [ $i -lt $1 ]; do
199     /usr/bin/time -f "%e" ./${NONPREFETCH_NONCACHE} master $ARGS1 2> ${LOGDIR}/tmp
200     cat ${LOGDIR}/tmp >> ${LOGDIR}/${NONPREFETCH_NONCACHE}_local_${EXTENSION}.txt
201     if [ $i -eq 0 ];then echo "<h3> Benchmark=${NONPREFETCH_NONCACHE} Thread=1local Extension=${EXTENSION}</h3><br>" > ${LOGDIR}/${NONPREFETCH_NONCACHE}_${EXTENSION}_1local_a.html  ;fi
202     cat ${LOGDIR}/tmp >> ${LOGDIR}/${NONPREFETCH_NONCACHE}_${EXTENSION}_1local_a.html
203     echo "<br>" >> ${LOGDIR}/${NONPREFETCH_NONCACHE}_${EXTENSION}_1local_a.html
204     sleep 2
205     i=`expr $i + 1`
206   done
207 }
208
209 function callrun {
210   PREFETCH=${BENCHMARK}N.bin
211   NONPREFETCH=${BENCHMARK}NPC.bin
212   NONPREFETCH_NONCACHE=${BENCHMARK}NPNC.bin
213   MANUAL_PREFETCH=${BENCHMARK}RangeN.bin
214
215   cd $BMDIR 
216
217   echo "---------- Running local $BMDIR non-prefetch on 1 machine ---------- "
218   localrun 1
219
220 #  echo "---------- Running single thread remote $BMDIR non-prefetch + non-cache on 2 machines ---------- "
221 #  oneremote 1 1 $NONPREFETCH_NONCACHE
222 #  echo "---------- Running single thread remote $BMDIR non-prefetch on 2 machines ---------- "
223 #  oneremote 1 1 $NONPREFETCH
224 #  echo "---------- Running single thread remote $BMDIR prefetch on 2 machines ---------- "
225 #  oneremote 1 1 $PREFETCH
226
227
228 for count in 2 4 6 8
229 do
230 echo "------- Running $count threads $BMDIR non-prefetch + non-cache on $count machines -----"
231 run 1 $count $NONPREFETCH_NONCACHE
232 echo "------- Running $count threads $BMDIR non-prefetch on $count machines -----"
233 run 1 $count $NONPREFETCH
234 #echo "------- Running $count threads $BMDIR normal prefetch on $count machines -----"
235 #run 1 $count $PREFETCH
236 echo "------- Running $count threads $BMDIR manual prefetch on $count machines -----"
237 run 1 $count $MANUAL_PREFETCH
238
239 ###########
240 #echo "------- Running $count threads $BMDIR non-prefetch + non-cache on $count machines -----"
241 #runallstats 1 $count $NONPREFETCH_NONCACHE
242 #echo "------- Running $count threads $BMDIR non-prefetch on $count machines -----"
243 #runallstats 1 $count $NONPREFETCH
244 #echo "------- Running $count threads $BMDIR normal prefetch on $count machines -----"
245 #runallstats 1 $count $PREFETCH
246 #echo "------- Running $count threads $BMDIR manual prefetch on $count machines -----"
247 #runallstats 1 $count $MANUAL_PREFETCH
248 #############
249
250 done
251
252 cd $TOPDIR
253 }
254
255 function callrunjavasingle {
256   JAVASINGLE=${BENCHMARK}.bin
257   cd $BMDIR
258   cd ../javasingle
259
260   echo "-----------Running javasingle for ${BENCHMARK} version ${EXTENSION} on 1 machines ------------"
261   javasinglerun 1
262   cd $TOPDIR
263 }
264
265 function javasinglerun {
266   i=0;
267   while [ $i -lt $1 ]; do
268     /usr/bin/time -f "%e" ./${BENCHMARK}.bin $ARGS1 2> ${LOGDIR}/tmp
269     cat ${LOGDIR}/tmp >> ${LOGDIR}/${BENCHMARK}_javasingle_${EXTENSION}.txt
270     if [ $i -eq 0 ];then echo "<h3> Benchmark=${BENCHMARK} Thread=1java Extension=${EXTENSION}</h3><br>" > ${LOGDIR}/${BENCHMARK}_${EXTENSION}_1java_a.html  ;fi
271     cat ${LOGDIR}/tmp >> ${LOGDIR}/${BENCHMARK}_${EXTENSION}_1java_a.html
272     echo "<br>" >> ${LOGDIR}/${BENCHMARK}_${EXTENSION}_1java_a.html
273     sleep 2
274     i=`expr $i + 1`
275   done
276 }
277
278 function callmicrorun {
279   PREFETCH=${BENCHMARK}1.bin
280   NONPREFETCH=${BENCHMARK}1NP.bin
281   NONPREFETCH_NONCACHE=${BENCHMARK}1NPNC.bin
282   cd $BMDIR 
283   echo "---------- Running local $BMDIR non-prefetch on 1 machine ---------- "
284 #  localrun 10
285   echo "---------- Running single thread remote $BMDIR non-prefetch + non-cache on 2 machines ---------- "
286   oneremote 10 1 $NONPREFETCH_NONCACHE
287   echo "---------- Running single thread remote $BMDIR non-prefetch on 2 machines ---------- "
288   oneremote 10 1 $NONPREFETCH
289   echo "---------- Running single thread remote $BMDIR prefetch on 2 machines ---------- "
290   oneremote 10 1 $PREFETCH
291   cd $TOPDIR
292 }
293
294
295 echo "---------- Clean old files ---------- "
296 rm runlog/*
297 for b in `echo $benchmarks`
298 do
299   bm=`grep $b bm.txt`
300   BENCHMARK=`echo $bm | cut -f1 -d":"`
301   BMDIR=`echo $bm | cut -f2 -d":"`
302   ARGS1=`echo $bm | cut -f3 -d":"`
303   ARGS2=`echo $bm | cut -f4 -d":"`
304   ARGS3=`echo $bm | cut -f5 -d":"`
305   ARGS4=`echo $bm | cut -f6 -d":"`
306   ARGS5=`echo $bm | cut -f7 -d":"`
307   ARGS6=`echo $bm | cut -f8 -d":"`
308   ARGS7=`echo $bm | cut -f9 -d":"`
309   ARGS8=`echo $bm | cut -f10 -d":"`
310   EXTENSION=`echo $bm | cut -f11 -d":"`
311   name1='array'
312   name2='chase'
313   if [ $b == $name1 ] || [ $b == $name2 ]; then
314   callmicrorun
315   else
316   callrun
317   callrunjavasingle
318   fi
319 done
320
321 #----------Calulates  the averages ----------- 
322 for file in `ls runlog/*.txt`
323 do
324   echo -n $file >> average.txt
325   cat $file | grep -v "^Command" | awk '{sum += $1} END {print " "sum/NR}' >> average.txt
326 done
327 echo "===========" >> average.txt
328 echo "" >> average.txt
329
330 echo "done"