-
Notifications
You must be signed in to change notification settings - Fork 7
/
ngc_rdma_test.sh
executable file
·353 lines (321 loc) · 12.5 KB
/
ngc_rdma_test.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
#!/bin/bash
# Owner: [email protected]
set -eE
NEIGHBOR_LEVELS=1 # Utilizing NIC's NUMA
default_qps=4
max_qps=64
bw_ms_list=("65536")
lat_ms_list=("2")
server_QPS=()
client_QPS=()
conn_type_cmd=()
mtu_sizes=()
#Defaults are not using cuda, set params as empty string
server_cuda=""
client_cuda=""
ALLOW_CORE_ZERO=false
scriptdir="$(dirname "$0")"
source "${scriptdir}/common.sh"
source "${scriptdir}/ipsec_full_offload_setup.sh"
POSITIONAL_ARGS=()
while [ $# -gt 0 ]
do
case "${1}" in
--use_cuda)
RUN_WITH_CUDA=true
shift
;;
--server_cuda=*)
[ "${RUN_WITH_CUDA}" = true ] || fatal "--server_cuda can only be used with --use_cuda"
server_cuda_idx=${1#*=}
shift
;;
--client_cuda=*)
[ "${RUN_WITH_CUDA}" = true ] || fatal "--client_cuda can only be used with --use_cuda"
client_cuda_idx=${1#*=}
shift
;;
--all_connection_types)
ALL_CONN_TYPES=true
shift
;;
--qp=*)
user_qps="${1#*=}"
shift
;;
--conn=*)
IFS=',' read -ra CONN_TYPES <<< "${1#*=}"
shift
;;
--tests=*)
IFS=',' read -ra TESTS <<< "${1#*=}"
shift
;;
--bw_message-size-list=*)
IFS=',' read -ra bw_ms_list <<< "${1#*=}"
shift
;;
--lat_message-size-list=*)
IFS=',' read -ra lat_ms_list <<< "${1#*=}"
shift
;;
--unidir)
RDMA_UNIDIR=true
shift
;;
--sd)
SD=true
shift
;;
--duration=*)
TEST_DURATION="${1#*=}"
shift
;;
--ipsec)
IPSEC=true
shift
;;
--*)
fatal "Unknown option ${1}"
;;
*)
POSITIONAL_ARGS+=("${1}")
shift
;;
esac
done
set -- "${POSITIONAL_ARGS[@]}"
IMPLEMENTED_TESTS=("ib_write_bw" "ib_read_bw" "ib_send_bw" "ib_write_lat" "ib_read_lat" "ib_send_lat")
# loop over TESTS and fatal if there is a test that is not implemented
for test in "${TESTS[@]}"; do
if [[ ! " ${IMPLEMENTED_TESTS[@]} " =~ " ${test} " ]]; then
fatal "Test '${test}' is not implemented."
fi
done
# If TESTS is empty, set it to IMPLEMENTED_TESTS
if [ ${#TESTS[@]} -eq 0 ]; then
TESTS=("${IMPLEMENTED_TESTS[@]}")
fi
get_perftest_connect_options() {
local test
test="${1}"
ssh "${SERVER_TRUSTED}" "${test} --help" | awk -F'[<>]' '/--connection=/{gsub(/\//," ");gsub(/SRD/,"");print $2}'
}
show_help()
{
cat <<EOF >&2
Run RDMA test
* Passwordless SSH access to the participating nodes is required.
* Passwordless sudo root access is required from the SSH'ing user.
* Dependencies which need to be installed: numctl, perftest.
Syntax: $0 [<client username>@]<client hostname> <client ib device1>[,<client ib device2>,...] [<server username>@]<server hostname> <server ib device1>[,<server ib device2>,...] [--use_cuda] [--qp=<num of QPs>] [--all_connection_types | --conn=<list of connection types>] [--tests=<list of ib perftests>] [--duration=<time in seconds>] [--message-size-list=<list of message sizes>] [--ipsec] [--sd]
Options:
--use_cuda : add this flag to run BW perftest benchamrks on GPUs
--server_cuda=<cuda device index>: Use the specified cuda device
--client_cuda=<cuda device index>: Use the specified cuda device
--qp=<num of QPs>: Use the sepecified QPs' number (default: 4 QPs per device, max: ${max_qps})
--all_connection_types: check all the supported connection types for each test, or:
--conn=<list of connection types>: Use this flag to provide a comma-separated list of connection types without spaces.
--tests=<list of ib perftests>: Use this flag to provide a comma-separated list of ib perftests to run.
--duration=<time in seconds>: Specify the duration for each test (default: 30 seconds)
--bw_message-size-list=<list of message sizes>: Use this flag to provide a comma separated message size list to run bw tests (default: 65536)
--lat_message-size-list=<list of message sizes>: Use this flag to provide a comma separated message size list to run latency tests (default: 2)
--unidir: Run in unidir (default: bidir)
--ipsec: Enable IPsec packet offload (full-offload) on the Arm cores.
--sd: Enable Socket Direct support. The SD should be added after the device (see example below).
Please note that when running 2 devices on each side we expect dual-port performance.
Example:(Run on 2 ports)
$0 client mlx5_0,mlx5_1 server mlx5_3,mlx5_4
Example:(Pick 3 connection types, single port)
$0 client mlx5_0 server mlx5_3 --conn=UC,UD,DC
Example: (Run on 2 ports with Socket Direct)
$0 client mlx5_0,mlx5_1,mlx5_4,mlx5_5 server mlx5_0,mlx5_1,mlx5_4,mlx5_5 --sd
EOF
}
if (( $# < 4 ))
then
show_help
exit 1
fi
CLIENT_TRUSTED="${1}"
CLIENT_DEVICES=(${2//,/ })
SERVER_TRUSTED="${3}"
SERVER_DEVICES=(${4//,/ })
[ -n "${IPSEC}" ] || IPSEC=false
if [ "$IPSEC" = true ]
then
LOCAL_BF=(${5//,/ })
LOCAL_BF_device=(${6//,/ })
REMOTE_BF=(${7//,/ })
REMOTE_BF_device=(${8//,/ })
fi
[ -n "${TEST_DURATION}" ] || TEST_DURATION="30"
NUM_CONNECTIONS=${#CLIENT_DEVICES[@]}
if [ -n "${user_qps}" ]; then
(( user_qps <= max_qps )) || fatal "Max allowed QPs are ${max_qps}."
for ((i = 0; i < NUM_CONNECTIONS; i++)); do
server_QPS+=("${user_qps}")
done
client_QPS=("${server_QPS[@]}")
else
read -ra client_QPS <<< $(default_qps_optimization "$CLIENT_TRUSTED" "${CLIENT_DEVICES[@]}")
read -ra server_QPS <<< $(default_qps_optimization "$SERVER_TRUSTED" "${SERVER_DEVICES[@]}")
fi
BASE_RDMA_PORT=10000
if [ "${#SERVER_DEVICES[@]}" -ne "${#CLIENT_DEVICES[@]}" ]
then
fatal "The number of server and client devices must be equal."
fi
NUM_DEVS=${#SERVER_DEVICES[@]}
NUM_BF_DEVS=${#LOCAL_BF[@]}
#init the arrays SERVER_NETDEVS,CLIENT_NETDEVS
get_netdevs
MAX_PROC="32"
min_l=$(get_min_channels)
opt_proc=$((min_l<MAX_PROC ? min_l : MAX_PROC))
read -ra CORES_ARRAY <<< $(get_cores_for_devices $1 $2 $3 $4 $((opt_proc+2)))
NUM_CORES_PER_DEVICE=$(( ${#CORES_ARRAY[@]}/(${#CLIENT_DEVICES[@]}*2) ))
NUM_INST=${NUM_CORES_PER_DEVICE}
# validate CONN_TYPES input before start of run
for CONN_TYPE in "${CONN_TYPES[@]}"; do
exists_for_at_least_one_test=false
for TEST in "${TESTS[@]}"; do
available_conn_types="$(get_perftest_connect_options "$TEST")"
# Check if the current connection type exists for the current test
if [[ "$available_conn_types" == *"$CONN_TYPE"* ]]; then
exists_for_at_least_one_test=true
break
fi
done
if [ "${exists_for_at_least_one_test}" != "true" ]; then
fatal "invalid connection type: ${CONN_TYPE}"
exit 1
fi
done
#---------------------Configure IPsec full offload--------------------
if [ "$IPSEC" = true ]
then
if [ -z "${MTU_SIZE}" ]; then
for dev in "${CLIENT_DEVICES[@]}"
do
echo "$dev"
net_name="$(ssh "${CLIENT_TRUSTED}" "ls -1 /sys/class/infiniband/${dev}/device/net/ | head -1")"
mtu_sizes+=("$(ssh "${CLIENT_TRUSTED}" "ip a show ${net_name} | awk '/mtu/{print \$5}'")")
echo "$mtu_sizes"
done
MTU_SIZE="$(get_min_val ${mtu_sizes[@]})"
fi
index=0
for ((; index<NUM_BF_DEVS; index++))
do
# IPsec full-offload configuration flow:
get_ips_and_ifs # create SERVER_IPS, SERVER_IPS_MASK, CLIENT_IPS, CLIENT_IPS_MASK
update_mlnx_bf_conf ${LOCAL_BF[index]}
update_mlnx_bf_conf ${REMOTE_BF[index]}
generate_next_ip # Generate local_IP & remote_IP
set_mtu ${LOCAL_BF[index]} ${LOCAL_BF_device[index]} ${REMOTE_BF[index]} ${REMOTE_BF_device[index]} $(( MTU_SIZE + 50 ))
set_ip ${LOCAL_BF[index]} ${LOCAL_BF_device[index]} "${local_IP}/24" ${REMOTE_BF[index]} ${REMOTE_BF_device[index]} "${remote_IP}/24"
in_key=$(generete_key)
out_key=$(generete_key)
in_reqid=$(generete_req)
out_reqid=$(generete_req)
set_representor ${LOCAL_BF_device[index]} ${REMOTE_BF_device[index]}
set_ipsec_rules ${LOCAL_BF[index]} ${LOCAL_BF_device[index]} "${local_IP}" "${remote_IP}" ${in_key} ${out_key} ${in_reqid} ${out_reqid} "offload packet"
set_ipsec_rules ${REMOTE_BF[index]} ${REMOTE_BF_device[index]} "${remote_IP}" "${local_IP}" ${out_key} ${in_key} ${out_reqid} ${in_reqid} "offload packet"
ovs_configure ${LOCAL_BF[index]} ${LOCAL_BF_device[index]} ${representor1} "${local_IP}" "${remote_IP}" "${index}"
ovs_configure ${REMOTE_BF[index]} ${REMOTE_BF_device[index]} ${representor2} "${remote_IP}" "${local_IP}" "${index}"
done
for ((index1=0; index1<NUM_DEVS; index1++))
do
set_ip ${CLIENT_TRUSTED} ${CLIENT_NETDEVS[index1]} "${CLIENT_IPS[index1]}/${CLIENT_IPS_MASK[index1]}" ${SERVER_TRUSTED} ${SERVER_NETDEVS[index1]} "${SERVER_IPS[index1]}/${SERVER_IPS_MASK[index1]}"
done
fi
#---------------------Run Benchmark--------------------
logstring=( "" "" "" "for" "devices:" "${SERVER_DEVICES[*]}" "<->" "${CLIENT_DEVICES[*]}")
for TEST in "${TESTS[@]}"; do
logstring[0]="${TEST}"
if [ $RUN_WITH_CUDA ] && grep -q '^ib_send_bw\|ib_write_lat\|ib_send_lat$' <<<"${TEST}"
then
log "Skip ${TEST} when running with CUDA"
continue
fi
if [ "${ALL_CONN_TYPES}" = true ]
then
read -ra connection_types <<<"$(get_perftest_connect_options "${TEST}")"
else
connection_types=("${CONN_TYPES[@]}")
if [ "${#connection_types[@]}" -eq 0 ]; then
connection_types=("default")
else
# Filter unrelevant connection types to the current test
available_conn_types=($(get_perftest_connect_options "${TEST}"))
connection_types=($(comm -12 <(printf '%s\n' "${available_conn_types[@]}" | LC_ALL=C sort) <(printf '%s\n' "${connection_types[@]}" | LC_ALL=C sort)))
if [ "${#connection_types[@]}" -eq 0 ]; then
continue
fi
fi
fi
case "${TEST}" in
*_lat)
extra_server_args=("--output=latency")
extra_client_args=("")
bw_test=false
;;
*_bw)
[ "${RDMA_UNIDIR}" = "true" ] && unset bidir || bidir="-b"
extra_client_args=("--report_gbit" "${bidir}" "-q" "%%QPS%%")
extra_server_args=("--report_gbit" "${bidir}" "-q" "%%QPS%%" "--output=bandwidth")
bw_test=true
;;
*)
fatal "${TEST} - test not supported."
;;
esac
for CONN_TYPE in "${connection_types[@]}"
do
if [[ "${TEST}" == *_lat* ]]; then
ms_list=("${lat_ms_list[@]}")
else
ms_list=("${bw_ms_list[@]}")
fi
[ "${CONN_TYPE}" = "default" ] || conn_type_cmd=( "-c" "${CONN_TYPE}" )
PASS=true
for message_size in "${ms_list[@]}"
do
run_perftest_servers
sleep 2
run_perftest_clients
[ "${CONN_TYPE}" = "default" ] &&
logstring[1]="-" || logstring[1]="(connection type: ${CONN_TYPE})"
if [ "${PASS}" = true ]
then
logstring[2]="Passed"
log "${logstring[*]}" RESULT_PASS
else
logstring[2]="Failed"
log "${logstring[*]}" RESULT_FAIL
fi
done
done
done
if [ "$IPSEC" = true ]
then
index=0
for ((; index<NUM_BF_DEVS; index++))
do
# IPsec full-offload configuration *flush* flow:
set_representor ${LOCAL_BF_device[index]} ${REMOTE_BF_device[index]}
ovs_configure_revert ${LOCAL_BF[index]} ${LOCAL_BF_device[index]} ${representor1} "${index}"
ovs_configure_revert ${REMOTE_BF[index]} ${REMOTE_BF_device[index]} ${representor2} "${index}"
remove_ipsec_rules ${LOCAL_BF[index]}
remove_ipsec_rules ${REMOTE_BF[index]}
flush_ip ${LOCAL_BF[index]} ${LOCAL_BF_device[index]} ${REMOTE_BF[index]} ${REMOTE_BF_device[index]}
set_mtu ${LOCAL_BF[index]} ${LOCAL_BF_device[index]} ${REMOTE_BF[index]} ${REMOTE_BF_device[index]} ${MTU_SIZE}
update_mlnx_bf_conf_revert ${LOCAL_BF[index]}
update_mlnx_bf_conf_revert ${REMOTE_BF[index]}
for ((index1=0; index1<NUM_DEVS; index1++))
do
set_ip ${CLIENT_TRUSTED} ${CLIENT_NETDEVS[index1]} "${CLIENT_IPS[index1]}/${CLIENT_IPS_MASK[index1]}" ${SERVER_TRUSTED} ${SERVER_NETDEVS[index1]} "${SERVER_IPS[index1]}/${SERVER_IPS_MASK[index1]}"
done
done
fi