Skip to content

Commit

Permalink
CI: fail if env2cmake access undefined variables
Browse files Browse the repository at this point in the history
- Set some default environment variables in the CI scripts and job
generator.
  • Loading branch information
SimeonEhrig committed Jan 7, 2025
1 parent 0530df5 commit 1aedc1a
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 17 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions script/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<SETENV: set cuda environment variables for disabled backend>"
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

#-------------------------------------------------------------------------------
Expand All @@ -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 "<DEFAULT: hip environment variables for disabled backend>"
export CMAKE_HIP_ARCHITECTURES=${CMAKE_HIP_ARCHITECTURES:=""}
export CMAKE_HIP_COMPILER=${CMAKE_HIP_COMPILER:=""}
fi

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -99,6 +111,12 @@ if [[ "${ALPAKA_CI_CXX}" == "icpx" ]]; then
fi
fi

if [ "${alpaka_ACC_SYCL_ENABLE}" == "OFF" ]; then
echo_yellow "<DEFAULT: SYCL environment variables for disabled backend>"
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
Expand Down
1 change: 1 addition & 0 deletions script/gitlabci/job_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions script/gitlabci/job_cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ 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
Expand All @@ -26,4 +30,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"
2 changes: 1 addition & 1 deletion script/install_clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
7 changes: 7 additions & 0 deletions script/job_generator/generate_job_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ 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:
# general configuration, if nvcc is the CUDA compiler
Expand Down Expand Up @@ -446,6 +450,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

Expand Down
39 changes: 24 additions & 15 deletions script/run_generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,24 @@ echo_green "<SCRIPT: run_generate>"
#
# @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
Expand Down Expand Up @@ -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 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 ..
5 changes: 5 additions & 0 deletions script/set_default_env_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 TBB_DIR=${TBB_DIR:=""}

0 comments on commit 1aedc1a

Please sign in to comment.