Skip to content

Commit f86bfe7

Browse files
authored
Switch to C++20 as a minimum requirement (#1086)
* Use C++20 * Fix modernize-use-constraints * Update CI and oldest docker image * Workaround nvcc issues
1 parent 86ef128 commit f86bfe7

42 files changed

Lines changed: 377 additions & 555 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ SpacesInParensOptions:
250250
InEmptyParentheses: false
251251
Other: false
252252
SpacesInSquareBrackets: false
253-
Standard: c++17
253+
Standard: c++20
254254
StatementAttributeLikeMacros:
255255
- Q_EMIT
256256
StatementMacros:

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Checks: >
4848
modernize-*,
4949
-modernize-pass-by-value,
5050
-modernize-use-auto,
51+
-modernize-use-integer-sign-comparison,
5152
-modernize-use-nodiscard,
5253
-modernize-use-trailing-return-type,
5354
performance-*,

.github/workflows/tests-macos.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ jobs:
113113
path: ginkgo
114114
- name: Install Ginkgo
115115
run: |
116-
# Ginkgo 1.8 needs the flags "-undefined dynamic_lookup" to link, recent versions should not need it
117116
cmake \
118-
-D CMAKE_SHARED_LINKER_FLAGS="-undefined dynamic_lookup" \
119117
-D GINKGO_BUILD_BENCHMARKS=OFF \
120118
-D GINKGO_BUILD_EXAMPLES=OFF \
121119
-D GINKGO_BUILD_MPI=OFF \

.github/workflows/tests-ubuntu.yaml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
- name: 'cpu'
128128
c_compiler: 'gcc'
129129
cxx_compiler: 'g++'
130-
cxx_version: ['17']
130+
cxx_version: ['20']
131131
cmake_build_type: ['None']
132132
runs-on: ubuntu-latest
133133
needs: [docker-build, id_repo]
@@ -224,18 +224,14 @@ jobs:
224224
cxx_compiler: 'hipcc'
225225
ddc_extra_cxx_flags: ''
226226
kokkos_extra_cmake_flags: '-D Kokkos_ENABLE_HIP=ON -D Kokkos_ENABLE_HIP_RELOCATABLE_DEVICE_CODE=ON -D Kokkos_ENABLE_ROCTHRUST=OFF -D Kokkos_ARCH_AMD_GFX90A=ON'
227-
cxx_version: ['17', '20', '23']
227+
cxx_version: ['20', '23']
228228
build_type:
229229
- cmake_build_type: 'Release'
230230
cxx_flags: ''
231231
- cmake_build_type: 'Debug'
232232
cxx_flags: '-O1'
233233
exclude:
234-
- image: 'oldest' # nvcc 11 only supports C++-17
235-
backend:
236-
name: 'cuda'
237-
cxx_version: '20'
238-
- image: 'oldest' # nvcc 11 only supports C++-17
234+
- image: 'oldest' # nvcc 12 only supports C++-20
239235
backend:
240236
name: 'cuda'
241237
cxx_version: '23'
@@ -421,7 +417,7 @@ jobs:
421417
- name: 'cpu'
422418
c_compiler: 'gcc'
423419
cxx_compiler: 'g++'
424-
cxx_version: ['17']
420+
cxx_version: ['20']
425421
cmake_build_type: ['Debug']
426422
sanitizer: ['address', 'undefined']
427423
runs-on: ubuntu-latest
@@ -522,7 +518,7 @@ jobs:
522518
- name: 'cpu'
523519
c_compiler: 'clang-21'
524520
cxx_compiler: 'clang++-21'
525-
cxx_version: ['17']
521+
cxx_version: ['20']
526522
cmake_build_type: ['Release']
527523
runs-on: ubuntu-latest
528524
needs: [docker-build, id_repo]

CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ endif()
126126
add_library(ddc_core)
127127
add_library(DDC::core ALIAS ddc_core)
128128
configure_file(cmake/config.hpp.in generated/ddc/config.hpp NO_SOURCE_PERMISSIONS @ONLY)
129-
target_compile_features(ddc_core PUBLIC cxx_std_17)
129+
target_compile_features(ddc_core PUBLIC cxx_std_20)
130130
target_link_libraries(ddc_core PUBLIC Kokkos::kokkos)
131131
target_sources(
132132
ddc_core
@@ -145,7 +145,6 @@ target_sources(
145145
src/ddc/detail/macros.hpp
146146
src/ddc/detail/tagged_vector.hpp
147147
src/ddc/detail/type_seq.hpp
148-
src/ddc/detail/type_traits.hpp
149148
src/ddc/detail/utils.hpp
150149
src/ddc/aligned_allocator.hpp
151150
src/ddc/chunk.hpp
@@ -219,7 +218,7 @@ if("${DDC_BUILD_KERNELS_FFT}")
219218

220219
add_library(ddc_fft)
221220
add_library(DDC::fft ALIAS ddc_fft)
222-
target_compile_features(ddc_fft PUBLIC cxx_std_17)
221+
target_compile_features(ddc_fft PUBLIC cxx_std_20)
223222
target_link_libraries(ddc_fft PUBLIC DDC::core Kokkos::kokkos KokkosFFT::fft)
224223
target_sources(
225224
ddc_fft
@@ -269,7 +268,7 @@ if("${DDC_BUILD_KERNELS_SPLINES}")
269268

270269
add_library(ddc_splines)
271270
add_library(DDC::splines ALIAS ddc_splines)
272-
target_compile_features(ddc_splines INTERFACE cxx_std_17)
271+
target_compile_features(ddc_splines INTERFACE cxx_std_20)
273272
target_link_libraries(
274273
ddc_splines
275274
INTERFACE DDC::core
@@ -342,7 +341,7 @@ if("${DDC_BUILD_PDI_WRAPPER}")
342341

343342
add_library(ddc_pdi)
344343
add_library(DDC::pdi ALIAS ddc_pdi)
345-
target_compile_features(ddc_pdi PUBLIC cxx_std_17)
344+
target_compile_features(ddc_pdi PUBLIC cxx_std_20)
346345
target_link_libraries(ddc_pdi PUBLIC DDC::core PDI::PDI_C)
347346
target_sources(
348347
ddc_pdi

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ If you want to know more, join un on [Slack](https://ddc-lib.slack.com/join/shar
3838

3939
To use DDC core, one needs the following dependencies:
4040

41-
* a C++17-compliant compiler
41+
* a C++20-compliant compiler
4242
* CMake 3.25
4343
* Kokkos 4.4...<6
4444
* (optional, micro benchmarking) Benchmark 1.8...<2

docker/oldest/Dockerfile

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ FROM ubuntu:jammy@sha256:3ba65aa20f86a0fad9df2b2c259c613df006b2e6d0bfcc8a146afb8
77
LABEL "org.opencontainers.image.source"="https://github.com/CExA-project/ddc"
88

99
ARG BACKEND
10-
ARG AMDGPU_VERSION=5.7.3
10+
ARG AMDGPU_VERSION=6.2.4
1111
ARG CMAKE_VERSION=3.25.3
12-
ARG CUDA_MAJOR_VERSION=11
13-
ARG CUDA_MINOR_VERSION=8
12+
ARG CUDA_MAJOR_VERSION=12
13+
ARG CUDA_MINOR_VERSION=2
1414
ARG GINKGO_VERSION=1.8.0
15-
ARG ROCM_VERSION=5.7.3
15+
ARG ROCM_VERSION=6.2.4
1616

1717
COPY bash_run /bin/
1818
ENV BASH_ENV=/etc/profile
@@ -66,19 +66,20 @@ RUN chmod +x /bin/bash_run \
6666
apt-get install -y --no-install-recommends \
6767
clang \
6868
;; "cuda") \
69+
# libnvjitlink seems to be a missing dependency of cusparse
6970
apt-get install -y --no-install-recommends \
7071
cuda-minimal-build-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
7172
cuda-nvtx-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
7273
libcublas-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
7374
libcufft-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
7475
libcurand-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
7576
libcusparse-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
76-
gcc-10 \
77-
g++-10 \
77+
libnvjitlink-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
7878
;; "hip") \
7979
apt-get install -y --no-install-recommends \
8080
hipblas-dev${ROCM_VERSION} \
8181
hipfft-dev${ROCM_VERSION} \
82+
hiprand-dev${ROCM_VERSION} \
8283
hipsparse-dev${ROCM_VERSION} \
8384
rocm-hip-runtime-dev${ROCM_VERSION} \
8485
rocrand-dev${ROCM_VERSION} \
@@ -95,9 +96,13 @@ RUN chmod +x /bin/bash_run \
9596
"cpu") \
9697
cmake -DCMAKE_BUILD_TYPE=Release -DGINKGO_BUILD_OMP=ON -DGINKGO_BUILD_TESTS=OFF -DGINKGO_BUILD_EXAMPLES=OFF -DGINKGO_BUILD_BENCHMARKS=OFF -B ginkgo/build -S ginkgo \
9798
;; "cuda") \
98-
cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_CUDA_HOST_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=Release -DGINKGO_CUDA_ARCHITECTURES=70 -DGINKGO_BUILD_CUDA=ON -DGINKGO_BUILD_TESTS=OFF -DGINKGO_BUILD_EXAMPLES=OFF -DGINKGO_BUILD_BENCHMARKS=OFF -B ginkgo/build -S ginkgo \
99+
cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CUDA_HOST_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DGINKGO_CUDA_ARCHITECTURES=70 -DGINKGO_BUILD_CUDA=ON -DGINKGO_BUILD_TESTS=OFF -DGINKGO_BUILD_EXAMPLES=OFF -DGINKGO_BUILD_BENCHMARKS=OFF -B ginkgo/build -S ginkgo \
99100
;; "hip") \
100-
cmake -DCMAKE_PREFIX_PATH=/opt/rocm -DCMAKE_BUILD_TYPE=Release -DCMAKE_HIP_ARCHITECTURES=gfx90a -DGINKGO_BUILD_HIP=ON -DGINKGO_BUILD_TESTS=OFF -DGINKGO_BUILD_EXAMPLES=OFF -DGINKGO_BUILD_BENCHMARKS=OFF -B ginkgo/build -S ginkgo \
101+
# HIP_PATH needs to be set to avoid Ginkgo defining it (https://github.com/ginkgo-project/ginkgo/blob/develop/cmake/hip_path.cmake).
102+
# The Ginkgo <1.9 heuristic does not seem to be compatible with the new HIP v6 directory layout.
103+
# This makes amdclang++ fail during cmake compiler test (https://releases.llvm.org/18.1.0/tools/clang/docs/HIPSupport.html#order-of-precedence-for-hip-path)
104+
export HIP_PATH=`hipconfig --path` \
105+
&& cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_HIP_ARCHITECTURES=gfx90a -DGINKGO_BUILD_HIP=ON -DGINKGO_BUILD_TESTS=OFF -DGINKGO_BUILD_EXAMPLES=OFF -DGINKGO_BUILD_BENCHMARKS=OFF -B ginkgo/build -S ginkgo \
101106
;; esac \
102107
&& cmake --build ginkgo/build \
103108
&& cmake --install ginkgo/build --prefix /usr \
@@ -113,8 +118,8 @@ RUN chmod +x /bin/bash_run \
113118
&& rm -rf /var/lib/apt/lists/* \
114119
&& useradd -d /data -m -U ci \
115120
&& if [ "xcuda" = "x${BACKEND}" ] \
116-
; then echo 'CUDA_GCC=gcc-10' > /etc/profile.d/ddc-cuda.sh \
117-
; echo 'CUDA_GXX=g++-10' >> /etc/profile.d/ddc-cuda.sh \
121+
; then echo 'CUDA_GCC=gcc' > /etc/profile.d/ddc-cuda.sh \
122+
; echo 'CUDA_GXX=g++' >> /etc/profile.d/ddc-cuda.sh \
118123
; fi
119124

120125
USER ci:ci

src/ddc/chunk.hpp

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66

77
#include <cassert>
88
#include <string>
9-
#include <type_traits>
109
#include <utility>
1110

1211
#include <Kokkos_Core.hpp>
1312

1413
#include "detail/kokkos.hpp"
15-
#include "detail/type_traits.hpp"
1614

1715
#include "chunk_common.hpp"
1816
#include "chunk_span.hpp"
@@ -166,21 +164,17 @@ class Chunk : public ChunkCommon<ElementType, SupportType, Kokkos::layout_right>
166164
}
167165

168166
/// Slice out some dimensions
169-
template <
170-
class... QueryDDims,
171-
class SFINAESupportType = SupportType,
172-
std::enable_if_t<is_discrete_domain_v<SFINAESupportType>, int> = 0>
167+
template <class... QueryDDims>
173168
auto operator[](DiscreteDomain<QueryDDims...> const& odomain) const
169+
requires(is_discrete_domain_v<SupportType>)
174170
{
175171
return span_view()[odomain];
176172
}
177173

178174
/// Slice out some dimensions
179-
template <
180-
class... QueryDDims,
181-
class SFINAESupportType = SupportType,
182-
std::enable_if_t<is_discrete_domain_v<SFINAESupportType>, int> = 0>
175+
template <class... QueryDDims>
183176
auto operator[](DiscreteDomain<QueryDDims...> const& odomain)
177+
requires(is_discrete_domain_v<SupportType>)
184178
{
185179
return span_view()[odomain];
186180
}
@@ -189,9 +183,7 @@ class Chunk : public ChunkCommon<ElementType, SupportType, Kokkos::layout_right>
189183
* @param delems discrete coordinates
190184
* @return const-reference to this element
191185
*/
192-
template <
193-
class... DElems,
194-
std::enable_if_t<detail::all_of_v<is_discrete_element_v<DElems>...>, int> = 0>
186+
template <concepts::discrete_element... DElems>
195187
element_type const& operator()(DElems const&... delems) const noexcept
196188
{
197189
static_assert(
@@ -207,11 +199,9 @@ class Chunk : public ChunkCommon<ElementType, SupportType, Kokkos::layout_right>
207199
* @param dvects discrete vectors
208200
* @return reference to this element
209201
*/
210-
template <
211-
class... DVects,
212-
std::enable_if_t<detail::all_of_v<is_discrete_vector_v<DVects>...>, int> = 0,
213-
std::enable_if_t<sizeof...(DVects) != 0, int> = 0>
202+
template <concepts::discrete_vector... DVects>
214203
element_type const& operator()(DVects const&... dvects) const noexcept
204+
requires(sizeof...(DVects) != 0)
215205
{
216206
static_assert(
217207
SupportType::rank() == (0 + ... + DVects::size()),
@@ -225,9 +215,7 @@ class Chunk : public ChunkCommon<ElementType, SupportType, Kokkos::layout_right>
225215
* @param delems discrete coordinates
226216
* @return reference to this element
227217
*/
228-
template <
229-
class... DElems,
230-
std::enable_if_t<detail::all_of_v<is_discrete_element_v<DElems>...>, int> = 0>
218+
template <concepts::discrete_element... DElems>
231219
element_type& operator()(DElems const&... delems) noexcept
232220
{
233221
static_assert(
@@ -243,11 +231,9 @@ class Chunk : public ChunkCommon<ElementType, SupportType, Kokkos::layout_right>
243231
* @param dvects discrete vectors
244232
* @return reference to this element
245233
*/
246-
template <
247-
class... DVects,
248-
std::enable_if_t<detail::all_of_v<is_discrete_vector_v<DVects>...>, int> = 0,
249-
std::enable_if_t<sizeof...(DVects) != 0, int> = 0>
234+
template <concepts::discrete_vector... DVects>
250235
element_type& operator()(DVects const&... dvects) noexcept
236+
requires(sizeof...(DVects) != 0)
251237
{
252238
static_assert(
253239
SupportType::rank() == (0 + ... + DVects::size()),

src/ddc/chunk_common.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ class ChunkCommon
119119
}
120120

121121
private:
122-
template <class Mapping = mapping_type>
123-
static KOKKOS_FUNCTION constexpr std::
124-
enable_if_t<std::is_constructible_v<Mapping, extents_type>, allocation_mdspan_type>
125-
make_allocation_mdspan(ElementType* ptr, SupportType const& domain)
122+
static KOKKOS_FUNCTION constexpr allocation_mdspan_type make_allocation_mdspan(
123+
ElementType* ptr,
124+
SupportType const& domain)
125+
requires(std::is_constructible_v<mapping_type, extents_type>)
126126
{
127127
return allocation_mdspan_type(ptr, detail::array(domain.extents()));
128128
}
@@ -212,10 +212,7 @@ class ChunkCommon
212212
* @param ptr the allocation pointer to the data
213213
* @param domain the domain that sustains the view
214214
*/
215-
template <
216-
class Mapping = mapping_type,
217-
std::enable_if_t<std::is_constructible_v<Mapping, extents_type>, int> = 0>
218-
KOKKOS_FUNCTION constexpr ChunkCommon(ElementType* ptr, SupportType const& domain)
215+
KOKKOS_FUNCTION constexpr ChunkCommon(ElementType* ptr, SupportType const& domain) requires(std::is_constructible_v<mapping_type, extents_type>)
219216
: m_allocation_mdspan(make_allocation_mdspan(ptr, domain))
220217
, m_domain(domain)
221218
{

0 commit comments

Comments
 (0)