Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add infrastructure for working with concepts #631

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: CPU
container: ghcr.io/acts-project/ubuntu2404:48
cxx_standard: "20"
options: -DTRACCC_USE_ROOT=FALSE
options: -DTRACCC_USE_ROOT=FALSE -DTRACCC_ENFORCE_CONCEPTS=TRUE
- name: HIP
container: ghcr.io/acts-project/ubuntu2004_rocm:47
cxx_standard: "17"
Expand All @@ -47,7 +47,7 @@ jobs:
- name: CUDA
container: ghcr.io/acts-project/ubuntu2204_cuda:48
cxx_standard: "20"
options: -DTRACCC_BUILD_CUDA=TRUE -DTRACCC_USE_ROOT=FALSE
options: -DTRACCC_BUILD_CUDA=TRUE -DTRACCC_USE_ROOT=FALSE -DTRACCC_ENFORCE_CONCEPTS=TRUE -DCMAKE_CUDA_FLAGS="-std=c++20"
- name: SYCL
container: ghcr.io/acts-project/ubuntu2004_oneapi:47
cxx_standard: "17"
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ 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: 8 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,11 @@ 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: 18 additions & 0 deletions core/include/traccc/definitions/concepts.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* traccc library, part of the ACTS project (R&D line)
*
* (c) 2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

#if __cpp_concepts >= 201907L
#define TRACCC_CONSTRAINT(...) __VA_ARGS__
#elif defined(TRACCC_ENFORCE_CONCEPTS)
#error \
"`TRACCC_ENFORCE_CONCEPTS` is set, but concepts are not available. This constitutes a fatal error."
#else
#define TRACCC_CONSTRAINT(...) typename
#endif
Loading