Skip to content

Commit

Permalink
Modernize CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
j-stephan committed Aug 2, 2023
1 parent 85852e0 commit b396ef5
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 193 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ env:
alpaka_ACC_GPU_HIP_ENABLE: OFF
alpaka_ACC_GPU_HIP_ONLY_MODE: OFF
alpaka_USE_MDSPAN: OFF
alpaka_ENABLE_WERROR: ON
CMAKE_INSTALL_PREFIX: ${{ github.workspace }}/_install

jobs:
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ option(alpaka_BUILD_EXAMPLES "Build the examples" OFF)

# Enable the test infrastructure only if alpaka is the top-level project
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
option(alpaka_ENABLE_WERROR "Treat all warnings as errors." OFF)
option(BUILD_TESTING "Build the testing tree." OFF)
include(CTest)
endif()
Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,21 @@ Supported Compilers

This library uses C++17 (or newer when available).

| Accelerator Back-end | gcc 9.5 <br/> (Linux) | gcc 10.4 / 11.1 <br/> (Linux) | gcc 12.3 <br/> (Linux) | gcc 13.1 <br/> (Linux) | clang 9 <br/> (Linux) | clang 10 / 11<br/> (Linux) | clang 12 <br/> (Linux) | clang 13 <br/> (Linux) | clang 14 <br/> (Linux) | clang 15 <br/> (Linux) | clang 16 <br/> (Linux) | icpx (latest) | Xcode 13.2.1 / 14.2 / 14.3.1 <br /> (macOS) | Visual Studio 2022 <br/> (Windows) |
|--------------------------------------------------------------------------------|---------------------------------------------|---------------------------------------------|---------------------------------------------|------------------------|--------------------------------------------------------|---------------------------------------------------------|--------------------------------------------------|---------------------------------------------|---------------------------------------------------|-------------------------------------------|-------------------------------------------|--------------------|-------------------------------------------------------|--------------------------------------|
| Serial | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| OpenMP 2.0+ blocks | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| OpenMP 2.0+ threads | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| std::thread | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| TBB | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| CUDA (nvcc) | :white_check_mark: <br/> (CUDA 11.0 - 12.1) | :white_check_mark: <br/> (CUDA 11.4 - 12.0) | :white_check_mark: <br/> (CUDA 12.0 - 12.1) | :x: | :white_check_mark: <br/> (CUDA 11.0-11.2; 11.6 - 12.0) | :white_check_mark: <br/> (CUDA 11.2, 11.6 - 12.0) | :white_check_mark: <br/> (CUDA 11.6 - 12.0) | :white_check_mark: <br/> (CUDA 11.7 - 12.0) | :white_check_mark: <br/> (CUDA 11.8 - 12.0) | :white_check_mark: <br/> (CUDA 12.1) | :x: | :x: | :x: | :x: |
| CUDA (clang) | - | - | - | :x: | :x: | :x: | :x: | :x: | :white_check_mark: (CUDA 11.0 - 11.5) | :white_check_mark: (CUDA 11.0 - 11.5)[^1] | :white_check_mark: (CUDA 11.0 - 11.5)[^1] | :x: | - | - |
| [HIP](https://alpaka.readthedocs.io/en/latest/install/HIP.html) (clang) | - | - | - | :x: | :x: | :x: | :x: | :x: | :white_check_mark: (HIP 5.0 - 5.2) | :white_check_mark: (HIP 5.3 - 5.4) | :white_check_mark: (HIP 5.5) | :x: | - | - |
| Accelerator Back-end | gcc 9.5 <br/> (Linux) | gcc 10.4 / 11.1 <br/> (Linux) | gcc 12.3 <br/> (Linux) | gcc 13.1 <br/> (Linux) | clang 9 <br/> (Linux) | clang 10 / 11<br/> (Linux) | clang 12 <br/> (Linux) | clang 13 <br/> (Linux) | clang 14 <br/> (Linux) | clang 15 <br/> (Linux) | clang 16 <br/> (Linux) | icpx (latest) | Xcode 13.2.1 / 14.2 / 14.3.1 <br /> (macOS) | Visual Studio 2022 <br/> (Windows) |
|--------------------------------------------------------------------------------|-------------------------------------------------|-------------------------------------------------|---------------------------------------------|------------------------|------------------------------------------------------------|-------------------------------------------------------|-------------------------------------------------|---------------------------------------------|---------------------------------------------------|-------------------------------------------|-------------------------------------------|--------------------|-------------------------------------------------------|--------------------------------------|
| Serial | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| OpenMP 2.0+ blocks | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| OpenMP 2.0+ threads | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| std::thread | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| TBB | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| CUDA (nvcc) | :white_check_mark: <br/> (CUDA 11.0 - 12.1)[^2] | :white_check_mark: <br/> (CUDA 11.4 - 12.1)[^2] | :white_check_mark: <br/> (CUDA 12.0 - 12.1) | :x: | :white_check_mark: <br/> (CUDA 11.0-11.2; 11.6 - 12.1)[^2] | :white_check_mark: <br/> (CUDA 11.2, 11.6 - 12.1)[^2] | :white_check_mark: <br/> (CUDA 11.6 - 12.1)[^2] | :white_check_mark: <br/> (CUDA 11.7 - 12.1) | :white_check_mark: <br/> (CUDA 11.8 - 12.1) | :white_check_mark: <br/> (CUDA 12.1) | :x: | :x: | :x: | :x: |
| CUDA (clang) | - | - | - | :x: | :x: | :x: | :x: | :x: | :white_check_mark: (CUDA 11.0 - 11.5) | :white_check_mark: (CUDA 11.0 - 11.5)[^1] | :white_check_mark: (CUDA 11.0 - 11.5)[^1] | :x: | - | - |
| [HIP](https://alpaka.readthedocs.io/en/latest/install/HIP.html) (clang) | - | - | - | :x: | :x: | :x: | :x: | :x: | :white_check_mark: (HIP 5.0 - 5.2) | :white_check_mark: (HIP 5.3 - 5.4) | :white_check_mark: (HIP 5.5) | :x: | - | - |

Other compilers or combinations marked with :x: in the table above may work but are not tested in CI and are therefore not explicitly supported.

[^1]: Due to a [compiler bug](https://github.com/llvm/llvm-project/issues/58491) in debug mode only release builds are supported.
[^1]: Due to an [LLVM bug](https://github.com/llvm/llvm-project/issues/58491) in debug mode only release builds are supported.
[^2]: Due to a [CUDA bug](https://github.com/alpaka-group/alpaka/issues/2035) debug builds are only supported for CUDA versions >= 11.7.

Dependencies
------------
Expand Down
21 changes: 15 additions & 6 deletions cmake/alpakaCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ else()
target_link_libraries(alpaka INTERFACE ${RT_LIBRARY})
endif()
endif()

# Add debug optimization levels. CMake doesn't do this by default.
# Note that -Og is the recommended gcc optimization level for debug mode but is equivalent to -O1 for clang (and its derivates).
alpaka_set_compiler_options(HOST_DEVICE target alpaka $<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:GNU>,$<COMPILE_LANGUAGE:CXX>>:-Og>
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:GNU>,$<COMPILE_LANGUAGE:CUDA>>:-Xcompiler -Og>
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:Clang,AppleClang,IntelLLVM>>:-O0>
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:MSVC>>:/Od>)

target_link_options(alpaka INTERFACE $<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:GNU>>:-Og>
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:Clang,AppleClang,IntelLLVM>>:-O0>)
endif()

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -339,7 +349,7 @@ if(alpaka_ACC_GPU_CUDA_ENABLE)
if(CMAKE_CUDA_COMPILER)
if(NOT CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")
# Use user selected CMake CXX compiler or CMAKE_CUDA_HOST_COMPILER as cuda host compiler to avoid fallback to the default system CXX host compiler.
# CMAKE_CUDA_HOST_COMPILER is reset by check_language(CUDA) therefore definition passed by the user via -DCMAKE_CUDA_HOST_COMPILER are
# CMAKE_CUDA_HOST_COMPILER is reset by check_language(CUDA) therefore definitions passed by the user via -DCMAKE_CUDA_HOST_COMPILER are
# ignored by CMake (looks like a CMake bug).
if(_alpaka_CUDA_HOST_COMPILER)
set(CMAKE_CUDA_HOST_COMPILER ${_alpaka_CUDA_HOST_COMPILER})
Expand Down Expand Up @@ -412,13 +422,12 @@ if(alpaka_ACC_GPU_CUDA_ENABLE)
if(alpaka_CUDA_EXPT_EXTENDED_LAMBDA STREQUAL ON)
alpaka_set_compiler_options(DEVICE target alpaka $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
endif()
# This is mandatory because with c++17 many standard library functions we rely on are constexpr (std::min, std::multiplies, ...)
# This is mandatory because with C++17 many standard library functions we rely on are constexpr (std::min, std::multiplies, ...)
alpaka_set_compiler_options(DEVICE target alpaka $<$<COMPILE_LANGUAGE:CUDA>:--expt-relaxed-constexpr>)

if((CMAKE_BUILD_TYPE STREQUAL "Debug") OR (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
alpaka_set_compiler_options(DEVICE target alpaka $<$<COMPILE_LANGUAGE:CUDA>:-g>)
alpaka_set_compiler_options(DEVICE target alpaka $<$<COMPILE_LANGUAGE:CUDA>:-lineinfo>)
endif()
# CMake automatically sets '-g' in debug mode
alpaka_set_compiler_options(DEVICE target alpaka $<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:CUDA>>:-G> # -G overrides -lineinfo
$<$<AND:$<CONFIG:RelWithDebInfo>,$<COMPILE_LANGUAGE:CUDA>>:-g -lineinfo>)

if(alpaka_FAST_MATH STREQUAL ON)
alpaka_set_compiler_options(DEVICE target alpaka $<$<COMPILE_LANGUAGE:CUDA>:--use_fast_math>)
Expand Down
4 changes: 4 additions & 0 deletions script/docker_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,9 @@ if [ ! -z "${alpaka_USE_MDSPAN+x}" ]
then
ALPAKA_DOCKER_ENV_LIST+=("--env" "alpaka_USE_MDSPAN=${alpaka_USE_MDSPAN}")
fi
if [ ! -z "${alpaka_ENABLE_WERROR+x}" ]
then
ALPAKA_DOCKER_ENV_LIST+=("--env" "alpaka_ENABLE_WERROR=${alpaka_ENABLE_WERROR}")
fi

docker_retry docker run -v "$(pwd)":"$(pwd)" -w "$(pwd)" "${ALPAKA_DOCKER_ENV_LIST[@]}" "${ALPAKA_CI_DOCKER_BASE_IMAGE_NAME}" /bin/bash -c "source ./script/install.sh && ./script/run.sh"
9 changes: 9 additions & 0 deletions script/job_generator/alpaka_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,14 @@ def alpaka_post_filter(row: List) -> bool:
for clang_cuda_version in ["15", "16"]:
if row_check_version(row, HOST_COMPILER, "==", clang_cuda_version):
return False

# Debug builds with nvcc <= 11.6 produce compiler errors
if (
is_in_row(row, BUILD_TYPE)
and row[param_map[BUILD_TYPE]][VERSION] == CMAKE_DEBUG
and row_check_name(row, DEVICE_COMPILER, "==", NVCC)
and row_check_version(row, DEVICE_COMPILER, "<=", "11.6")
):
return False

return True
Loading

0 comments on commit b396ef5

Please sign in to comment.