Skip to content

Commit

Permalink
Update CI build_cudaq.sh to specify num parallel jobs (#63)
Browse files Browse the repository at this point in the history
Related (and required) prerequisite:
NVIDIA/cuda-quantum#2546

Signed-off-by: Ben Howe <[email protected]>
  • Loading branch information
bmhowe23 authored Jan 28, 2025
1 parent 601b276 commit c303763
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:

- name: Build CUDAQ toolchain
run: |
.github/workflows/scripts/build_cudaq.sh ${{ matrix.python }}
.github/workflows/scripts/build_cudaq.sh --python-version ${{ matrix.python }}
- name: Build CUDA-QX wheels
run: |
Expand Down
60 changes: 57 additions & 3 deletions .github/workflows/scripts/build_cudaq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,62 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

# ==============================================================================
# Handling options
# ==============================================================================

show_help() {
echo "Usage: $0 [options]"
echo "Options:"
echo " --python-version Python version to build wheel for (e.g. 3.10)"
echo " -j Number of parallel jobs to build CUDA-Q with"
echo " (e.g. 8)"
}

parse_options() {
while (( $# > 0 )); do
case "$1" in
--python-version)
if [[ -n "$2" && "$2" != -* ]]; then
python_version=("$2")
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-j)
if [[ -n "$2" && "$2" != -* ]]; then
num_par_jobs=("$2")
cudaq_ninja_jobs_arg="-j $num_par_jobs"
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-*)
echo "Error: Unknown option $1" >&2
show_help
exit 1
;;
*)
echo "Error: Unknown argument $1" >&2
show_help
exit 1
;;
esac
done
}

# Defaults
python_version=3.10
cudaq_ninja_jobs_arg=""

# Parse options
parse_options "$@"


export CUDA_VERSION=12.0

# We need to use a newer toolchain because CUDA-QX libraries rely on c++20
Expand All @@ -16,8 +72,6 @@ source /opt/rh/gcc-toolset-11/enable
export CC=gcc
export CXX=g++

python_version=$1
python_version=${python_version:-3.10}
python=python${python_version}
${python} -m pip install --no-cache-dir numpy auditwheel

Expand Down Expand Up @@ -69,5 +123,5 @@ echo "$CUDAQ_PATCH" | git apply --verbose

$python -m venv --system-site-packages .venv
source .venv/bin/activate
CUDAQ_BUILD_TESTS=FALSE bash scripts/build_cudaq.sh -v
CUDAQ_BUILD_TESTS=FALSE bash scripts/build_cudaq.sh -v ${cudaq_ninja_jobs_arg}

0 comments on commit c303763

Please sign in to comment.