Skip to content

Commit bd49915

Browse files
authored
Add support for -j option for build_cudaq.sh script (#2546)
Signed-off-by: Ben Howe <[email protected]>
1 parent 066746b commit bd49915

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Building.md

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ To build the CUDA-Q source code locally, fork this repository and follow the
1919
[instructions for setting up your environment](./Dev_Setup.md). Once you have
2020
done that, you should be able to run the [build
2121
script](./scripts/build_cudaq.sh) to build and install CUDA-Q in a local folder.
22+
If you run out of memory while building CUDA-Q, you can limit the number of
23+
parallel build jobs by passing `-j N` to the build script, where `N` is the
24+
number of parallel jobs you wish to allow. Lower values of `N` are less likely
25+
to run out of memory but will build slower.
2226
The path where CUDA-Q will be installed can be configured by setting the
2327
environment variable `CUDAQ_INSTALL_PREFIX`. If you customize this path or do
2428
not work in our development container, you either need to invoke the

scripts/build_cudaq.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,18 @@ CUDAQ_INSTALL_PREFIX=${CUDAQ_INSTALL_PREFIX:-"$HOME/.cudaq"}
4545
build_configuration=${CMAKE_BUILD_TYPE:-Release}
4646
verbose=false
4747
install_toolchain=""
48+
num_jobs=""
4849

4950
__optind__=$OPTIND
5051
OPTIND=1
51-
while getopts ":c:t:v" opt; do
52+
while getopts ":c:t:j:v" opt; do
5253
case $opt in
5354
c) build_configuration="$OPTARG"
5455
;;
5556
t) install_toolchain="$OPTARG"
5657
;;
58+
j) num_jobs="-j $OPTARG"
59+
;;
5760
v) verbose=true
5861
;;
5962
\?) echo "Invalid command line option -$OPTARG" >&2
@@ -194,11 +197,11 @@ fi
194197
echo "Building CUDA-Q with configuration $build_configuration..."
195198
logs_dir=`pwd`/logs
196199
if $verbose; then
197-
ninja install
200+
ninja ${num_jobs} install
198201
status=$?
199202
else
200203
echo "The progress of the build is being logged to $logs_dir/ninja_output.txt."
201-
ninja install 2> "$logs_dir/ninja_error.txt" 1> "$logs_dir/ninja_output.txt"
204+
ninja ${num_jobs} install 2> "$logs_dir/ninja_error.txt" 1> "$logs_dir/ninja_output.txt"
202205
status=$?
203206
fi
204207

0 commit comments

Comments
 (0)