-
Notifications
You must be signed in to change notification settings - Fork 8
/
master-ctrl-slaves.sh
142 lines (114 loc) · 4.87 KB
/
master-ctrl-slaves.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
SSH_OPTIONS="-o ConnectTimeout=5 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -q"
SSH_KEY_PRIV="rsa.key"
BENCHMARK_TEST="sample"
function configure_hosts {
echo "* Configuring hosts:"
for host in `cat hosts-list.txt`
do
echo -n "${host} ... "
echo -n "config-push "
scp ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} slave-cmds.sh cpuinfo benchmark-sample.R benchmark-urbanek.R benchmark-revolution.R benchmark-gcbd.R root@${host}:/root
ret=$?
if [ $ret -ne 0 ] ; then
echo "error $ret"; continue
fi
echo -n "cpuinfo-chmod "
ssh ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host} 'chmod +x cpuinfo'
ret=$?
if [ $ret -ne 0 ] ; then
echo "error $ret"; continue
fi
echo "config-run "
{ ssh ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host} 'bash slave-cmds.sh mro_install netlib_install atlas_st_install openblas_install atlas_mt_install gotoblas2_install mkl_install blis_install cublas_install > install.log 2>&1' ;
scp ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host}:/root/install.log install-${host}.log;
scp ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host}:/root/host-info.log host-info-${host}.log;
echo "${host} finished" ; } &
done
while true
do
runningjobs=$(jobs -rp | wc -l)
if [ $runningjobs -eq 0 ] ; then
break
fi
curtim=`date +"%T"`
echo "* [$curtim] Waiting for $runningjobs hosts..."
sleep 5
done
echo "* All hosts configured"
}
function power_off {
echo "* Power-off hosts:"
for host in `cat hosts-list.txt`
do
echo -n "${host} ... "
echo "power off "
ssh ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host} 'poweroff'
done
echo "* Done"
}
function benchmark {
echo "* Benchmark: ${BENCHMARK_TEST}"
for host in `cat hosts-list.txt`
do
echo -n "${host} ... "
echo "benchmark-run "
{ ssh ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host} "bash slave-cmds.sh test_${BENCHMARK_TEST} netlib_check atlas_st_check openblas_check atlas_mt_check gotoblas2_check mkl_check blis_check cublas_check > test-${BENCHMARK_TEST}.log 2>&1" ;
scp ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host}:/root/test-${BENCHMARK_TEST}.log test-${BENCHMARK_TEST}-${host}.log;
scp ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host}:/root/test-${BENCHMARK_TEST}-netlib.rds test-${BENCHMARK_TEST}-${host}-netlib.rds;
scp ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host}:/root/test-${BENCHMARK_TEST}-atlas_st.rds test-${BENCHMARK_TEST}-${host}-atlas_st.rds;
scp ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host}:/root/test-${BENCHMARK_TEST}-openblas.rds test-${BENCHMARK_TEST}-${host}-openblas.rds;
scp ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host}:/root/test-${BENCHMARK_TEST}-atlas_mt.rds test-${BENCHMARK_TEST}-${host}-atlas_mt.rds;
scp ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host}:/root/test-${BENCHMARK_TEST}-gotoblas2.rds test-${BENCHMARK_TEST}-${host}-gotoblas2.rds;
scp ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host}:/root/test-${BENCHMARK_TEST}-mkl.rds test-${BENCHMARK_TEST}-${host}-mkl.rds;
scp ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host}:/root/test-${BENCHMARK_TEST}-blis.rds test-${BENCHMARK_TEST}-${host}-blis.rds;
scp ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host}:/root/test-${BENCHMARK_TEST}-cublas.rds test-${BENCHMARK_TEST}-${host}-cublas.rds 2> /dev/null;
echo "${host} finished" ; } &
done
while true
do
runningjobs=$(jobs -rp | wc -l)
if [ $runningjobs -eq 0 ] ; then
break
fi
curtim=`date +"%T"`
echo "* [$curtim] Waiting for $runningjobs hosts..."
sleep 5
done
echo "* All hosts finished benchmark ${BENCHMARK_TEST}"
}
##############################################################
##############################################################
if [ $# -eq 0 ]; then
echo "No arguments supplied"
else
for i in "$@"
do
case "$i" in
configure_hosts)
configure_hosts
;;
power_off)
power_off
;;
test_sample)
BENCHMARK_TEST="sample"
benchmark
;;
test_urbanek)
BENCHMARK_TEST="urbanek"
benchmark
;;
test_revolution)
BENCHMARK_TEST="revolution"
benchmark
;;
test_gcbd)
BENCHMARK_TEST="gcbd"
benchmark
;;
*)
echo "unknown command"
esac
done
fi