1cb3bd0a5610d6c623c5c4fa0072bba8b3a013da
[IRC.git] / Robust / src / Benchmarks / Prefetch / ManualPrefetch / 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'
6 #benchmarks='10lookup'
7
8 LOGDIR=~/research/Robust/src/Benchmarks/Prefetch/ManualPrefetch/runlog
9 TOPDIR=`pwd`
10
11 function run {
12   i=0;
13   DIR=`pwd`
14   HOSTNAME=`hostname`
15   while [ $i -lt $1 ]; do
16     echo "$DIR" > ~/.tmpdir
17     echo "bin=$3" > ~/.tmpvars
18     ct=0
19     MACHINES=''
20     for j in $MACHINELIST; do
21       if [ $ct -lt $2 ]; then
22         if [ "$j" != "$HOSTNAME" ]; then
23           MACHINES="$MACHINES $j"
24         fi
25       fi
26       let ct=$ct+1
27     done
28
29     rm dstm.conf
30     DSTMDIR=${HOME}/research/Robust/src/Benchmarks/Prefetch/config
31     if [ $2 -eq 2 ]; then 
32       arg=$ARGS2
33       ln -s ${DSTMDIR}/dstm_2.conf dstm.conf
34     fi
35     if [ $2 -eq 3 ]; then 
36       arg=$ARGS3
37       ln -s ${DSTMDIR}/dstm_3.conf dstm.conf
38     fi
39     if [ $2 -eq 4 ]; then 
40       arg=$ARGS4
41       ln -s ${DSTMDIR}/dstm_4.conf dstm.conf
42     fi
43     if [ $2 -eq 5 ]; then 
44       arg=$ARGS5
45       ln -s ${DSTMDIR}/dstm_5.conf dstm.conf
46     fi
47     if [ $2 -eq 6 ]; then 
48       arg=$ARGS6
49       ln -s ${DSTMDIR}/dstm_6.conf dstm.conf
50     fi
51     if [ $2 -eq 7 ]; then 
52       arg=$ARGS7
53       ln -s ${DSTMDIR}/dstm_7.conf dstm.conf
54     fi
55     if [ $2 -eq 8 ]; then 
56       arg=$ARGS8
57       ln -s ${DSTMDIR}/dstm_8.conf dstm.conf
58     fi
59     chmod +x ~/.tmpvars
60     for machine in `echo $MACHINES`
61     do
62       ssh ${machine} 'cd `cat ~/.tmpdir`; source ~/.tmpvars; ./$bin' &
63       echo ""
64     done
65     sleep 2
66     echo ${3}
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 oneremote {
86   i=0;
87   DIR=`pwd` 
88   while [ $i -lt $1 ]; do
89     echo "$DIR" > ~/.tmpdir
90     echo "bin=$3" > ~/.tmpvars
91     echo "arg='$ARGS1'" > ~/.tmpargs
92     echo "logd=$LOGDIR" > ~/.tmplogdir
93     echo "ext=$EXTENSION" > ~/.tmpext
94     ./$3 &
95     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'
96     echo "Terminating ... "
97     killall $3
98     sleep 2
99     i=`expr $i + 1`
100   done
101 }
102
103 function localrun {
104   rm dstm.conf
105   DSTMDIR=${HOME}/research/Robust/src/Benchmarks/Prefetch/config
106   ln -s ${DSTMDIR}/dstm_1.conf dstm.conf
107   i=0;
108   while [ $i -lt $1 ]; do
109     /usr/bin/time -f "%e" ./${MANUAL_PREFETCH} master $ARGS1 2> ${LOGDIR}/tmp
110     cat ${LOGDIR}/tmp >> ${LOGDIR}/${MANUAL_PREFETCH}_local_${EXTENSION}.txt
111 #   if [ $i -eq 0 ];then echo "<h3> Benchmark=${NONPREFETCH_NONCACHE} Thread=1local Extension=${EXTENSION}</h3><br>" > ${LOGDIR}/${NONPREFETCH_NONCACHE}_${EXTENSION}_1local_a.html  ;fi
112 #    cat ${LOGDIR}/tmp >> ${LOGDIR}/${NONPREFETCH_NONCACHE}_${EXTENSION}_1local_a.html
113 #    echo "<br>" >> ${LOGDIR}/${NONPREFETCH_NONCACHE}_${EXTENSION}_1local_a.html
114     sleep 2
115     i=`expr $i + 1`
116   done
117 }
118
119 function callrun {
120   MANUAL_PREFETCH=${BENCHMARK}RangeN.bin
121   
122   cd $BMDIR 
123
124   echo "---------- Running local $BMDIR non-prefetch on 1 machine ---------- "
125   # localrun 1
126
127 for count in 2 4 6 8
128 do
129 echo "------- Running $count threads $BMDIR manual prefetch on $count machines -----"
130 run 1 $count ${MANUAL_PREFETCH}
131 done
132
133 cd $TOPDIR
134 }
135
136
137 #benchmarks='rainforest'
138 benchmarks='moldynverB'
139 echo "---------- Clean old files ---------- "
140 rm runlog/*
141 for b in `echo $benchmarks`
142 do
143   bm=`grep $b bm.txt`
144   BENCHMARK=`echo $bm | cut -f1 -d":"`
145   BMDIR=`echo $bm | cut -f2 -d":"`
146   ARGS1=`echo $bm | cut -f3 -d":"`
147   ARGS2=`echo $bm | cut -f4 -d":"`
148   ARGS3=`echo $bm | cut -f5 -d":"`
149   ARGS4=`echo $bm | cut -f6 -d":"`
150   ARGS5=`echo $bm | cut -f7 -d":"`
151   ARGS6=`echo $bm | cut -f8 -d":"`
152   ARGS7=`echo $bm | cut -f9 -d":"`
153   ARGS8=`echo $bm | cut -f10 -d":"`
154   EXTENSION=`echo $bm | cut -f11 -d":"`
155   callrun
156 done
157
158 #----------Calulates  the averages ----------- 
159 for file in `ls runlog/*.txt`
160 do
161   echo -n $file >> average.txt
162   cat $file | grep -v "^Command" | awk '{sum += $1} END {print " "sum/NR}' >> average.txt
163 done
164 echo "===========" >> average.txt
165 echo "" >> average.txt
166
167 echo "done"