c17cfbae2da701d4b9f00a3bad76ec3cc5235def
[IRC.git] / Robust / src / Benchmarks / Prefetch / MicroBenchmarks / runmicro.sh
1 #!/bin/sh 
2
3 #set -x
4 MACHINES2='dw-11.eecs.uci.edu'
5 MACHINES3='dw-11.eecs.uci.edu dw-12.eecs.uci.edu'
6 MACHINES4='dw-11.eecs.uci.edu dw-12.eecs.uci.edu dw-13.eecs.uci.edu'
7 MACHINES5='dw-11.eecs.uci.edu dw-12.eecs.uci.edu dw-13.eecs.uci.edu dw-14.eecs.uci.edu'
8 LOGDIR=/home/adash/research/Robust/src/Benchmarks/Prefetch/runlog
9 TOPDIR=`pwd`
10
11 function run {
12   i=0;
13   DIR=`pwd`
14   while [ $i -lt $1 ]; do
15     echo "$DIR" > ~/.tmpdir
16     echo "bin=$3" > ~/.tmpvars
17     if [ $2 -eq 2 ]; then 
18       arg=$ARGS2
19       MACHINES=$MACHINES2
20     fi
21     if [ $2 -eq 3 ]; then 
22       arg=$ARGS3
23       MACHINES=$MACHINES3
24     fi
25     if [ $2 -eq 4 ]; then 
26       arg=$ARGS4
27       MACHINES=$MACHINES4
28     fi
29     if [ $2 -eq 5 ]; then 
30       arg=$ARGS5
31       MACHINES=$MACHINES5
32     fi
33     chmod +x ~/.tmpvars
34     for machine in `echo $MACHINES`
35     do
36       ssh ${machine} 'cd `cat ~/.tmpdir`; source ~/.tmpvars; ./$bin' &
37       echo ""
38     done
39     sleep 2
40     /usr/bin/time -f "%e" ./$3 master $arg 2>> ${LOGDIR}/${3}.txt
41     echo "Terminating ... "
42     for machine in `echo $MACHINES`
43     do
44       ssh ${machine} 'source ~/.tmpvars; killall $bin'
45     done
46     sleep 2
47     i=`expr $i + 1`
48   done
49 }
50
51 function localrun {
52   i=0;
53   while [ $i -lt $1 ]; do
54     /usr/bin/time -f "%e" ./${NONPREFETCH} master $ARGS1 2>> ${LOGDIR}/${NONPREFETCH}_local.txt
55     sleep 4
56     i=`expr $i + 1`
57   done
58 }
59
60 function callrun {
61   NONPREFETCH=${BENCHMARK}1NP.bin
62   NONPREFETCH2=${BENCHMARK}2NP.bin
63   NONPREFETCH3=${BENCHMARK}3NP.bin
64   NONPREFETCH4=${BENCHMARK}4NP.bin
65   NONPREFETCH5=${BENCHMARK}5NP.bin
66
67   echo "---------- Running ${BENCHMARK} local non-prefetch on 1 machine ---------- "
68   localrun 1
69
70   echo "---------- Running ${BENCHMARK} two threads non-prefetch on 2 machines ---------- "
71   run 1 2 $NONPREFETCH2 
72   echo "---------- Running ${BENCHMARK} three threads non-prefetch on 3 machines ---------- "
73   run 1 3 $NONPREFETCH3 
74   echo "---------- Running ${BENCHMARK} four threads non-prefetch on 4 machines ---------- "
75   run 1 4 $NONPREFETCH4 
76   echo "---------- Running ${BENCHMARK} five threads non-prefetch on 5 machines ---------- "
77   run 1 5 $NONPREFETCH5 
78
79   cd $TOPDIR
80 }
81
82 benchmarks='rarray rao warray wao'
83
84 echo "---------- Clean old files ---------- "
85 rm ../runlog/*
86 for b in `echo $benchmarks`
87 do
88   bm=`grep $b bm.txt`
89   BENCHMARK=`echo $bm | cut -f1 -d":"`
90   ARGS1=`echo $bm | cut -f2 -d":"`
91   ARGS2=`echo $bm | cut -f3 -d":"`
92   ARGS3=`echo $bm | cut -f4 -d":"`
93   ARGS4=`echo $bm | cut -f5 -d":"`
94   ARGS5=`echo $bm | cut -f6 -d":"`
95   EXTENSION=`echo $bm | cut -f7 -d":"`
96   callrun
97 done
98
99 #----------Calulates  the averages ----------- 
100 for file in `ls ../runlog/*.txt`
101 do
102   echo -n $file >> average.txt
103   cat $file | awk '{sum += $1} END {print " "sum/NR}' >> average.txt
104 done
105 echo "===========" >> average.txt
106 echo "" >> average.txt
107
108 echo "done"