-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathbuild_and_run.sh
executable file
·243 lines (213 loc) · 10.8 KB
/
build_and_run.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
#!/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES.
# SPDX-License-Identifier: BSD-3-Clause
NUMARGS=$#
ARGS=$*
# NOTE: ensure all dir changes are relative to the location of this
# script, and that this script resides in the repo dir!
REPODIR=$(cd $(dirname $0); pwd)
VALIDARGS="cpp_tests py_tests cpp_examples py_async_tests py_bench py_async_bench -v -g -n -c --show_depr_warn -h"
HELP="$0 [cpp_tests] [cpp_bench] [cpp_examples] [py_tests] [py_async_tests] [py_bench] [py_async_bench]
cpp_tests - run all C++ tests
cpp_bench - run C++ benchmarks
cpp_example - run C++ example
py_tests - run all Python core tests
py_async_tests - run all Python async tests
py_bench - run Python core benchmarks
py_async_bench - run Python async benchmarks
clean - remove all existing build artifacts and configuration (start
over)
libucxx - build the UCXX C++ module
libucxx_python - build the UCXX C++ Python support module
ucxx - build the ucxx Python package
tests - build tests
-v - verbose build mode
-g - build for debug
-n - no install step
-c - create cpp/compile_commands.json
--show_depr_warn - show cmake deprecation warnings
--cmake-args=\\\"<args>\\\" - pass arbitrary list of CMake configuration options (escape all quotes in argument)
-h | --h[elp] - print this text
default action (no args) is to build (with command below) and run all tests and benchmarks.
./build.sh libucxx libucxx_python ucxx tests
"
BUILD_ARGS=""
RUN_CPP_TESTS=0
RUN_CPP_BENCH=0
RUN_CPP_EXAMPLE=0
RUN_PY_TESTS=0
RUN_PY_ASYNC_TESTS=0
RUN_PY_BENCH=0
RUN_PY_ASYNC_BENCH=0
BINARY_PATH=${CONDA_PREFIX}/bin
function hasArg {
(( ${NUMARGS} != 0 )) && (echo " ${ARGS} " | grep -q " $1 ")
}
function runAll {
((${NUMARGS} == 0 )) || !(echo " ${ARGS} " | grep -q " [^-]\+ ")
}
if hasArg -h || hasArg --h || hasArg --help; then
echo "${HELP}"
exit 0
fi
if hasArg -v; then
BUILD_ARGS="${BUILD_ARGS} -v"
fi
if hasArg -g; then
BUILD_ARGS="${BUILD_ARGS} -g"
fi
if hasArg -n; then
BUILD_ARGS="${BUILD_ARGS} -n"
fi
if hasArg -c; then
BUILD_ARGS="${BUILD_ARGS} -c"
fi
if runAll || hasArg cpp_tests; then
RUN_CPP_TESTS=1
fi
if runAll || hasArg cpp_bench; then
RUN_CPP_BENCH=1
fi
if runAll || hasArg cpp_example; then
RUN_CPP_EXAMPLE=1
fi
if runAll || hasArg py_tests; then
RUN_PY_TESTS=1
fi
if runAll || hasArg py_async_tests; then
RUN_PY_ASYNC_TESTS=1
fi
if runAll || hasArg py_bench; then
RUN_PY_BENCH=1
fi
if runAll || hasArg py_async_bench; then
RUN_PY_ASYNC_BENCH=1
fi
# Exit if a building error occurs
set -e
(cd ${REPODIR}; ./build.sh ${BUILD_ARGS} libucxx libucxx_python ucxx benchmarks tests examples)
# Let all tests run even if they fail
set +e
run_cpp_benchmark() {
PROGRESS_MODE=$1
# UCX_TCP_CM_REUSEADDR=y to be able to bind immediately to the same port before
# `TIME_WAIT` timeout
CMD_LINE_SERVER="UCX_TCP_CM_REUSEADDR=y ${BINARY_PATH}/benchmarks/libucxx/ucxx_perftest -s 8388608 -r -n 20 -m ${PROGRESS_MODE}"
CMD_LINE_CLIENT="${BINARY_PATH}/benchmarks/libucxx/ucxx_perftest -s 8388608 -r -n 20 -m ${PROGRESS_MODE} 127.0.0.1"
echo -e "\e[1mRunning: \n - ${CMD_LINE_SERVER}\n - ${CMD_LINE_CLIENT}\e[0m"
UCX_TCP_CM_REUSEADDR=y ${BINARY_PATH}/benchmarks/libucxx/ucxx_perftest -s 8388608 -r -n 20 -m ${PROGRESS_MODE} &
${BINARY_PATH}/benchmarks/libucxx/ucxx_perftest -s 8388608 -r -n 20 -m ${PROGRESS_MODE} 127.0.0.1
}
run_cpp_example() {
PROGRESS_MODE=$1
# UCX_TCP_CM_REUSEADDR=y to be able to bind immediately to the same port before
# `TIME_WAIT` timeout
CMD_LINE="UCX_TCP_CM_REUSEADDR=y ${BINARY_PATH}/examples/libucxx/ucxx_example_basic -m ${PROGRESS_MODE}"
echo -e "\e[1mRunning: \n - ${CMD_LINE}\e[0m"
UCX_TCP_CM_REUSEADDR=y ${BINARY_PATH}/examples/libucxx/ucxx_example_basic -m ${PROGRESS_MODE}
}
run_tests_async() {
PROGRESS_MODE=$1
ENABLE_DELAYED_SUBMISSION=$2
ENABLE_PYTHON_FUTURE=$3
SKIP=$4
CMD_LINE="UCXPY_PROGRESS_MODE=${PROGRESS_MODE} UCXPY_ENABLE_DELAYED_SUBMISSION=${ENABLE_DELAYED_SUBMISSION} UCXPY_ENABLE_PYTHON_FUTURE=${ENABLE_PYTHON_FUTURE} pytest -vs python/ucxx/ucxx/_lib_async/tests/"
if [ $SKIP -ne 0 ]; then
echo -e "\e[31;1mSkipping unstable test: ${CMD_LINE}\e[0m"
else
echo -e "\e[1mRunning: ${CMD_LINE}\e[0m"
UCXPY_PROGRESS_MODE=${PROGRESS_MODE} UCXPY_ENABLE_DELAYED_SUBMISSION=${ENABLE_DELAYED_SUBMISSION} UCXPY_ENABLE_PYTHON_FUTURE=${ENABLE_PYTHON_FUTURE} pytest -vs python/ucxx/ucxx/_lib_async/tests/
fi
}
run_py_benchmark() {
BACKEND=$1
PROGRESS_MODE=$2
ASYNCIO_WAIT=$3
ENABLE_DELAYED_SUBMISSION=$4
ENABLE_PYTHON_FUTURE=$5
N_BUFFERS=$6
SLOW=$7
if [ $ASYNCIO_WAIT -ne 0 ]; then
ASYNCIO_WAIT="--asyncio-wait"
else
ASYNCIO_WAIT=""
fi
CMD_LINE="UCXPY_ENABLE_DELAYED_SUBMISSION=${ENABLE_DELAYED_SUBMISSION} UCXPY_ENABLE_PYTHON_FUTURE=${ENABLE_PYTHON_FUTURE} python -m ucxx.benchmarks.send_recv --backend ${BACKEND} -o cupy --reuse-alloc -d 0 -e 1 -n 8MiB --n-buffers $N_BUFFERS --progress-mode ${PROGRESS_MODE} ${ASYNCIO_WAIT}"
echo -e "\e[1mRunning: ${CMD_LINE}\e[0m"
if [ $SLOW -ne 0 ]; then
echo -e "\e[31;1mSLOW BENCHMARK: it may seem like a deadlock but will eventually complete.\e[0m"
fi
UCXPY_ENABLE_DELAYED_SUBMISSION=${ENABLE_DELAYED_SUBMISSION} UCXPY_ENABLE_PYTHON_FUTURE=${ENABLE_PYTHON_FUTURE} python -m ucxx.benchmarks.send_recv --backend ${BACKEND} -o cupy --reuse-alloc -d 0 -e 1 -n 8MiB --n-buffers $N_BUFFERS --progress-mode ${PROGRESS_MODE} ${ASYNCIO_WAIT}
}
if [[ $RUN_CPP_TESTS != 0 ]]; then
# UCX_TCP_CM_REUSEADDR=y to be able to bind immediately to the same port before
# `TIME_WAIT` timeout
UCX_TCP_CM_REUSEADDR=y ${BINARY_PATH}/gtests/libucxx/UCXX_TEST
fi
if [[ $RUN_CPP_BENCH != 0 ]]; then
# run_cpp_benchmark PROGRESS_MODE
run_cpp_benchmark polling
run_cpp_benchmark blocking
run_cpp_benchmark thread-polling
run_cpp_benchmark thread-blocking
run_cpp_benchmark wait
fi
if [[ $RUN_CPP_EXAMPLE != 0 ]]; then
# run_cpp_example PROGRESS_MODE
run_cpp_example polling
run_cpp_example blocking
run_cpp_example thread-polling
run_cpp_example thread-blocking
run_cpp_example wait
fi
if [[ $RUN_PY_TESTS != 0 ]]; then
echo -e "\e[1mRunning: pytest-vs python/ucxx/ucxx/_lib/tests/\e[0m"
pytest -vs python/ucxx/ucxx/_lib/tests/
fi
if [[ $RUN_PY_ASYNC_TESTS != 0 ]]; then
# run_tests_async PROGRESS_MODE ENABLE_DELAYED_SUBMISSION ENABLE_PYTHON_FUTURE SKIP
run_tests_async polling 0 0 0
run_tests_async polling 0 1 0
run_tests_async polling 1 0 1 # Delayed submission can't be used with polling
run_tests_async polling 1 1 1 # Delayed submission can't be used with polling
run_tests_async thread-polling 0 0 0
run_tests_async thread-polling 0 1 0
run_tests_async thread-polling 1 0 0
run_tests_async thread-polling 1 1 0
run_tests_async thread 0 0 0
run_tests_async thread 0 1 0
run_tests_async thread 1 0 0
run_tests_async thread 1 1 0
fi
if [[ $RUN_PY_BENCH != 0 ]]; then
# run_py_benchmark BACKEND PROGRESS_MODE ASYNCIO_WAIT ENABLE_DELAYED_SUBMISSION ENABLE_PYTHON_FUTURE NBUFFERS SLOW
run_py_benchmark ucxx-core blocking 0 0 0 1 0
run_py_benchmark ucxx-core polling 0 0 0 1 0
run_py_benchmark ucxx-core thread-polling 0 0 0 1 0
run_py_benchmark ucxx-core thread-polling 1 0 0 1 0
run_py_benchmark ucxx-core thread 0 0 0 1 0
run_py_benchmark ucxx-core thread 1 0 0 1 0
fi
if [[ $RUN_PY_ASYNC_BENCH != 0 ]]; then
for nbuf in 1 8; do
# run_py_benchmark BACKEND PROGRESS_MODE ASYNCIO_WAIT ENABLE_DELAYED_SUBMISSION ENABLE_PYTHON_FUTURE NBUFFERS SLOW
run_py_benchmark ucxx-async polling 0 0 0 ${nbuf} 0
run_py_benchmark ucxx-async polling 0 0 1 ${nbuf} 0
run_py_benchmark ucxx-async polling 0 1 0 ${nbuf} 0
run_py_benchmark ucxx-async polling 0 1 1 ${nbuf} 0
run_py_benchmark ucxx-async thread-polling 0 0 0 ${nbuf} 0
run_py_benchmark ucxx-async thread-polling 0 0 1 ${nbuf} 0
run_py_benchmark ucxx-async thread-polling 0 1 0 ${nbuf} 0
run_py_benchmark ucxx-async thread-polling 0 1 1 ${nbuf} 0
if [ ${nbuf} -eq 1 ]; then
run_py_benchmark ucxx-async thread 0 0 0 ${nbuf} 1
run_py_benchmark ucxx-async thread 0 0 1 ${nbuf} 1
run_py_benchmark ucxx-async thread 0 1 0 ${nbuf} 1
else
run_py_benchmark ucxx-async thread 0 0 0 ${nbuf} 0
run_py_benchmark ucxx-async thread 0 0 1 ${nbuf} 0
run_py_benchmark ucxx-async thread 0 1 0 ${nbuf} 0
fi
run_py_benchmark ucxx-async thread 0 1 1 ${nbuf} 0
done
fi