1dc316e40a6b914f36452a9e6dfc8609632ec12a
[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 40962dconv 2048mmver moldynverC 2500fft2d 10lookup 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     for machine in `echo $MACHINES`
133     do
134       ssh ${machine} 'cd `cat ~/.tmpdir`; source ~/.tmpvars; /usr/bin/time -f "%e" ./$bin 2>> ./clienttime_`hostname | cut -f1 -d"."`.txt' &
135       echo ""
136     done
137     sleep 2
138     perl -x${TOPDIR} ${TOPDIR}/switch/fetch_stat.pl clear_stats settings=switch/clearsettings.txt
139     /usr/bin/time -f "%e" ./$3 master $arg 2> ${LOGDIR}/tmp
140     perl -x${TOPDIR} ${TOPDIR}/switch/fetch_stat.pl settings=switch/settings.txt
141     cat ${LOGDIR}/tmp >> ${LOGDIR}/${3}_${2}Thrd_${EXTENSION}.txt
142     if [ $i -eq 0 ];then echo "<h3> Benchmark=${3} Thread=${2} Extension=${EXTENSION}</h3><br>" > ${LOGDIR}/${3}_${EXTENSION}_${2}Thrd_a.html  ;fi
143     cat ${LOGDIR}/tmp >> ${LOGDIR}/${3}_${EXTENSION}_${2}Thrd_a.html
144     echo "<a href=\"${3}_${2}Thrd_${EXTENSION}_${i}.html\">Network Stats</a><br>" >> ${LOGDIR}/${3}_${EXTENSION}_${2}Thrd_a.html
145     mv ${TOPDIR}/html/dell.html ${LOGDIR}/${3}_${2}Thrd_${EXTENSION}_${i}.html
146     echo "Terminating ... "
147     HOSTNAME=`hostname`
148     for machine in `echo $MACHINES`
149     do
150       if [ "$machine" != "$HOSTNAME" ]; then
151         ssh ${machine} '~/research/Robust/src/Benchmarks/Prefetch/killallclients.sh'
152         #ssh ${machine} 'source ~/.tmpvars; binpid=`ps aux | grep $bin | grep time | sed 's/[     ]./:/g' | sed 's/::/:/g' | cut -f2 -d":"`;kill -USR1 $binpid'
153       fi 
154     done
155     sleep 2
156     i=`expr $i + 1`
157   done
158 }
159
160 function oneremote {
161   i=0;
162   DIR=`pwd` 
163
164   DSTMDIR=${HOME}/research/Robust/src/Benchmarks/Prefetch/config
165   rm dstm.conf
166   ln -s ${DSTMDIR}/dstm_2.conf dstm.conf
167
168   while [ $i -lt $1 ]; do
169     echo "$DIR" > ~/.tmpdir
170     echo "bin=$3" > ~/.tmpvars
171     echo "arg='$ARGS1'" > ~/.tmpargs
172     echo "logd=$LOGDIR" > ~/.tmplogdir
173     echo "ext=$EXTENSION" > ~/.tmpext
174     ./$3 &
175     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'
176     echo "Terminating ... "
177     killall $3
178     sleep 2
179     i=`expr $i + 1`
180   done
181 }
182
183 function localrun {
184   i=0;
185
186   DSTMDIR=${HOME}/research/Robust/src/Benchmarks/Prefetch/config
187   rm dstm.conf
188   ln -s ${DSTMDIR}/dstm_1.conf dstm.conf
189
190   while [ $i -lt $1 ]; do
191     /usr/bin/time -f "%e" ./${NONPREFETCH_NONCACHE} master $ARGS1 2> ${LOGDIR}/tmp
192     cat ${LOGDIR}/tmp >> ${LOGDIR}/${NONPREFETCH_NONCACHE}_local_${EXTENSION}.txt
193     if [ $i -eq 0 ];then echo "<h3> Benchmark=${NONPREFETCH_NONCACHE} Thread=1local Extension=${EXTENSION}</h3><br>" > ${LOGDIR}/${NONPREFETCH_NONCACHE}_${EXTENSION}_1local_a.html  ;fi
194     cat ${LOGDIR}/tmp >> ${LOGDIR}/${NONPREFETCH_NONCACHE}_${EXTENSION}_1local_a.html
195     echo "<br>" >> ${LOGDIR}/${NONPREFETCH_NONCACHE}_${EXTENSION}_1local_a.html
196     sleep 2
197     i=`expr $i + 1`
198   done
199 }
200
201 function callrun {
202   PREFETCH=${BENCHMARK}N.bin
203   NONPREFETCH=${BENCHMARK}NPC.bin
204   NONPREFETCH_NONCACHE=${BENCHMARK}NPNC.bin
205   MANUAL_PREFETCH=${BENCHMARK}RangeN.bin
206
207   cd $BMDIR 
208
209   echo "---------- Running local $BMDIR non-prefetch on 1 machine ---------- "
210   localrun 10
211
212 #  echo "---------- Running single thread remote $BMDIR non-prefetch + non-cache on 2 machines ---------- "
213 #  oneremote 1 1 $NONPREFETCH_NONCACHE
214 #  echo "---------- Running single thread remote $BMDIR non-prefetch on 2 machines ---------- "
215 #  oneremote 1 1 $NONPREFETCH
216 #  echo "---------- Running single thread remote $BMDIR prefetch on 2 machines ---------- "
217 #  oneremote 1 1 $PREFETCH
218
219
220 for count in 2 4 8
221 do
222 echo "------- Running $count threads $BMDIR non-prefetch + non-cache on $count machines -----"
223 run 10 $count $NONPREFETCH_NONCACHE
224 echo "------- Running $count threads $BMDIR non-prefetch on $count machines -----"
225 run 10 $count $NONPREFETCH
226 #echo "------- Running $count threads $BMDIR normal prefetch on $count machines -----"
227 #run 1 $count $PREFETCH
228 echo "------- Running $count threads $BMDIR manual prefetch on $count machines -----"
229 run 10 $count $MANUAL_PREFETCH
230
231 ###########
232 #echo "------- Running $count threads $BMDIR non-prefetch + non-cache on $count machines -----"
233 #runallstats 1 $count $NONPREFETCH_NONCACHE
234 #echo "------- Running $count threads $BMDIR non-prefetch on $count machines -----"
235 #runallstats 1 $count $NONPREFETCH
236 #echo "------- Running $count threads $BMDIR normal prefetch on $count machines -----"
237 #runallstats 1 $count $PREFETCH
238 #echo "------- Running $count threads $BMDIR manual prefetch on $count machines -----"
239 #runallstats 1 $count $MANUAL_PREFETCH
240 #############
241
242 done
243
244 cd $TOPDIR
245 }
246
247 function callrunjavasingle {
248   JAVASINGLE=${BENCHMARK}.bin
249   cd $BMDIR
250   cd ../javasingle
251
252   echo "-----------Running javasingle for ${BENCHMARK} version ${EXTENSION} on 1 machines ------------"
253   javasinglerun 10
254   cd $TOPDIR
255 }
256
257 function javasinglerun {
258   i=0;
259   while [ $i -lt $1 ]; do
260     /usr/bin/time -f "%e" ./${BENCHMARK}.bin $ARGS1 2> ${LOGDIR}/tmp
261     cat ${LOGDIR}/tmp >> ${LOGDIR}/${BENCHMARK}_javasingle_${EXTENSION}.txt
262     if [ $i -eq 0 ];then echo "<h3> Benchmark=${BENCHMARK} Thread=1java Extension=${EXTENSION}</h3><br>" > ${LOGDIR}/${BENCHMARK}_${EXTENSION}_1java_a.html  ;fi
263     cat ${LOGDIR}/tmp >> ${LOGDIR}/${BENCHMARK}_${EXTENSION}_1java_a.html
264     echo "<br>" >> ${LOGDIR}/${BENCHMARK}_${EXTENSION}_1java_a.html
265     sleep 2
266     i=`expr $i + 1`
267   done
268 }
269
270 function callmicrorun {
271   PREFETCH=${BENCHMARK}N.bin
272   NONPREFETCH=${BENCHMARK}NPC.bin
273   NONPREFETCH_NONCACHE=${BENCHMARK}NPNC.bin
274   MANUAL_PREFETCH=${BENCHMARK}RangeN.bin
275
276   cd $BMDIR 
277   echo "---------- Running local $BMDIR non-prefetch on 1 machine ---------- "
278   localrun 1
279   echo "---------- Running single thread remote $BMDIR non-prefetch + non-cache on 2 machines ---------- "
280   oneremote 10 1 $NONPREFETCH_NONCACHE
281   echo "---------- Running single thread remote $BMDIR non-prefetch on 2 machines ---------- "
282   oneremote 10 1 $NONPREFETCH
283 # echo "---------- Running single thread remote $BMDIR prefetch on 2 machines ---------- "
284 # oneremote 10 1 $PREFETCH
285   echo "------- Running $count threads $BMDIR manual prefetch on $count machines -----"
286   oneremote 1 1 $MANUAL_PREFETCH
287   cd $TOPDIR
288 }
289
290
291 echo "---------- Clean old files ---------- "
292 rm runlog/*
293 for b in `echo $benchmarks`
294 do
295   bm=`grep $b bm.txt`
296   BENCHMARK=`echo $bm | cut -f1 -d":"`
297   BMDIR=`echo $bm | cut -f2 -d":"`
298   ARGS1=`echo $bm | cut -f3 -d":"`
299   ARGS2=`echo $bm | cut -f4 -d":"`
300   ARGS3=`echo $bm | cut -f5 -d":"`
301   ARGS4=`echo $bm | cut -f6 -d":"`
302   ARGS5=`echo $bm | cut -f7 -d":"`
303   ARGS6=`echo $bm | cut -f8 -d":"`
304   ARGS7=`echo $bm | cut -f9 -d":"`
305   ARGS8=`echo $bm | cut -f10 -d":"`
306   EXTENSION=`echo $bm | cut -f11 -d":"`
307   name1='array'
308   name2='chase'
309   if [ $b == $name1 ] || [ $b == $name2 ]; then
310   callmicrorun
311   else
312   callrun
313   callrunjavasingle
314   fi
315 done
316
317 #----------Calulates  the averages ----------- 
318 for file in `ls runlog/*.txt`
319 do
320   echo -n $file >> average.txt
321   cat $file | grep -v "^Command" | awk '{sum += $1} END {print " "sum/NR}' >> average.txt
322 done
323 echo "===========" >> average.txt
324 echo "" >> average.txt
325
326 echo "done"