From bb5c75dd426172fe48203e6caa16e693b9b30f4e Mon Sep 17 00:00:00 2001 From: Simeon Ehrig Date: Tue, 7 Jan 2025 16:54:21 +0100 Subject: [PATCH] CI: fail if env2cmake access undefined variables - Set empty default variables if CUDA, HIP or SYCL backend is not enabled to avoid unbound variables. - Set CMake default configuration variables to avoid unbound variables. - Set alpaka_DEBUG to 0 if not set. In an upcoming PR, the job generator should set more jobs to `alpaka_DEBUG=2`. - Remove quotes for many CMake configuration arguments, to make CMake output more readable. If argument values contains white spaces, quotes are not avoidable. --- .github/workflows/ci.yml | 4 ++- script/before_install.sh | 18 +++++++++++ script/gitlabci/job_base.yml | 1 + script/gitlabci/job_cuda.yml | 6 ++++ script/install_clang.sh | 2 +- script/install_tbb.sh | 2 +- script/job_generator/generate_job_yaml.py | 6 ++++ script/run_generate.sh | 39 ++++++++++++++--------- script/set_default_env_vars.sh | 5 +++ 9 files changed, 65 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fd0e5c34dd..36b706689df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,9 @@ env: alpaka_ACC_GPU_CUDA_ONLY_MODE: OFF alpaka_ACC_GPU_HIP_ENABLE: OFF alpaka_ACC_GPU_HIP_ONLY_MODE: OFF + alpaka_ACC_SYCL_ENABLE: OFF alpaka_USE_MDSPAN: OFF + alpaka_DEBUG: 0 alpaka_ENABLE_WERROR: ON CMAKE_INSTALL_PREFIX: ${{ github.workspace }}/_install @@ -111,7 +113,7 @@ jobs: ### Analysis builds - name: linux_clang-14_cuda-11.2_debug_analysis os: ubuntu-20.04 - env: {ALPAKA_CI_CXX: clang++, ALPAKA_CI_CLANG_VER: 14, ALPAKA_CI_STDLIB: libstdc++, CMAKE_BUILD_TYPE: Debug, ALPAKA_BOOST_VERSION: 1.79.0, ALPAKA_CI_CMAKE_VER: 3.25.3, OMP_NUM_THREADS: 4, ALPAKA_CI_ANALYSIS: ON, ALPAKA_CI_RUN_TESTS: OFF, alpaka_DEBUG: 1, alpaka_ACC_GPU_CUDA_ENABLE: ON, ALPAKA_CI_CUDA_VERSION: "11.2", ALPAKA_CI_CUDA_COMPILER : clang++, alpaka_ACC_CPU_B_OMP2_T_SEQ_ENABLE: OFF, alpaka_ACC_CPU_B_SEQ_T_OMP2_ENABLE: OFF} + env: {ALPAKA_CI_CXX: clang++, ALPAKA_CI_CLANG_VER: 14, ALPAKA_CI_STDLIB: libstdc++, CMAKE_BUILD_TYPE: Debug, ALPAKA_BOOST_VERSION: 1.79.0, ALPAKA_CI_CMAKE_VER: 3.25.3, OMP_NUM_THREADS: 4, ALPAKA_CI_ANALYSIS: ON, ALPAKA_CI_RUN_TESTS: OFF, alpaka_DEBUG: 1, alpaka_ACC_GPU_CUDA_ENABLE: ON, ALPAKA_CI_CUDA_VERSION: "11.2", ALPAKA_CI_CUDA_COMPILER : clang++, alpaka_ACC_CPU_B_OMP2_T_SEQ_ENABLE: OFF, alpaka_ACC_CPU_B_SEQ_T_OMP2_ENABLE: OFF, CMAKE_CUDA_ARCHITECTURES: 61, alpaka_RELOCATABLE_DEVICE_CODE: OFF, alpaka_CUDA_SHOW_REGISTER: OFF, alpaka_CUDA_KEEP_FILES: OFF, alpaka_CUDA_EXPT_EXTENDED_LAMBDA: OFF} container: ubuntu:20.04 - name: windows_cl-2022_debug_analysis os: windows-2022 diff --git a/script/before_install.sh b/script/before_install.sh index 0e61d47cbe6..68b748a24f4 100755 --- a/script/before_install.sh +++ b/script/before_install.sh @@ -43,6 +43,14 @@ export ALPAKA_CI_INSTALL_CUDA="OFF" if [[ "${alpaka_ACC_GPU_CUDA_ENABLE}" == "ON" ]] then export ALPAKA_CI_INSTALL_CUDA="ON" +else + echo_yellow "" + export alpaka_RELOCATABLE_DEVICE_CODE=${alpaka_RELOCATABLE_DEVICE_CODE:=""} + export CMAKE_CUDA_ARCHITECTURES=${CMAKE_CUDA_ARCHITECTURES:=""} + export CMAKE_CUDA_COMPILER=${CMAKE_CUDA_COMPILER:=""} + export alpaka_CUDA_SHOW_REGISTER=${alpaka_CUDA_SHOW_REGISTER:=""} + export alpaka_CUDA_KEEP_FILES=${alpaka_CUDA_KEEP_FILES:=""} + export alpaka_CUDA_EXPT_EXTENDED_LAMBDA=${alpaka_CUDA_EXPT_EXTENDED_LAMBDA:=""} fi #------------------------------------------------------------------------------- @@ -51,6 +59,10 @@ export ALPAKA_CI_INSTALL_HIP="OFF" if [ "${alpaka_ACC_GPU_HIP_ENABLE}" == "ON" ] then export ALPAKA_CI_INSTALL_HIP="ON" +else + echo_yellow "" + export CMAKE_HIP_ARCHITECTURES=${CMAKE_HIP_ARCHITECTURES:=""} + export CMAKE_HIP_COMPILER=${CMAKE_HIP_COMPILER:=""} fi #------------------------------------------------------------------------------- @@ -99,6 +111,12 @@ if [[ "${ALPAKA_CI_CXX}" == "icpx" ]]; then fi fi +if [ "${alpaka_ACC_SYCL_ENABLE}" == "OFF" ]; then + echo_yellow "" + export alpaka_SYCL_ONEAPI_CPU=${alpaka_SYCL_ONEAPI_CPU:=""} + export alpaka_SYCL_ONEAPI_CPU_ISA=${alpaka_SYCL_ONEAPI_CPU_ISA:=""} +fi + #------------------------------------------------------------------------------- if [ "$ALPAKA_CI_OS_NAME" = "Linux" ] then diff --git a/script/gitlabci/job_base.yml b/script/gitlabci/job_base.yml index a91bb2a6efc..f36cfa774fe 100644 --- a/script/gitlabci/job_base.yml +++ b/script/gitlabci/job_base.yml @@ -9,6 +9,7 @@ ALPAKA_CI_BUILD_JOBS: "$CI_CPUS" OMP_NUM_THREADS: "$CI_CPUS" script: + - source ./script/set_default_env_vars.sh - source ./script/gitlabci/print_env.sh - source ./script/gitlab_ci_run.sh interruptible: true diff --git a/script/gitlabci/job_cuda.yml b/script/gitlabci/job_cuda.yml index 97bc2e139b7..61512321028 100644 --- a/script/gitlabci/job_cuda.yml +++ b/script/gitlabci/job_cuda.yml @@ -13,6 +13,9 @@ linux_nvcc12.0_gcc11_debug_relocatable_device_code_compile_only: ALPAKA_CI_CMAKE_VER: 3.26.5 alpaka_CXX_STANDARD: 20 alpaka_RELOCATABLE_DEVICE_CODE: "ON" + alpaka_CUDA_SHOW_REGISTER: "OFF" + alpaka_CUDA_KEEP_FILES: "OFF" + alpaka_CUDA_EXPT_EXTENDED_LAMBDA: "OFF" linux_nvcc12.0_gcc11_release_extended_lambda_off_compile_only: extends: .base_cuda_gcc_compile_only @@ -26,4 +29,7 @@ linux_nvcc12.0_gcc11_release_extended_lambda_off_compile_only: ALPAKA_CI_CMAKE_VER: 3.27.1 alpaka_CXX_STANDARD: 20 alpaka_ACC_GPU_CUDA_ENABLE: "ON" + alpaka_RELOCATABLE_DEVICE_CODE: "OFF" + alpaka_CUDA_SHOW_REGISTER: "OFF" + alpaka_CUDA_KEEP_FILES: "OFF" alpaka_CUDA_EXPT_EXTENDED_LAMBDA: "OFF" diff --git a/script/install_clang.sh b/script/install_clang.sh index 63231ea8389..9cfa2cdea5a 100755 --- a/script/install_clang.sh +++ b/script/install_clang.sh @@ -32,7 +32,7 @@ else if { [ "${ALPAKA_CI_UBUNTU_NAME}" == "focal" ] && [ "${ALPAKA_CI_CLANG_VER}" -ge 13 ]; } || \ { [ "${ALPAKA_CI_UBUNTU_NAME}" == "jammy" ] && [ "${ALPAKA_CI_CLANG_VER}" -ge 15 ]; } then - sudo add-apt-repository "deb http://apt.llvm.org/${ALPAKA_CI_UBUNTU_NAME}/ llvm-toolchain-${ALPAKA_CI_UBUNTU_NAME}-$ALPAKA_CI_CLANG_VER main" + sudo add-apt-repository -y "deb http://apt.llvm.org/${ALPAKA_CI_UBUNTU_NAME}/ llvm-toolchain-${ALPAKA_CI_UBUNTU_NAME}-$ALPAKA_CI_CLANG_VER main" fi travis_retry sudo apt-get -y --quiet --allow-unauthenticated --no-install-recommends install clang-${ALPAKA_CI_CLANG_VER} diff --git a/script/install_tbb.sh b/script/install_tbb.sh index 64d8b10cfb1..265551dbf99 100755 --- a/script/install_tbb.sh +++ b/script/install_tbb.sh @@ -45,6 +45,6 @@ else # run the mv in PS, because INNER_FOLDER contains backslashes (from github.workspace variable) and bash fails to glob powershell.exe -Command mv "${INNER_FOLDER}/*" "${TBB_ROOT}/" rm -r "${INNER_FOLDER}" - export TBB_DIR="${TBB_ROOT}/lib/cmake/tbb" + export ALPAKA_CI_TBB_DIR="${TBB_ROOT}/lib/cmake/tbb" fi fi diff --git a/script/job_generator/generate_job_yaml.py b/script/job_generator/generate_job_yaml.py index 667ecf79616..d3a9eb1ccca 100644 --- a/script/job_generator/generate_job_yaml.py +++ b/script/job_generator/generate_job_yaml.py @@ -345,6 +345,9 @@ def job_variables(job: Dict[str, Tuple[str, str]]) -> Dict[str, str]: variables["ALPAKA_CI_STDLIB"] = "libstdc++" variables["CMAKE_CUDA_ARCHITECTURES"] = job[SM_LEVEL][VERSION] variables["ALPAKA_CI_CUDA_VERSION"] = job[ALPAKA_ACC_GPU_CUDA_ENABLE][VERSION] + variables["alpaka_RELOCATABLE_DEVICE_CODE"] = "OFF" + variables["alpaka_CUDA_SHOW_REGISTER"] = "OFF" + variables["alpaka_CUDA_KEEP_FILES"] = "OFF" variables["alpaka_CUDA_EXPT_EXTENDED_LAMBDA"] = "OFF" if job[DEVICE_COMPILER][NAME] == NVCC: @@ -451,6 +454,9 @@ def global_variables() -> Dict[str, str]: variables["ALPAKA_CI_CUDA_DIR"] = "$HOME/cuda" variables["ALPAKA_CI_HIP_ROOT_DIR"] = "$HOME/hip" variables["alpaka_ENABLE_WERROR"] = "ON" + # TODO(SimeonEhrig): Implement algorithm which select for each backend one + # job and set alpaka_DEBUG=2 + variables["alpaka_DEBUG"] = 0 return variables diff --git a/script/run_generate.sh b/script/run_generate.sh index e17fd8fb335..7f527b79e45 100755 --- a/script/run_generate.sh +++ b/script/run_generate.sh @@ -21,15 +21,24 @@ echo_green "" # # @param $1 cmake/environment variable name # -# @result if $1 exists cmake variable definition else nothing is returned +# @result if $1 exists cmake variable definition else nothing is returned. If variable is not +# defined, the script will be exited. # # @code{.bash} # FOO=ON +# BAR="" # echo "$(env2cmake FOO)" # returns "-DFOO=ON" # echo "$(env2cmake BAR)" # returns nothing +# echo "$(env2cmake FOOBAR)" # exit 1 # @endcode function env2cmake() { + # check if variable is defined + if [ -z ${!1+x} ]; then + kill -SIGTERM $$ + fi + + # return only content of variable is not empty if [ ! -z "${!1}" ] ; then echo -n "-D$1=${!1}" fi @@ -80,19 +89,19 @@ mkdir -p build/ cd build/ "${ALPAKA_CI_CMAKE_EXECUTABLE}" --log-level=VERBOSE -G "${ALPAKA_CI_CMAKE_GENERATOR}" ${ALPAKA_CI_CMAKE_GENERATOR_PLATFORM}\ - -Dalpaka_BUILD_EXAMPLES=ON -DBUILD_TESTING=ON -Dalpaka_BUILD_BENCHMARKS=ON "$(env2cmake alpaka_ENABLE_WERROR)" \ - "$(env2cmake BOOST_ROOT)" -DBOOST_LIBRARYDIR="${ALPAKA_CI_BOOST_LIB_DIR}/lib" -DBoost_USE_STATIC_LIBS=ON -DBoost_USE_MULTITHREADED=ON -DBoost_USE_STATIC_RUNTIME=OFF -DBoost_ARCHITECTURE="-x64" \ - "$(env2cmake CMAKE_BUILD_TYPE)" "$(env2cmake CMAKE_CXX_FLAGS)" "$(env2cmake CMAKE_CXX_COMPILER)" "$(env2cmake CMAKE_EXE_LINKER_FLAGS)" "$(env2cmake CMAKE_CXX_EXTENSIONS)"\ - "$(env2cmake alpaka_ACC_CPU_B_SEQ_T_SEQ_ENABLE)" "$(env2cmake alpaka_ACC_CPU_B_SEQ_T_THREADS_ENABLE)" \ - "$(env2cmake alpaka_ACC_CPU_B_TBB_T_SEQ_ENABLE)" \ - "$(env2cmake alpaka_ACC_CPU_B_OMP2_T_SEQ_ENABLE)" "$(env2cmake alpaka_ACC_CPU_B_SEQ_T_OMP2_ENABLE)" \ - "$(env2cmake TBB_DIR)" \ - "$(env2cmake alpaka_RELOCATABLE_DEVICE_CODE)" \ - "$(env2cmake alpaka_ACC_GPU_CUDA_ENABLE)" "$(env2cmake alpaka_ACC_GPU_CUDA_ONLY_MODE)" "$(env2cmake CMAKE_CUDA_ARCHITECTURES)" "$(env2cmake CMAKE_CUDA_COMPILER)" "$(env2cmake CMAKE_CUDA_FLAGS)" \ - "$(env2cmake alpaka_CUDA_FAST_MATH)" "$(env2cmake alpaka_CUDA_FTZ)" "$(env2cmake alpaka_CUDA_SHOW_REGISTER)" "$(env2cmake alpaka_CUDA_KEEP_FILES)" "$(env2cmake alpaka_CUDA_EXPT_EXTENDED_LAMBDA)" \ - "$(env2cmake alpaka_ACC_GPU_HIP_ENABLE)" "$(env2cmake alpaka_ACC_GPU_HIP_ONLY_MODE)" "$(env2cmake CMAKE_HIP_ARCHITECTURES)" "$(env2cmake CMAKE_HIP_COMPILER)" "$(env2cmake CMAKE_HIP_FLAGS)" \ - "$(env2cmake alpaka_ACC_SYCL_ENABLE)" "$(env2cmake alpaka_SYCL_ONEAPI_CPU)" "$(env2cmake alpaka_SYCL_ONEAPI_CPU_ISA)" \ - "$(env2cmake alpaka_DEBUG)" "$(env2cmake alpaka_CI)" "$(env2cmake alpaka_CHECK_HEADERS)" "$(env2cmake alpaka_CXX_STANDARD)" "$(env2cmake alpaka_USE_MDSPAN)" "$(env2cmake CMAKE_INSTALL_PREFIX)" \ - ".." + -Dalpaka_BUILD_EXAMPLES=ON -DBUILD_TESTING=ON -Dalpaka_BUILD_BENCHMARKS=ON $(env2cmake alpaka_ENABLE_WERROR) \ + $(env2cmake BOOST_ROOT) -DBOOST_LIBRARYDIR="${ALPAKA_CI_BOOST_LIB_DIR}/lib" -DBoost_USE_STATIC_LIBS=ON -DBoost_USE_MULTITHREADED=ON -DBoost_USE_STATIC_RUNTIME=OFF -DBoost_ARCHITECTURE="-x64" \ + $(env2cmake CMAKE_BUILD_TYPE) "$(env2cmake CMAKE_CXX_FLAGS)" $(env2cmake CMAKE_CXX_COMPILER) "$(env2cmake CMAKE_EXE_LINKER_FLAGS)" $(env2cmake CMAKE_CXX_EXTENSIONS)\ + $(env2cmake alpaka_ACC_CPU_B_SEQ_T_SEQ_ENABLE) $(env2cmake alpaka_ACC_CPU_B_SEQ_T_THREADS_ENABLE) \ + $(env2cmake alpaka_ACC_CPU_B_TBB_T_SEQ_ENABLE) \ + $(env2cmake alpaka_ACC_CPU_B_OMP2_T_SEQ_ENABLE) $(env2cmake alpaka_ACC_CPU_B_SEQ_T_OMP2_ENABLE) \ + $(env2cmake ALPAKA_CI_TBB_DIR) \ + $(env2cmake alpaka_RELOCATABLE_DEVICE_CODE) \ + $(env2cmake alpaka_ACC_GPU_CUDA_ENABLE) $(env2cmake alpaka_ACC_GPU_CUDA_ONLY_MODE) $(env2cmake CMAKE_CUDA_ARCHITECTURES) $(env2cmake CMAKE_CUDA_COMPILER) "$(env2cmake CMAKE_CUDA_FLAGS)" \ + $(env2cmake alpaka_CUDA_SHOW_REGISTER) $(env2cmake alpaka_CUDA_KEEP_FILES) $(env2cmake alpaka_CUDA_EXPT_EXTENDED_LAMBDA) \ + $(env2cmake alpaka_ACC_GPU_HIP_ENABLE) $(env2cmake alpaka_ACC_GPU_HIP_ONLY_MODE) $(env2cmake CMAKE_HIP_ARCHITECTURES) $(env2cmake CMAKE_HIP_COMPILER) "$(env2cmake CMAKE_HIP_FLAGS)" \ + $(env2cmake alpaka_ACC_SYCL_ENABLE) $(env2cmake alpaka_SYCL_ONEAPI_CPU) $(env2cmake alpaka_SYCL_ONEAPI_CPU_ISA) \ + $(env2cmake alpaka_DEBUG) $(env2cmake alpaka_CI) $(env2cmake alpaka_CHECK_HEADERS) $(env2cmake alpaka_CXX_STANDARD) $(env2cmake alpaka_USE_MDSPAN) $(env2cmake CMAKE_INSTALL_PREFIX) \ + .. cd .. diff --git a/script/set_default_env_vars.sh b/script/set_default_env_vars.sh index 50de13b68f6..966412841e8 100755 --- a/script/set_default_env_vars.sh +++ b/script/set_default_env_vars.sh @@ -2,6 +2,11 @@ # set default values for unset environment variables +export CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS:=""} +export CMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS:=""} export CMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS:="ON"} export CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:=""} +export CMAKE_CUDA_FLAGS=${CMAKE_CUDA_FLAGS:=""} +export CMAKE_HIP_FLAGS=${CMAKE_HIP_FLAGS:=""} +export ALPAKA_CI_TBB_DIR=${ALPAKA_CI_TBB_DIR:=""}