Skip to content

Commit

Permalink
improve behavior if mdspan is enabled and alpaka_CUDA_EXPT_EXTENDED_L…
Browse files Browse the repository at this point in the history
…AMBDA is disabled

- Instead automatically disabling mdspan if alpaka_CUDA_EXPT_EXTENDED_LAMBDA is off throw an error. That's more expected behavior than an enabled feature is off. Also the old behavior does not worked, because mdspan was still compiled and throws a compiler error.
- Fix bug, that the Clang as CUDA compiler was also affected by the CMake options alpaka_CUDA_EXPT_EXTENDED_LAMBDA, which sets a nvcc flag.
  • Loading branch information
SimeonEhrig committed Jan 8, 2025
1 parent 0530df5 commit fbe8081
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 4 additions & 7 deletions cmake/alpakaCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -951,19 +951,16 @@ endif()

if (NOT alpaka_USE_MDSPAN STREQUAL "OFF")
if (MSVC AND (alpaka_CXX_STANDARD LESS 20))
message(WARNING "std::mdspan on MSVC requires C++20. Please enable C++20 via alpaka_CXX_STANDARD. Use of std::mdspan has been disabled.")
set(alpaka_USE_MDSPAN "OFF" CACHE STRING "Use std::mdspan with alpaka" FORCE)
message(FATAL_ERROR "std::mdspan on MSVC requires C++20. Please enable C++20 via alpaka_CXX_STANDARD. Use of std::mdspan has been disabled.")
endif ()

if (alpaka_ACC_GPU_CUDA_ENABLE AND (CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") AND (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
# this issue actually only occurs when the host compiler (not the CXX compiler) is clang, but cmake does not let us query the host compiler id
# see: https://gitlab.kitware.com/cmake/cmake/-/issues/20901
message(WARNING "std::mdspan does not work with nvcc and clang as host compiler. Use of std::mdspan has been disabled.")
set(alpaka_USE_MDSPAN "OFF" CACHE STRING "Use std::mdspan with alpaka" FORCE)
message(FATAL_ERROR "std::mdspan does not work with nvcc and clang as host compiler. Use of std::mdspan has been disabled.")
endif ()

if (alpaka_ACC_GPU_CUDA_ENABLE AND (NOT alpaka_CUDA_EXPT_EXTENDED_LAMBDA STREQUAL ON))
message(WARNING "std::mdspan requires nvcc's extended lambdas. Use of std::mdspan has been disabled.")
set(alpaka_USE_MDSPAN "OFF" CACHE STRING "Use std::mdspan with alpaka" FORCE)
if (alpaka_ACC_GPU_CUDA_ENABLE AND CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND (NOT alpaka_CUDA_EXPT_EXTENDED_LAMBDA STREQUAL ON))
message(FATAL_ERROR "std::mdspan requires nvcc's extended lambdas.")
endif()
endif()
5 changes: 5 additions & 0 deletions script/job_generator/generate_job_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,16 @@ 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_CUDA_EXPT_EXTENDED_LAMBDA"] = "OFF"

if job[DEVICE_COMPILER][NAME] == NVCC:
# general configuration, if nvcc is the CUDA compiler
variables["ALPAKA_CI_CUDA_COMPILER"] = "nvcc"

# MdSpan requires alpaka_CUDA_EXPT_EXTENDED_LAMBDA
if job[MDSPAN][VERSION] == ON_VER:
variables["alpaka_CUDA_EXPT_EXTENDED_LAMBDA"] = "ON"

# configuration, if GCC is the CUDA host compiler
if job[HOST_COMPILER][NAME] == GCC:
variables["ALPAKA_CI_CXX"] = "g++"
Expand Down

0 comments on commit fbe8081

Please sign in to comment.