Skip to content

Commit

Permalink
Add argument to build/test scripts for additional cmake options (#620)
Browse files Browse the repository at this point in the history
* Add libcudacxx_LIT_FLAGS.

* [skip-tests] [not working] Add arg for cmake options.

* Use bash array and cmake separate_commands.

* Don't use separate_command after all.

* Delete debug print.

* Add back passing vv and no-progress-bar.

* Use anchors in matrix.yaml.

* Nested anchors.

* Can't alias an alias.

* Add extra_build_args to CI matrix and pass to build script.

* Extra braces.

* Quotes.

* Fix quotes.

* Try quoting.
  • Loading branch information
jrhemstad authored Dec 13, 2023
1 parent fddf2fe commit 1f028d6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dispatch-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
with:
cpu: ${{ matrix.cpu }}
test_name: ${{matrix.cpu}}/${{matrix.compiler.name}}${{matrix.compiler.version}}/C++${{matrix.std}}
build_script: "./ci/build_${{ inputs.project_name }}.sh -cxx ${{matrix.compiler.exe}} -std ${{matrix.std}}"
test_script: "./ci/test_${{ inputs.project_name }}.sh -cxx ${{matrix.compiler.exe}} -std ${{matrix.std}}"
build_script: './ci/build_${{ inputs.project_name }}.sh -cxx ${{matrix.compiler.exe}} -std ${{matrix.std}} "${{matrix.extra_build_args}}"'
test_script: './ci/test_${{ inputs.project_name }}.sh -cxx ${{matrix.compiler.exe}} -std ${{matrix.std}}'
container_image: rapidsai/devcontainers:${{inputs.devcontainer_version}}-cpp-${{matrix.compiler.name}}${{matrix.compiler.version}}-cuda${{matrix.cuda}}-${{matrix.os}}
run_tests: ${{ contains(matrix.jobs, 'test') && !contains(github.event.head_commit.message, 'skip-tests') && matrix.os != 'windows-2022' }}

Expand Down
20 changes: 16 additions & 4 deletions ci/build_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ HOST_COMPILER=${CXX:-g++} # $CXX if set, otherwise `g++`
CXX_STANDARD=17
CUDA_COMPILER=${CUDACXX:-nvcc} # $CUDACXX if set, otherwise `nvcc`
CUDA_ARCHS= # Empty, use presets by default.
GLOBAL_CMAKE_OPTIONS=()

# Check if the correct number of arguments has been provided
function usage {
Expand All @@ -23,12 +24,14 @@ function usage {
echo " -cxx: Host compiler (Defaults to \$CXX if set, otherwise g++)"
echo " -std: CUDA/C++ standard (Defaults to 17)"
echo " -arch: Target CUDA arches, e.g. \"60-real;70;80-virtual\" (Defaults to value in presets file)"
echo " -cmake-options: Additional options to pass to CMake"
echo
echo "Examples:"
echo " $ PARALLEL_LEVEL=8 $0"
echo " $ PARALLEL_LEVEL=8 $0 -cxx g++-9"
echo " $ $0 -cxx clang++-8"
echo " $ $0 -cxx g++-8 -std 14 -arch 80-real -v -cuda /usr/local/bin/nvcc"
echo " $ $0 -cmake-options \"-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=-Wfatal-errors\""
exit 1
}

Expand All @@ -45,6 +48,17 @@ while [ "${#args[@]}" -ne 0 ]; do
-cuda) CUDA_COMPILER="${args[1]}"; args=("${args[@]:2}");;
-arch) CUDA_ARCHS="${args[1]}"; args=("${args[@]:2}");;
-disable-benchmarks) ENABLE_CUB_BENCHMARKS="false"; args=("${args[@]:1}");;
-cmake-options)
if [ -n "${args[1]}" ]; then
IFS=' ' read -ra split_args <<< "${args[1]}"
GLOBAL_CMAKE_OPTIONS+=("${split_args[@]}")
args=("${args[@]:2}")
else
echo "Error: No arguments provided for -cmake-options"
usage
exit 1
fi
;;
-h | -help | --help) usage ;;
*) echo "Unrecognized option: ${args[0]}"; usage ;;
esac
Expand All @@ -54,9 +68,8 @@ done
HOST_COMPILER=$(which ${HOST_COMPILER})
CUDA_COMPILER=$(which ${CUDA_COMPILER})

GLOBAL_CMAKE_OPTIONS=""
if [[ -n "${CUDA_ARCHS}" ]]; then
GLOBAL_CMAKE_OPTIONS+="-DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHS} "
GLOBAL_CMAKE_OPTIONS+=("-DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHS}")
fi

if [ $VERBOSE ]; then
Expand Down Expand Up @@ -227,7 +240,6 @@ print_environment_details() {
end_group "⚙️ Environment Details"
}


function configure_preset()
{
local BUILD_NAME=$1
Expand All @@ -236,7 +248,7 @@ function configure_preset()
local GROUP_NAME="🛠️ CMake Configure ${BUILD_NAME}"

pushd .. > /dev/null
run_command "$GROUP_NAME" cmake --preset=$PRESET --log-level=VERBOSE $GLOBAL_CMAKE_OPTIONS $CMAKE_OPTIONS
run_command "$GROUP_NAME" cmake --preset=$PRESET --log-level=VERBOSE "${GLOBAL_CMAKE_OPTIONS[@]}" $CMAKE_OPTIONS
status=$?
popd > /dev/null
return $status
Expand Down
13 changes: 7 additions & 6 deletions libcudacxx/test/libcudacxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,17 @@ add_lit_testsuite(check-cudacxx

find_program(libcudacxx_LIT lit REQUIRED)

set(libcudacxx_LIT_FLAGS "" CACHE STRING "Semi-colon separated list of flags passed to the invocation of lit.")
message(STATUS "libcudacxx_LIT_FLAGS: ${libcudacxx_LIT_FLAGS}")

if (NOT LIBCUDACXX_TEST_WITH_NVRTC)
# Build but don't run the tests. Used by CI to pre-seed sccache for the test machines.
# Only executed if explicitly requested.
add_custom_target(libcudacxx.test.lit.precompile
"${CMAKE_COMMAND}" -E env
"LIBCUDACXX_SITE_CONFIG=${lit_site_cfg_path}"
"${libcudacxx_LIT}" -vv --no-progress-bar --time-tests
"-Dexecutor=\"NoopExecutor()\"" # Don't run the compiled tests.
"${libcudacxx_SOURCE_DIR}/test/libcudacxx"
COMMAND "${CMAKE_COMMAND}" -E env "LIBCUDACXX_SITE_CONFIG=${lit_site_cfg_path}"
"${libcudacxx_LIT}" -vv --no-progress-bar ${libcudacxx_LIT_FLAGS} "-Dexecutor=\"NoopExecutor()\"" "${libcudacxx_SOURCE_DIR}/test/libcudacxx"
)

endif()

# Restricted to avoid oversubscribing the GPU:
Expand All @@ -139,7 +140,7 @@ set(libcudacxx_LIT_PARALLEL_LEVEL 8 CACHE STRING
add_test(NAME libcudacxx.test.lit COMMAND
"${CMAKE_COMMAND}" -E env
"LIBCUDACXX_SITE_CONFIG=${lit_site_cfg_path}"
"${libcudacxx_LIT}" -vv --no-progress-bar --time-tests
"${libcudacxx_LIT}" -vv --no-progress-bar ${libcudacxx_LIT_FLAGS}
-j "${libcudacxx_LIT_PARALLEL_LEVEL}"
"${libcudacxx_SOURCE_DIR}/test/libcudacxx"
)
Expand Down

0 comments on commit 1f028d6

Please sign in to comment.