Brian's changes to manual prefetching for array and chase
[IRC.git] / Robust / src / Benchmarks / Distributed / runjava.sh
1 #!/bin/sh 
2 BASEDIR=`pwd`
3 LOGDIR=${BASEDIR}
4 DSTM_CONFDIR=${HOME}/research/Robust/src
5 JAVA_DIR=java
6 JVM_DIR=jvm
7 DSM_DIR=dsm
8 ITERATIONS=2
9 TOPDIR=${HOME}/research/Robust/src/Prefetch
10
11 function killclients {
12   i=1;
13   while [ $i -le $1 ]; do
14     ssh dc-${i}.calit2.uci.edu 'killall Client.bin;'
15     i=`expr $i + 1`
16   done
17 }
18
19 function runjava {
20   # Run java version
21   echo "Running java version"
22   j=1;
23   BM_DIR=${BM_NAME}/${JAVA_DIR}
24   while [ $j -le $ITERATIONS ]; do
25    echo "Running on $1 machines ... "
26    # Start the server
27    cd ${BM_DIR}
28    suffix=$SERVER_ARGS | tr -d ' '
29    echo "Running Server ... "
30    /usr/bin/time -f "%e" ./Server.bin -N $1 $SERVER_ARGS 2>> ${LOGDIR}/server_${1}_${BM_NAME}_java.out &
31    # Start the clients
32    k=1;
33    echo ${BASEDIR}/${BM_DIR} > ~/.tmpdir
34    perl -x${TOPDIR} ${TOPDIR}/switch/fetch_stat.pl clear_stats settings=switch/clearsettings.txt
35    while [ $k -le $1 ]; do
36      echo "SSH into dc-${k}"
37      SEED=`expr $k \* 100`
38      echo "SEED='$SEED'" > ~/.seed
39      if [ $k -eq $1 ];
40      then
41        ssh dc-${k}.calit2.uci.edu 'cd `cat ~/.tmpdir`; source ~/.bmargs; ./Client.bin $CLIENT_ARGS -seed `hostname | cut -f2 -d"-" | cut -f1 -d"."`'
42      else
43        ssh dc-${k}.calit2.uci.edu 'cd `cat ~/.tmpdir`; source ~/.bmargs; ./Client.bin $CLIENT_ARGS -seed  `hostname | cut -f2 -d"-" | cut -f1 -d"."`' &
44      fi
45      k=`expr $k + 1`
46    done
47    killclients $k
48    sleep 10;
49    perl -x${TOPDIR} ${TOPDIR}/switch/fetch_stat.pl settings=switch/settings.txt
50    cat ${LOGDIR}/tmp >> ${LOGDIR}/${BM_NAME}_${1}Thrd.txt
51    if [ $i -eq 0 ];then echo "<h3> Benchmark=${BM_NAME} Thread=${1}</h3><br>" > ${LOGDIR}/${BM_NAME}_${1}Thrd_a.html  ;fi
52    cat ${LOGDIR}/tmp >> ${LOGDIR}/${BM_NAME}_${1}Thrd_a.html
53    echo "<a href=\"${BM_NAME}_${1}Thrd_${j}.html\">Network Stats</a><br>" >> ${LOGDIR}/${BM_NAME}_${1}Thrd_a.html
54    mv ${TOPDIR}/html/dell.html ${LOGDIR}/${BM_NAME}_${1}Thrd_${j}.html
55
56    j=`expr $j + 1`
57    cd -
58   done
59 }
60
61 function runjvm {
62   # Run java version
63   echo "Running jvm version"
64   j=1;
65   BM_DIR=${BM_NAME}/${JVM_DIR}
66   while [ $j -le $ITERATIONS ]; do
67    echo "Running on $1 machines ... "
68    # Start the server
69    cd ${BM_DIR}
70    suffix=$SERVER_ARGS | tr -d ' '
71    echo "Running Server ... "
72    /usr/bin/time -f "%e" java $JVM_SERVER_CLASS -N $1 $SERVER_ARGS 2>> ${LOGDIR}/server_${1}_${BM_NAME}_jvm.out &
73    # Start the clients
74    k=1;
75    echo ${BASEDIR}/${BM_DIR} > ~/.tmpdir
76    while [ $k -le $1 ]; do
77      echo "SSH into dc-${k}"
78      seed=`expr $k * 100`
79      if [ $k -eq $1 ];
80      then
81        ssh dc-${k}.calit2.uci.edu 'cd `cat ~/.tmpdir`; source ~/.bmargs; java $JVM_CLIENT_CLASS $CLIENT_ARGS -seed $seed'
82      else
83        ssh dc-${k}.calit2.uci.edu 'cd `cat ~/.tmpdir`; source ~/.bmargs; java $JVM_CLIENT_CLASS $CLIENT_ARGS -seed $seed' &
84      fi
85      k=`expr $k + 1`
86    done
87    sleep 20;
88    j=`expr $j + 1`
89    cd -
90   done
91 }
92
93 function calcavg {
94   for file in `ls ${LOGDIR}/*.out`
95   do
96     echo -n $file
97     cat $file | awk '{sum += $1} END {print " "sum/NR}'
98   done
99 }
100
101 exec < bm_args.txt
102 while read line
103 do
104   BM_NAME=`echo $line | cut -f1 -d":"`
105   SERVER_ARGS=`echo $line | cut -f2 -d":"`
106   CLIENT_ARGS=`echo $line | cut -f3 -d":"`
107   JVM_SERVER_CLASS=`echo $line | cut -f4 -d":"`
108   JVM_CLIENT_CLASS=`echo $line | cut -f5 -d":"`
109
110   # Setup for remote machine
111   echo "" > ~/.bmargs
112   echo "BM_NAME='$BM_NAME'"  > ~/.bmargs
113   echo "SERVER_ARGS='$SERVER_ARGS'" >> ~/.bmargs
114   echo "CLIENT_ARGS='$CLIENT_ARGS'" >> ~/.bmargs
115   echo "JVM_SERVER_CLASS='$JVM_SERVER_CLASS'" >> ~/.bmargs
116   echo "JVM_CLIENT_CLASS='$JVM_CLIENT_CLASS'" >> ~/.bmargs
117   NUM_MACHINES=$1
118   runjava $NUM_MACHINES
119   #runjvm $NUM_MACHINES
120   # Cleanup
121   rm ~/.bmargs
122   rm ~/.tmpdir
123 done
124
125 echo "------- Calculating Averages -------- "
126 calcavg