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