root/trunk/src/bps

Revision 1, 9.1 kB (checked in by root, 3 years ago)

initial import

  • Property svn:executable set to
Line 
1 #!/bin/bash
2
3 # bps.sh   Command-line version of bps
4
5 #Check environment variables
6
7 [ -n "$DEBUG" ] && set -vx
8 if [ -z "$BPS_RSH" ]
9 then
10  rsh_method=rsh
11 else
12  rsh_method=$BPS_RSH
13 fi
14 if [ -z "$BPS_RCP" ]
15 then
16  rcp_method=rcp
17 else
18  rcp_method=$BPS_RCP
19 fi
20
21 # defines
22 Version="BPS 1.4"
23 MachineData=machine.data
24 BonnieLog=bonnie.log
25 NetperfLog=netperf.log
26 NetpipeLog=netpipe.log
27 NetpipeData=netpipe.data
28 NpbLog=npb.log
29 StreamLog=stream.log
30 UnixbenchLog=unixbench.log
31 LMLog=lmbench.log
32
33 #prints log header
34
35 headerstart() {
36         printf "[ start $* - `date` ]\n"
37 }
38
39 #prints log footer
40
41 headerend()   {
42         printf "[ end   $* - `date` ]\n"
43 }
44
45 #help function
46 show_ver() {
47         echo $Version
48 }
49 show_help() {
50         printf "Usage: $0 <OPTIONS>\n\n"
51         printf "Options:\n"
52         printf "  -b <file system>              bonnie++\n"
53         printf "  -s                            stream\n"
54         printf "  -f <send node>,<receive node> netperf to remote node\n"
55         printf "  -p <send node>,<receive node> netpipe to remote node\n"
56         printf "  -n <compiler>,<#processors),  NAS parallel benchmarks\n"
57         printf "     <test size>,<MPI>,         compiler={gnu/gnu4/pgi/intel/path}\n"
58         printf "     <machine1,machine2,...>    test size={A,B,C,dummy}\n"
59         printf "                                MPI={lam,mpich,mpichgm,mpich2,ompi,dummy}\n"
60         printf "  -k                            keep NAS directory when finished\n"
61         printf "  -u                            unixbench\n"
62         printf "  -m                            lmbench\n"
63         printf "  -l <log_dir>                  benchmark log directory\n"
64         printf "  -w                            preserve existing log directory\n"
65         printf "  -i <mboard manufacturer>,     machine information\n"
66         printf "     <mboard model>,<memory>,\n"
67         printf "     <interconnect>,<linux ver>\n"
68         printf "  -v                            show version\n"
69         printf "  -h                            show this help\n"
70         printf "\n"
71         exit 1
72 }
73
74 # the actual benchmark running functions
75 run_bonnie() {
76         headerstart bonnie
77         $BPSDIR/bin/bonnie++  -d $Bonnie_opt
78         headerend bonnie
79 }
80 run_netperf() {
81         local port
82         node1=`printf "$*" | cut -d, -f1`
83         node2=`printf "$*" | cut -d, -f2`
84         uid=`whoami`
85         declare -i port
86         port=$[1024+$$]
87         #clean up any stray jobs on both nodes
88         $rsh_method -n $node1 killall netserver "&>" /dev/null
89         $rsh_method -n $node2 killall netserver "&>" /dev/null
90         $rsh_method -n $node1 killall netperf "&>" /dev/null
91         $rsh_method -n $node2 killall netperf "&>" /dev/null
92         #Copy binaries to users bps-log directory (should be in /home)
93         $rsh_method -n $node1 "mkdir -p /tmp/${uid}"
94         /bin/cp  "$BPSDIR/bin/netperf" $Logdir
95         /bin/cp  "$BPSDIR/bin/netserver" $Logdir
96         echo "starting remote netserver on '$node2' with port $port to receive from '$node1'"
97         $rsh_method -n $node2 $Logdir/netserver -p $port "&>" /dev/null "&"
98         sleep 2
99         headerstart netperf
100         $rsh_method -n $node1 $Logdir/netperf -p $port -t UDP_STREAM -n 2 -l 60 -H $node2 -- -s 65535 -m 1472
101         $rsh_method -n $node1 $Logdir/netperf -p $port -t TCP_STREAM -n 2 -l 60 -H $node2
102         headerend netperf
103         #cleanup
104         /bin/rm $Logdir/netserver
105         /bin/rm $Logdir/netperf
106         $rsh_method -n $node1 killall netperf "&>" /dev/null
107         $rsh_method -n $node2 killall netserver "&>" /dev/null
108 }
109 run_netpipe() {
110         node1=`printf "$*" | cut -d, -f1`
111         node2=`printf "$*" | cut -d, -f2`
112         uid=`whoami`
113         #clean up any stray jobs on both nodes
114         $rsh_method -n $node1 killall NPtcp "&>" /dev/null
115         $rsh_method -n $node2 killall NPtcp "&>" /dev/null
116         #Copy binaries incase the do not exist on host
117         /bin/cp  "$BPSDIR/bin/NPtcp" $Logdir
118        
119         #start the receiver
120         $rsh_method -n $node2 "$Logdir/NPtcp -r &> /dev/null &"
121         echo "starting NPtcp receiver on '$node2' to receive from '$node1'"
122         headerstart netpipe
123         #$rsh_method -n $node1 touch /tmp/${uid}/${NetpipeData} "&>" /dev/null
124         #start the sender
125         $rsh_method -n $node1 "$Logdir/NPtcp -t -h $node2 -P -o $Logdir/${NetpipeData}"
126         headerend netpipe
127         # cleanup
128         $rsh_method -n $node2 killall NPtcp "&>" /dev/null
129         $rsh_method -n $node1 killall NPtcp "&>" /dev/null
130         /bin/rm $Logdir/NPtcp
131 }
132 run_npb() {
133         compiler=`printf "$*" | cut -d, -f1`
134         numproc=`printf "$*" | cut -d, -f2`
135         testsize=`printf "$*" | cut -d, -f3`
136         mpi=`printf "$*" | cut -d, -f4`
137         headerstart NAS
138         echo "Compiler: $compiler Processors: $numproc Size: $testsize MPI: $mpi"
139         cd $Logdir/npb
140         echo "Running: ./run_suite -c $compiler -n $numproc -t $testsize -m $mpi"
141         ./run_suite -c $compiler -n $numproc -t $testsize -m $mpi
142         cat  $Logdir/npb/results/npb.$compiler.$mpi.$testsize.$numproc
143         headerend NAS
144 }
145 run_stream() {
146         headerstart stream
147         $BPSDIR/bin/stream-wall
148         headerend stream
149 }
150 run_lmbench() {
151         headerstart lmbench
152         cd /tmp/$username/LMbench
153         ./lmexpect &> /dev/null
154         cd results
155         make summary-html  2>/dev/null
156         make clean &>/dev/null
157         headerend lmbench
158 }
159
160 run_unixbench() {
161         headerstart unixbench
162         /tmp/$username/unixbench/Run
163         headerend unixbench
164 }
165
166 #check directory settings
167
168 if [ -z "$BPSDIR" ]
169 then
170         if [ -d /opt/bps ]
171         then
172                 BPSDIR=/opt/bps
173         else
174                 printf "Error: No BPSDIR environment variable set and bps.sh  not found in\n       /opt/bps.\n       Please set this to the location of the bps root directory.\n"
175                 exit 1
176         fi
177 fi
178
179 #check our options
180 declare -i optnum=0
181 declare -i NoOverwrite=0
182 while getopts "msn:kp:f:l:b:uwhvi:" opt
183 do
184     let optnum=optnum+1
185         case $opt in
186                 s) Stream=1 ;;
187                 n) Npb=1 ; Npb_opts=$OPTARG;;
188                 p) Netpipe=1 ; Netpipe_opts=$OPTARG ;;
189                 f) Netperf=1 ; Netperf_opts=$OPTARG ;;
190                 b) Bonnie=1 ; Bonnie_opt=$OPTARG;;
191                 l) Logdir=$OPTARG ; [ $Logdir != "/" ] && Logdir=${OPTARG%%/} ;;
192                 k) KeepNAS=1 ;;
193                 u) Unixbench=1 ;;
194                 m) lmbench=1 ;;
195                 w) NoOverwrite=1 ;;
196                 i) Information=1 ; Info_opts=$OPTARG ;;
197                 h) show_help ; exit 0;;
198                 v) show_ver ; exit 0;;
199                 \?) show_help; exit 1;;
200         esac
201 done
202
203 #check user id
204 username=`whoami`
205 #[ $username = "root" ] && echo "NOTE: BPS Can not be run as root" && show_help && exit
206 [ $OPTIND -eq 1 ] && show_help #no options specified... give some assistance
207 [ $optnum -eq 1 ] && [ $NoOverwrite -eq 1 ] && show_help #-w specified but nothing else
208 [ $optnum -eq 1 ] && [ -n "$Logdir" ] && show_help
209 if [ -z "$Logdir" ]
210 then
211         if [ -z "$BPSLOGDIR" ]
212         then
213                 printf "Logdir defaulting to ~/bps-logs\n"
214                 Logdir=~/bps-logs
215         else
216                 Logdir=$BPSLOGDIR
217         fi
218 else
219         if [ -e $Logdir ] && [ ! -w $Logdir ]
220         then
221                 printf "No write permission on ${Logdir}\n"
222                 exit 1
223         fi
224 fi
225
226 # if the logdir exists make a backup (only if user specifies with -w)
227 if [ $NoOverwrite -eq 1 ]
228 then
229         if [ -e $Logdir ]
230         then
231                 if [ $Logdir = $HOME ]
232                 then
233                         printf "$HOME is your home directory, it can not be backed up\n"
234                         exit 1
235                 elif [ $Logdir = "/" ]
236                 then
237                         printf "Root directory can not be backed up\n"
238                         exit 1
239                 else
240                         printf "$Logdir exists... backed up to ${Logdir}.`date '+%s'`\n"
241                         [ -e ${Logdir}.bbench.bak ] && rm -rf ${Logdir}.bbench.bak
242                         mv -f $Logdir ${Logdir}.`date '+%s'`
243                         mkdir $Logdir &> /dev/null
244                 fi
245         else
246                 mkdir $Logdir &> /dev/null
247         fi
248 else
249  mkdir $Logdir &> /dev/null
250 fi
251 printf "Note: $Logdir must be mounted on all nodes (i.e. under /home)\n"
252 #create machinedata file for reference
253 uname -a > ${Logdir}/${MachineData}
254 grep "model name" /proc/cpuinfo >> ${Logdir}/${MachineData}
255 grep "cpu MHz" /proc/cpuinfo >> ${Logdir}/${MachineData}
256 [ -n "$Information" ] && $(echo $Info_opts | (IFS=',';read A B C D E;echo -e "Motherboard Manufacturer: ${A}\nMotherboard Model: ${B}\nMemory: ${C}\nInterconnects: ${D}\nLinux Version: ${E}">> ${Logdir}/${MachineData}))
257
258
259
260 # run the benchmarks
261
262 if [ -n "$lmbench" ]
263 then
264         echo "Running LMBench..."
265         mkdir -p /tmp/$username
266         cp -r $BPSDIR/src/lmbench-2.0-patch1.tgz /tmp/$username
267         cd /tmp/$username
268         tar -xzf /tmp/$username/lmbench-2.0-patch1.tgz
269         run_lmbench &> ${Logdir}/${LMLog}
270         rm -rf /tmp/$username
271 fi
272 [ -n "$Bonnie" ] && echo "Running Bonnie++..." && run_bonnie &> ${Logdir}/${BonnieLog}
273 if [ -n "$Netperf" ]
274 then
275         echo "Running Netperf..."
276         run_netperf $Netperf_opts &> ${Logdir}/${NetperfLog}
277         rm -f /tmp/netperf.debug
278 fi
279
280 [ -n "$Netpipe" ] && echo "Running Netpipe..." && run_netpipe $Netpipe_opts &> ${Logdir}/${NetpipeLog}
281
282 if [ -n "$Npb" ]
283 then
284         echo "Running NAS Parallel Benchmarks..."
285         A=`printf "$Npb_opts" | cut -d, -f1`
286         B=`printf "$Npb_opts" | cut -d, -f2`
287         C=`printf "$Npb_opts" | cut -d, -f3`
288         D=`printf "$Npb_opts" | cut -d, -f4`
289         machines=`printf "$Npb_opts" | cut -d, -f5-`
290         username=`whoami`
291         tar -C $Logdir -xzf $BPSDIR/src/npb.tar.gz
292         echo $machines | sed -f /$BPSDIR/bin/sedscr > $Logdir/npb/cluster/machines
293         run_npb $Npb_opts &> $Logdir/npb.$A.$D.$C.$B
294         if [ ! -n "$KeepNAS" ]
295         then
296                 rm -rf $Logdir/npb
297         fi
298 fi
299
300 [ -n "$Stream" ] && echo "Running Stream..." && run_stream &> ${Logdir}/${StreamLog}
301
302 if [ -n "$Unixbench" ]
303 then
304         echo "Running Unixbench..."
305         username=`whoami`
306         mkdir -p /tmp/$username
307         cp $BPSDIR/src/unixbench.tar.gz /tmp/$username
308         cd /tmp/$username
309         tar -xzf /tmp/$username/unixbench.tar.gz
310         cd /tmp/$username/unixbench
311         run_unixbench &> ${Logdir}/${UnixbenchLog} 
312         cp /tmp/$username/unixbench/results/report $Logdir/unixbench.report
313         rm -rf /tmp/$username
314 fi
315
316 #if [ -n "$Xbench" ]
317 #then
318 #       echo
319 #       echo " --> 'xhost localhost' must be set by root."
320 #       echo " --> Your screen will go blank while the test is running"
321 #       echo " --> Press Return when ready"
322 #       read
323 #       echo "Running Xbench..."
324 #       run_xbench &> ${Logdir}/${XbenchLog}
325 #       run_xbench_post
326 #fi
Note: See TracBrowser for help on using the browser.