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