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