3ae77bdd2628d03a349897f22a7d7013fa45bf0f
[IRC.git] / Robust / src / Benchmarks / Prefetch / run.sh
1 #!/bin/sh 
2
3 #set -x
4 MACHINES2='dw-9.eecs.uci.edu'
5 MACHINES3='dw-9.eecs.uci.edu dw-7.eecs.uci.edu'
6 MACHINES4='dw-9.eecs.uci.edu dw-7.eecs.uci.edu dw-5.eecs.uci.edu'
7 LOGDIR=/home/adash/research/Robust/src/Benchmarks/Prefetch/runlog
8 TOPDIR=`pwd`
9
10 function run {
11   i=0;
12   DIR=`pwd`
13   while [ $i -lt $1 ]; do
14     echo "$DIR" > ~/.tmpdir
15     echo "bin=$3" > ~/.tmpvars
16     if [ $2 -eq 2 ]; then 
17       arg=$ARGS2
18       MACHINES=$MACHINES2
19     fi
20     if [ $2 -eq 3 ]; then 
21       arg=$ARGS3
22       MACHINES=$MACHINES3
23     fi
24     if [ $2 -eq 4 ]; then 
25       arg=$ARGS4
26       MACHINES=$MACHINES4
27     fi
28     chmod +x ~/.tmpvars
29     for machine in `echo $MACHINES`
30     do
31       ssh ${machine} 'cd `cat ~/.tmpdir`; source ~/.tmpvars; ./$bin' &
32       echo ""
33     done
34     sleep 2
35     /usr/bin/time -f "%e" ./$3 master $arg 2>> ${LOGDIR}/${3}_${EXTENSION}.txt
36     echo "Terminating ... "
37     for machine in `echo $MACHINES`
38     do
39       ssh ${machine} 'source ~/.tmpvars; killall $bin'
40     done
41     sleep 2
42     i=`expr $i + 1`
43   done
44 }
45
46 function oneremote {
47   i=0;
48   DIR=`pwd` 
49   while [ $i -lt $1 ]; do
50     echo "$DIR" > ~/.tmpdir
51     echo "bin=$3" > ~/.tmpvars
52     echo "arg='$ARGS1'" > ~/.tmpargs
53     echo "logd=$LOGDIR" > ~/.tmplogdir
54     echo "ext=$EXTENSION" > ~/.tmpext
55     ./$3 &
56     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'
57     echo "Terminating ... "
58     killall $3
59     sleep 2
60     i=`expr $i + 1`
61   done
62 }
63
64 function localrun {
65   i=0;
66 #while [ $i -lt $1 ]; do
67 #    /usr/bin/time -f "%e" ./${NONPREFETCH} master $ARGS1 2>> ${LOGDIR}/${NONPREFETCH}_local_${EXTENSION}.txt
68 #   sleep 4
69 #   i=`expr $i + 1`
70 # done
71   i=0;
72   while [ $i -lt $1 ]; do
73     /usr/bin/time -f "%e" ./${NONPREFETCH_NONCACHE} master $ARGS1 2>> ${LOGDIR}/${NONPREFETCH_NONCACHE}_local_${EXTENSION}.txt
74     sleep 4
75     i=`expr $i + 1`
76   done
77 }
78
79 function callrun {
80   PREFETCH=${BENCHMARK}1.bin
81   NONPREFETCH=${BENCHMARK}1NP.bin
82   NONPREFETCH_NONCACHE=${BENCHMARK}1NPNC.bin
83   PREFETCH2=${BENCHMARK}2.bin
84   NONPREFETCH2=${BENCHMARK}2NP.bin
85   NONPREFETCH_NONCACHE2=${BENCHMARK}2NPNC.bin
86   PREFETCH3=${BENCHMARK}3.bin
87   NONPREFETCH3=${BENCHMARK}3NP.bin
88   NONPREFETCH_NONCACHE3=${BENCHMARK}3NPNC.bin
89   PREFETCH4=${BENCHMARK}4.bin
90   NONPREFETCH4=${BENCHMARK}4NP.bin
91   NONPREFETCH_NONCACHE4=${BENCHMARK}4NPNC.bin
92   cd $BMDIR 
93
94   echo "---------- Running local $BMDIR non-prefetch on 1 machine ---------- "
95   localrun 3
96
97   echo "---------- Running single thread remote $BMDIR non-prefetch + non-cache on 2 machines ---------- "
98 #  oneremote 1 1 $NONPREFETCH_NONCACHE
99   echo "---------- Running single thread remote $BMDIR non-prefetch on 2 machines ---------- "
100 #  oneremote 1 1 $NONPREFETCH
101   echo "---------- Running single thread remote $BMDIR prefetch on 2 machines ---------- "
102 #  oneremote 1 1 $PREFETCH
103
104   echo "---------- Running two threads $BMDIR non-prefetch + non-cache on 2 machines ---------- "
105   run 3 2 $NONPREFETCH_NONCACHE2 
106   echo "---------- Running two threads $BMDIR non-prefetch on 2 machines ---------- "
107 #  run 3 2 $NONPREFETCH2 
108   echo "---------- Running two threads $BMDIR prefetch on 2 machines ---------- "
109   run 3 2 $PREFETCH2 
110
111   echo "---------- Running three threads $BMDIR non-prefetch + non-cache on 3 machines ---------- "
112   run 3 3 $NONPREFETCH_NONCACHE3 
113   echo "---------- Running three threads $BMDIR non-prefetch on 3 machines ---------- "
114 #  run 3 3 $NONPREFETCH3 
115   echo "---------- Running three threads $BMDIR prefetch on 3 machines ---------- "
116   run 3 3 $PREFETCH3 
117
118   echo "---------- Running four threads $BMDIR non-prefetch + non-cache on 4 machines ---------- "
119   run 3 4 $NONPREFETCH_NONCACHE4 
120   echo "---------- Running four threads $BMDIR non-prefetch on 4 machines ---------- "
121 #  run 3 4 $NONPREFETCH4 
122   echo "---------- Running four threads $BMDIR prefetch on 4 machines ---------- "
123   run 3 4 $PREFETCH4 
124
125   cd $TOPDIR
126 }
127
128 function callmicrorun {
129   PREFETCH=${BENCHMARK}1.bin
130   NONPREFETCH=${BENCHMARK}1NP.bin
131   NONPREFETCH_NONCACHE=${BENCHMARK}1NPNC.bin
132   cd $BMDIR 
133   echo "---------- Running local $BMDIR non-prefetch on 1 machine ---------- "
134 #  localrun 10
135   echo "---------- Running single thread remote $BMDIR non-prefetch + non-cache on 2 machines ---------- "
136   oneremote 10 1 $NONPREFETCH_NONCACHE
137   echo "---------- Running single thread remote $BMDIR non-prefetch on 2 machines ---------- "
138   oneremote 10 1 $NONPREFETCH
139   echo "---------- Running single thread remote $BMDIR prefetch on 2 machines ---------- "
140   oneremote 10 1 $PREFETCH
141   cd $TOPDIR
142 }
143
144 benchmarks='array chase mmver200 mmver600'
145 #benchmarks='em3dver10000100015'
146 #benchmarks='moldynverA'
147 #benchmarks='sorverD' //8000 X 8000 matrix
148
149 echo "---------- Clean old files ---------- "
150 rm runlog/*
151 for b in `echo $benchmarks`
152 do
153   bm=`grep $b bm.txt`
154   BENCHMARK=`echo $bm | cut -f1 -d":"`
155   BMDIR=`echo $bm | cut -f2 -d":"`
156   ARGS1=`echo $bm | cut -f3 -d":"`
157   ARGS2=`echo $bm | cut -f4 -d":"`
158   ARGS3=`echo $bm | cut -f5 -d":"`
159   ARGS4=`echo $bm | cut -f6 -d":"`
160   EXTENSION=`echo $bm | cut -f7 -d":"`
161   name1='array'
162   name2='chase'
163   if [ $b == $name1 ] || [ $b == $name2 ]; then
164   callmicrorun
165   else
166   callrun
167   fi
168 done
169
170 #----------Calulates  the averages ----------- 
171 for file in `ls runlog/*.txt`
172 do
173   echo -n $file >> average.txt
174   cat $file | awk '{sum += $1} END {print " "sum/NR}' >> average.txt
175 done
176 echo "===========" >> average.txt
177 echo "" >> average.txt
178
179 echo "done"