Skip to content

Commit

Permalink
Raise minimum C++ standard to 20
Browse files Browse the repository at this point in the history
Now that Acts has a minimum C++ version of C++20, we can follow suit.
This commit removes the preprocessor macros that ensure backwards
compatibility on concepts and increases the C++ version requirement to
20. Also updates the CI.
  • Loading branch information
stephenswat committed Jul 26, 2024
1 parent 2e14d32 commit 48531bd
Show file tree
Hide file tree
Showing 17 changed files with 83 additions and 176 deletions.
49 changes: 17 additions & 32 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,48 +25,33 @@ jobs:
matrix:
platform:
- name: CPU
container: ghcr.io/acts-project/ubuntu2004:v30
cxx_standard: "17"
options:
run_tests: true
- name: CPU
container: ghcr.io/acts-project/ubuntu2004:v30
cxx_standard: "17"
options: -DTRACCC_USE_ROOT=FALSE
run_tests: true
- name: CPU
container: ghcr.io/acts-project/ubuntu2404:48
container: ghcr.io/acts-project/ubuntu2404:56
cxx_standard: "20"
options: -DTRACCC_USE_ROOT=FALSE -DTRACCC_ENFORCE_CONCEPTS=TRUE
options:
run_tests: true
- name: HIP
container: ghcr.io/acts-project/ubuntu2004_rocm:47
cxx_standard: "17"
container: ghcr.io/acts-project/ubuntu2204_rocm_clang_cxx20:56
cxx_standard: "20"
options: -DTRACCC_BUILD_HIP=TRUE -DTRACCC_SETUP_ROCTHRUST=TRUE
run_tests: false
- name: CUDA
container: ghcr.io/acts-project/ubuntu2004_cuda:47
cxx_standard: "17"
options: -DTRACCC_BUILD_CUDA=TRUE -DTRACCC_ENABLE_NVTX_PROFILING=TRUE
run_tests: false
- name: CUDA
container: ghcr.io/acts-project/ubuntu2204_cuda:48
container: ghcr.io/acts-project/ubuntu2404_cuda:56
cxx_standard: "20"
options: -DTRACCC_BUILD_CUDA=TRUE -DTRACCC_USE_ROOT=FALSE -DTRACCC_ENFORCE_CONCEPTS=TRUE -DCMAKE_CUDA_FLAGS="-std=c++20"
options: -DTRACCC_BUILD_CUDA=TRUE -DCMAKE_CUDA_FLAGS="-std=c++20"
run_tests: false
- name: SYCL
container: ghcr.io/acts-project/ubuntu2004_oneapi:47
cxx_standard: "17"
options: -DTRACCC_BUILD_SYCL=TRUE
container: ghcr.io/acts-project/ubuntu2404_oneapi:56
cxx_standard: "20"
options: -DTRACCC_BUILD_SYCL=TRUE -DCMAKE_SYCL_FLAGS="-fsycl -fsycl-targets=spir64"
run_tests: true
- name: KOKKOS
container: ghcr.io/acts-project/ubuntu2004:v30
cxx_standard: "17"
container: ghcr.io/acts-project/ubuntu2404:56
cxx_standard: "20"
options: -DTRACCC_BUILD_KOKKOS=TRUE
run_tests: false
- name: ALPAKA
container: ghcr.io/acts-project/ubuntu2204:v33
cxx_standard: "17"
container: ghcr.io/acts-project/ubuntu2404:56
cxx_standard: "20"
options: -DTRACCC_BUILD_ALPAKA=TRUE
run_tests: false
build:
Expand All @@ -75,14 +60,14 @@ jobs:
include:
- platform:
name: "SYCL"
container: ghcr.io/acts-project/ubuntu2004_cuda_oneapi:47
cxx_standard: "17"
container: ghcr.io/acts-project/ubuntu2404_cuda_oneapi:56
cxx_standard: "20"
options: -DTRACCC_BUILD_SYCL=TRUE -DTRACCC_BUILD_CUDA=FALSE -DVECMEM_BUILD_CUDA_LIBRARY=FALSE
build: Release
- platform:
name: "SYCL"
container: ghcr.io/acts-project/ubuntu2004_rocm_oneapi:47
cxx_standard: "17"
container: ghcr.io/acts-project/ubuntu2404_rocm_oneapi:56
cxx_standard: "20"
options: -DTRACCC_BUILD_SYCL=TRUE -DVECMEM_BUILD_HIP_LIBRARY=FALSE
build: Release
# Use BASH as the shell from the images.
Expand Down
19 changes: 12 additions & 7 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ stages:
paths:
- build
script:
- cmake -G Ninja --preset ${TRACCC_BUILD_PRESET} -DCMAKE_BUILD_TYPE=Release
- SYCLFLAGS="${TRACCC_SYCL_FLAGS}" CXXFLAGS="${TRACCC_CXX_FLAGS}"
cmake -G Ninja --preset ${TRACCC_BUILD_PRESET} -DCMAKE_BUILD_TYPE=Release
-DTRACCC_BUILD_EXAMPLES=FALSE ${TRACCC_CMAKE_ARGS}
-S src -B build
- cmake --build build --parallel 2
Expand All @@ -52,15 +53,15 @@ stages:
# CUDA build job.
build:cuda:
<<: *build_job
image: ghcr.io/acts-project/ubuntu2004_cuda:47
image: ghcr.io/acts-project/ubuntu2204_cuda:56
variables:
TRACCC_BUILD_TYPE: CUDA
TRACCC_BUILD_PRESET: cuda

# CUDA test job.
test:cuda:
<<: *nvidia_test_job
image: ghcr.io/acts-project/ubuntu2004_cuda:47
image: ghcr.io/acts-project/ubuntu2204_cuda:56
variables:
TRACCC_BUILD_TYPE: CUDA
dependencies:
Expand All @@ -69,15 +70,17 @@ test:cuda:
# SYCL build job (with an Intel backend).
build:sycl_intel:
<<: *build_job
image: ghcr.io/acts-project/ubuntu2004_oneapi:47
image: ghcr.io/acts-project/ubuntu2404_oneapi:56
variables:
TRACCC_BUILD_TYPE: SYCL
TRACCC_BUILD_PRESET: sycl
TRACCC_SYCL_FLAGS: -fsycl -fsycl-targets=spir64
TRACCC_CMAKE_ARGS: -DTRACCC_BUILD_CUDA=FALSE

# SYCL test job (with an Intel backend).
test:sycl_intel:
<<: *intel_test_job
image: ghcr.io/acts-project/ubuntu2004_oneapi:47
image: ghcr.io/acts-project/ubuntu2404_oneapi:56
variables:
TRACCC_BUILD_TYPE: SYCL
ONEAPI_DEVICE_SELECTOR: opencl:*
Expand All @@ -87,16 +90,18 @@ test:sycl_intel:
# SYCL build job (with an NVIDIA backend).
build:sycl_nvidia:
<<: *build_job
image: ghcr.io/acts-project/ubuntu2004_cuda_oneapi:48
image: ghcr.io/acts-project/ubuntu2204_cuda_oneapi:56
variables:
TRACCC_BUILD_TYPE: SYCL
TRACCC_BUILD_PRESET: sycl
TRACCC_SYCL_FLAGS: -fsycl -fsycl-targets=nvidia_gpu_sm_75 -Wno-unknown-cuda-version -Wno-deprecated-declarations
TRACCC_CXX_FLAGS: -Wno-deprecated-declarations
TRACCC_CMAKE_ARGS: -DTRACCC_BUILD_CUDA=FALSE

# SYCL test job (with an NVIDIA backend).
test:sycl_nvidia:
<<: *nvidia_test_job
image: ghcr.io/acts-project/ubuntu2004_cuda_oneapi:48
image: ghcr.io/acts-project/ubuntu2204_cuda_oneapi:56
variables:
TRACCC_BUILD_TYPE: SYCL
ONEAPI_DEVICE_SELECTOR: cuda:*
Expand Down
11 changes: 4 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ cmake_minimum_required( VERSION 3.9 )
project( traccc VERSION 0.12.0 LANGUAGES CXX )

# Set up the used C++ standard(s).
set( CMAKE_CXX_STANDARD 17 CACHE STRING "The (host) C++ standard to use" )
set( CMAKE_CXX_STANDARD 20 CACHE STRING "The (host) C++ standard to use" )
set( CMAKE_CXX_EXTENSIONS FALSE CACHE BOOL "Disable (host) C++ extensions" )
set( CMAKE_CUDA_STANDARD 17 CACHE STRING "The (CUDA) C++ standard to use" )
set( CMAKE_CUDA_STANDARD 20 CACHE STRING "The (CUDA) C++ standard to use" )
set( CMAKE_CUDA_EXTENSIONS FALSE CACHE BOOL "Disable (CUDA) C++ extensions" )
set( CMAKE_SYCL_STANDARD 17 CACHE STRING "The (SYCL) C++ standard to use" )
set( CMAKE_HIP_STANDARD 17 CACHE STRING "The (HIP) C++ standard to use" )
set( CMAKE_SYCL_STANDARD 20 CACHE STRING "The (SYCL) C++ standard to use" )
set( CMAKE_HIP_STANDARD 20 CACHE STRING "The (HIP) C++ standard to use" )

# Flag controlling whether warnings should make the build fail.
option( TRACCC_FAIL_ON_WARNINGS
Expand Down Expand Up @@ -67,9 +67,6 @@ option( TRACCC_BUILD_EXAMPLES "Build the examples of traccc" TRUE )
option( TRACCC_USE_SYSTEM_LIBS "Use system libraries be default" FALSE )
option( TRACCC_USE_ROOT "Use ROOT in the build (if needed)" TRUE )

# Flag enforcing concept usage.
option( TRACCC_ENFORCE_CONCEPTS "Throw an error if concepts are not available" FALSE )

# Clean up.
unset( TRACCC_BUILD_CUDA_DEFAULT )

Expand Down
8 changes: 0 additions & 8 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,3 @@ target_link_libraries( traccc_core
# CUDA or HIP backend with SYCL.
target_compile_definitions( traccc_core
PUBLIC $<$<COMPILE_LANGUAGE:SYCL>:EIGEN_NO_CUDA EIGEN_NO_HIP> )

if ( TRACCC_ENFORCE_CONCEPTS )
target_compile_definitions(
traccc_core
PUBLIC
TRACCC_ENFORCE_CONCEPTS
)
endif ()
18 changes: 0 additions & 18 deletions core/include/traccc/definitions/concepts.hpp

This file was deleted.

14 changes: 3 additions & 11 deletions core/include/traccc/sanity/contiguous_on.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

#pragma once

// Project include(s).
#include "traccc/definitions/concepts.hpp"

// VecMem include(s).
#include <memory>
#include <vecmem/containers/data/vector_view.hpp>
Expand All @@ -19,9 +16,7 @@
#include <vecmem/utils/copy.hpp>

// System include
#if __cpp_concepts >= 201907L
#include <concepts>
#endif
#include <memory>
#include <unordered_set>

Expand All @@ -44,12 +39,9 @@ namespace traccc::host {
* @return true If the vector is contiguous on `P`.
* @return false Otherwise.
*/
template <TRACCC_CONSTRAINT(std::semiregular) P,
TRACCC_CONSTRAINT(std::equality_comparable) T>
#if __cpp_concepts >= 201907L
requires std::regular_invocable<P, T>
#endif
bool is_contiguous_on(P&& projection, vecmem::data::vector_view<T> vector) {
template <std::semiregular P, std::equality_comparable T>
requires std::regular_invocable<P, T> bool is_contiguous_on(
P&& projection, vecmem::data::vector_view<T> vector) {
// Grab the number of elements in our vector.
uint32_t n = vector.size();

Expand Down
13 changes: 3 additions & 10 deletions core/include/traccc/sanity/ordered_on.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,14 @@

#pragma once

// Project include(s).
#include "traccc/definitions/concepts.hpp"

// VecMem include(s).
#include <vecmem/containers/data/vector_view.hpp>
#include <vecmem/containers/device_vector.hpp>
#include <vecmem/memory/memory_resource.hpp>
#include <vecmem/utils/copy.hpp>

// System include
#if __cpp_concepts >= 201907L
#include <concepts>
#endif

namespace traccc::host {
/**
Expand All @@ -46,11 +41,9 @@ namespace traccc::host {
* @return true If the vector is ordered on `R`.
* @return false Otherwise.
*/
template <TRACCC_CONSTRAINT(std::semiregular) R, typename T>
#if __cpp_concepts >= 201907L
requires std::relation<R, T, T>
#endif
bool is_ordered_on(R relation, vecmem::data::vector_view<T> vector) {
template <std::semiregular R, typename T>
requires std::relation<R, T, T> bool is_ordered_on(
R relation, vecmem::data::vector_view<T> vector) {
// Grab the number of elements in our vector.
uint32_t n = vector.size();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct ccl_kernel_helper {
/// @param[out] measurements_view collection of measurements
/// @param[out] cell_links collection of links to measurements each cell is
/// put into
template <TRACCC_CONSTRAINT(device::concepts::barrier) barrier_t>
template <device::concepts::barrier barrier_t>
TRACCC_DEVICE inline void ccl_kernel(
details::index_t threadId, details::index_t blckDim, unsigned int blockId,
const cell_collection_types::const_view cells_view,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace traccc::device {
/// iteration.
/// @param[in] barrier A generic object for block-wide synchronisation
///
template <TRACCC_CONSTRAINT(device::concepts::barrier) barrier_t>
template <device::concepts::barrier barrier_t>
TRACCC_DEVICE void fast_sv_1(
vecmem::device_vector<details::index_t>& f,
vecmem::device_vector<details::index_t>& gf,
Expand Down Expand Up @@ -125,7 +125,7 @@ TRACCC_DEVICE void fast_sv_1(
} while (barrier.blockOr(gf_changed));
}

template <TRACCC_CONSTRAINT(device::concepts::barrier) barrier_t>
template <device::concepts::barrier barrier_t>
TRACCC_DEVICE inline void ccl_kernel(
const details::index_t threadId, const details::index_t blckDim,
const unsigned int blockId,
Expand Down
6 changes: 0 additions & 6 deletions device/common/include/traccc/device/concepts/barrier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@

#pragma once

#include "traccc/definitions/concepts.hpp"

#if __cpp_concepts >= 201907L
#include <concepts>
#endif

namespace traccc::device::concepts {
#if __cpp_concepts >= 201907L
/**
* @brief Concept to ensure that a type is barrier-like, i.e. it can
* synchronize threads in a compute block.
Expand Down Expand Up @@ -57,5 +52,4 @@ concept barrier = requires(T& b) {
->std::integral;
};
};
#endif
} // namespace traccc::device::concepts
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ inline void select_seeds(
scalar seed1_sum = 0;
scalar seed2_sum = 0;

const internal_spacepoint<spacepoint>& ispB1 =
const internal_spacepoint<spacepoint> ispB1 =
internal_sp_device.bin(lhs.sp1.bin_idx)[lhs.sp1.sp_idx];
const internal_spacepoint<spacepoint>& ispT1 =
const internal_spacepoint<spacepoint> ispT1 =
internal_sp_device.bin(lhs.sp3.bin_idx)[lhs.sp3.sp_idx];
const internal_spacepoint<spacepoint>& ispB2 =
const internal_spacepoint<spacepoint> ispB2 =
internal_sp_device.bin(rhs.sp1.bin_idx)[rhs.sp1.sp_idx];
const internal_spacepoint<spacepoint>& ispT2 =
const internal_spacepoint<spacepoint> ispT2 =
internal_sp_device.bin(rhs.sp3.bin_idx)[rhs.sp3.sp_idx];

const spacepoint& spB1 = spacepoints_device.at(ispB1.m_link);
Expand All @@ -185,9 +185,9 @@ inline void select_seeds(
const triplet& aTriplet = data[i];
const sp_location& spB_loc = aTriplet.sp1;
const sp_location& spT_loc = aTriplet.sp3;
const internal_spacepoint<spacepoint>& spB =
const internal_spacepoint<spacepoint> spB =
internal_sp_device.bin(spB_loc.bin_idx)[spB_loc.sp_idx];
const internal_spacepoint<spacepoint>& spT =
const internal_spacepoint<spacepoint> spT =
internal_sp_device.bin(spT_loc.bin_idx)[spT_loc.sp_idx];

// if the number of seeds reaches the threshold, break
Expand Down
Loading

0 comments on commit 48531bd

Please sign in to comment.