-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmarkthis.sh
executable file
·80 lines (68 loc) · 1.95 KB
/
benchmarkthis.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
set -ueox pipefail
times=5
queue="hall-lab"
jobname="benchmark"
hostname=""
setup=""
teardown=""
while getopts ":n:q:J:m:p:e:" opt; do
case $opt in
n)
echo "Running command $OPTARG times" >&2
times=$OPTARG
;;
q)
echo "Using queue $OPTARG" >&2
queue=$OPTARG
;;
J)
echo "Using job name base $OPTARG" >&2
jobname=$OPTARG
;;
m)
echo "Submitting to host $OPTARG" >&2
hostname=$OPTARG
;;
p)
echo "Pre-running setup script $OPTARG" >&2
setup=$OPTARG
;;
e)
echo "Post-running teardown script $OPTARG" >&2
teardown=$OPTARG
;;
\?)
echo "Unknown option -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument" >&2
exit 1
;;
esac
done
if [ $hostname == '' ]; then
echo "Must specify a hostname with -m" >&2
exit 1
fi
# Remove all processed arguments
shift $((OPTIND-1))
cmd=${@}
processors=`bhosts -w $hostname | sed 's/\s\+/ /g' | grep -v MAX | cut -f4`
echo "Requesting $processors processors on $hostname" >&2
initial_dep=""
if [ "$setup" != "" ]; then
bsub -N -u [email protected] -n $processors -q $queue -m "$hostname" -J ${jobname}.pre bash $setup
initial_dep=" -w done($jobname.pre)"
fi
#bsub initial job
bsub -N -u [email protected] -n $processors -q $queue -m "$hostname" -J ${jobname}.1 $initial_dep $cmd
for ((i=2;i<=times;i++)); do
prev=$((i - 1))
bsub -N -u [email protected] -n $processors -q $queue -m "$hostname" -J $jobname.$i -w "done($jobname.$prev)" $cmd
done
if [ "$teardown" != "" ]; then
bsub -N -u [email protected] -n $processors -q $queue -m "$hostname" -J ${jobname}.post -w "done($jobname.$times)" bash $teardown
fi
exit 0