Skip to content

Commit b778c95

Browse files
authored
Update libcudacxx C++ dialect handling. (#6693)
1 parent bd89eda commit b778c95

File tree

11 files changed

+67
-169
lines changed

11 files changed

+67
-169
lines changed

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ All CCCL subprojects are computationally expensive to build and test. Use the pr
3636

3737
### CMake Presets
3838

39-
Presets are defined in `CMakePresets.json`. Names follow a `<project>-cxx<std>` format, such as `cub-cpp20`, `thrust-cpp17`, or `libcudacxx-cpp20`. Use `cmake --list-presets` to view available options. Build trees are placed under `build/${CCCL_BUILD_INFIX}/${PRESET}`.
39+
Presets are defined in `CMakePresets.json`. Names follow a `project` or `<project>-cxx<std>` format, such as `cub-cpp20`, `thrust-cpp17`, or `libcudacxx`. Use `cmake --list-presets` to view available options. Build trees are placed under `build/${CCCL_BUILD_INFIX}/${PRESET}`.
4040

4141
### `.devcontainer/launch.sh`
4242

@@ -114,7 +114,7 @@ ci/util/build_and_test_targets.sh \
114114

115115
```bash
116116
ci/util/build_and_test_targets.sh \
117-
--preset libcudacxx-cpp20 \
117+
--preset libcudacxx \
118118
--lit-precompile-tests "std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp" \
119119
--lit-tests "std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp"
120120
```

CMakePresets.json

Lines changed: 27 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -121,63 +121,21 @@
121121
}
122122
},
123123
{
124-
"name": "libcudacxx-base",
125-
"hidden": true,
124+
"name": "libcudacxx",
126125
"inherits": "base",
127126
"cacheVariables": {
128127
"CCCL_ENABLE_LIBCUDACXX": true,
129128
"LIBCUDACXX_ENABLE_LIBCUDACXX_TESTS": true
130129
}
131130
},
132131
{
133-
"name": "libcudacxx-cpp17",
134-
"displayName": "libcu++: C++17",
135-
"inherits": "libcudacxx-base",
136-
"cacheVariables": {
137-
"CMAKE_CXX_STANDARD": "17",
138-
"CMAKE_CUDA_STANDARD": "17",
139-
"LIBCUDACXX_TEST_STANDARD_VER": "c++17"
140-
}
141-
},
142-
{
143-
"name": "libcudacxx-cpp20",
144-
"displayName": "libcu++: C++20",
145-
"inherits": "libcudacxx-base",
146-
"cacheVariables": {
147-
"CMAKE_CXX_STANDARD": "20",
148-
"CMAKE_CUDA_STANDARD": "20",
149-
"LIBCUDACXX_TEST_STANDARD_VER": "c++20"
150-
}
151-
},
152-
{
153-
"name": "libcudacxx-nvrtc-base",
154-
"hidden": true,
155-
"inherits": "libcudacxx-base",
132+
"name": "libcudacxx-nvrtc",
133+
"inherits": "libcudacxx",
156134
"cacheVariables": {
157135
"LIBCUDACXX_TEST_WITH_NVRTC": true,
158136
"CMAKE_CUDA_ARCHITECTURES": "70"
159137
}
160138
},
161-
{
162-
"name": "libcudacxx-nvrtc-cpp17",
163-
"displayName": "libcu++ NVRTC: C++17",
164-
"inherits": "libcudacxx-nvrtc-base",
165-
"cacheVariables": {
166-
"CMAKE_CXX_STANDARD": "17",
167-
"CMAKE_CUDA_STANDARD": "17",
168-
"LIBCUDACXX_TEST_STANDARD_VER": "c++17"
169-
}
170-
},
171-
{
172-
"name": "libcudacxx-nvrtc-cpp20",
173-
"displayName": "libcu++ NVRTC: C++20",
174-
"inherits": "libcudacxx-nvrtc-base",
175-
"cacheVariables": {
176-
"CMAKE_CXX_STANDARD": "20",
177-
"CMAKE_CUDA_STANDARD": "20",
178-
"LIBCUDACXX_TEST_STANDARD_VER": "c++20"
179-
}
180-
},
181139
{
182140
"name": "cub-base",
183141
"hidden": true,
@@ -363,6 +321,18 @@
363321
"name": "install",
364322
"configurePreset": "install"
365323
},
324+
{
325+
"name": "libcudacxx",
326+
"configurePreset": "libcudacxx",
327+
"targets": [
328+
"libcudacxx.test.internal_headers",
329+
"libcudacxx.test.public_headers",
330+
"libcudacxx.test.public_headers_host_only",
331+
"libcudacxx.test.lit.precompile",
332+
"libcudacxx.test.atomics.ptx",
333+
"libcudacxx.test.c2h_all"
334+
]
335+
},
366336
{
367337
"name": "libcudacxx-codegen",
368338
"configurePreset": "libcudacxx-codegen",
@@ -378,54 +348,12 @@
378348
]
379349
},
380350
{
381-
"name": "libcudacxx-nvrtcc",
382-
"hidden": true,
351+
"name": "libcudacxx-nvrtc",
352+
"configurePreset": "libcudacxx-nvrtc",
383353
"targets": [
384354
"libcudacxx.nvrtcc"
385355
]
386356
},
387-
{
388-
"name": "libcudacxx-base",
389-
"hidden": true,
390-
"targets": [
391-
"libcudacxx.test.internal_headers",
392-
"libcudacxx.test.public_headers",
393-
"libcudacxx.test.public_headers_host_only",
394-
"libcudacxx.test.lit.precompile",
395-
"libcudacxx.test.atomics.ptx",
396-
"libcudacxx.test.c2h_all"
397-
]
398-
},
399-
{
400-
"name": "libcudacxx-nvrtc-cpp17",
401-
"hidden": false,
402-
"inherits": [
403-
"libcudacxx-nvrtcc"
404-
],
405-
"configurePreset": "libcudacxx-nvrtc-cpp17"
406-
},
407-
{
408-
"name": "libcudacxx-nvrtc-cpp20",
409-
"hidden": false,
410-
"inherits": [
411-
"libcudacxx-nvrtcc"
412-
],
413-
"configurePreset": "libcudacxx-nvrtc-cpp20"
414-
},
415-
{
416-
"name": "libcudacxx-cpp17",
417-
"configurePreset": "libcudacxx-cpp17",
418-
"inherits": [
419-
"libcudacxx-base"
420-
]
421-
},
422-
{
423-
"name": "libcudacxx-cpp20",
424-
"configurePreset": "libcudacxx-cpp20",
425-
"inherits": [
426-
"libcudacxx-base"
427-
]
428-
},
429357
{
430358
"name": "cub-cpp17",
431359
"configurePreset": "cub-cpp17"
@@ -492,44 +420,27 @@
492420
{
493421
"name": "libcudacxx-codegen",
494422
"configurePreset": "libcudacxx-codegen",
423+
"inherits": "base",
495424
"filter": {
496425
"include": {
497426
"name": "^libcudacxx\\.test\\.atomics\\.codegen.*$"
498427
}
499428
}
500429
},
501430
{
502-
"name": "libcudacxx-ctest-base",
503-
"hidden": true,
504-
"inherits": [
505-
"base"
506-
],
431+
"name": "libcudacxx-ctest",
432+
"configurePreset": "libcudacxx",
433+
"inherits": "base",
507434
"filter": {
508435
"exclude": {
509436
"name": "^libcudacxx\\.test\\.lit$"
510437
}
511438
}
512439
},
513440
{
514-
"name": "libcudacxx-ctest-cpp17",
515-
"configurePreset": "libcudacxx-cpp17",
516-
"inherits": [
517-
"libcudacxx-ctest-base"
518-
]
519-
},
520-
{
521-
"name": "libcudacxx-ctest-cpp20",
522-
"configurePreset": "libcudacxx-cpp20",
523-
"inherits": [
524-
"libcudacxx-ctest-base"
525-
]
526-
},
527-
{
528-
"name": "libcudacxx-lit-base",
529-
"hidden": true,
530-
"inherits": [
531-
"base"
532-
],
441+
"name": "libcudacxx-lit",
442+
"configurePreset": "libcudacxx",
443+
"inherits": "base",
533444
"filter": {
534445
"include": {
535446
"name": "^libcudacxx\\.test\\.lit$"
@@ -541,39 +452,9 @@
541452
}
542453
},
543454
{
544-
"name": "libcudacxx-lit-cpp17",
545-
"configurePreset": "libcudacxx-cpp17",
546-
"inherits": [
547-
"libcudacxx-lit-base"
548-
]
549-
},
550-
{
551-
"name": "libcudacxx-lit-cpp20",
552-
"configurePreset": "libcudacxx-cpp20",
553-
"inherits": [
554-
"libcudacxx-lit-base"
555-
]
556-
},
557-
{
558-
"name": "libcudacxx-nvrtc-base",
559-
"hidden": true,
560-
"inherits": [
561-
"libcudacxx-lit-base"
562-
]
563-
},
564-
{
565-
"name": "libcudacxx-nvrtc-cpp17",
566-
"configurePreset": "libcudacxx-nvrtc-cpp17",
567-
"inherits": [
568-
"libcudacxx-nvrtc-base"
569-
]
570-
},
571-
{
572-
"name": "libcudacxx-nvrtc-cpp20",
573-
"configurePreset": "libcudacxx-nvrtc-cpp20",
574-
"inherits": [
575-
"libcudacxx-nvrtc-base"
576-
]
455+
"name": "libcudacxx-nvrtc",
456+
"configurePreset": "libcudacxx-nvrtc",
457+
"inherits": "libcudacxx-lit"
577458
},
578459
{
579460
"name": "cub-base",

ci/build_libcudacxx.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ source "$(dirname "${BASH_SOURCE[0]}")/build_common.sh"
66

77
print_environment_details
88

9-
PRESET="libcudacxx-cpp${CXX_STANDARD}"
10-
CMAKE_OPTIONS=""
9+
PRESET="libcudacxx"
10+
CMAKE_OPTIONS="-DCMAKE_CXX_STANDARD=${CXX_STANDARD} -DCMAKE_CUDA_STANDARD=${CXX_STANDARD}"
1111

1212
configure_and_build_preset libcudacxx "$PRESET" "$CMAKE_OPTIONS"
1313

ci/matrix.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ workflows:
1616
# - { jobs: ['run_gpu'], project: 'target', ctk: ['12.X', '13.X'], cxx: ['gcc', 'clang'], gpu: 'rtxa6000',
1717
# args: '--preset cub-cpp20 --build-targets "cub.cpp20.test.iterator" --ctest-targets "cub.cpp20.test.iterator"' }
1818
# - { jobs: ['run_cpu'], project: 'target', ctk: ['12.X', '13.X'], cxx: ['gcc', 'clang', 'msvc'],
19-
# args: '--preset libcudacxx-cpp20 --lit-precompile-tests "cuda/utility/basic_any.pass.cpp"' }
19+
# args: '--preset libcudacxx --lit-precompile-tests "cuda/utility/basic_any.pass.cpp"' }
2020
# - { jobs: ['run_gpu'], project: 'target', ctk: ['12.X', '13.X'], cxx: ['gcc', 'clang'], gpu: 'rtx2080',
21-
# args: '--preset libcudacxx-cpp20 --lit-tests "cuda/utility/basic_any.pass.cpp"' }
21+
# args: '--preset libcudacxx --lit-tests "cuda/utility/basic_any.pass.cpp"' }
2222
#
2323
override:
2424

ci/nvrtc_libcudacxx.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ source "$(dirname "${BASH_SOURCE[0]}")/build_common.sh"
55
print_environment_details
66

77

8-
PRESET="libcudacxx-nvrtc-cpp${CXX_STANDARD}"
9-
CMAKE_OPTIONS=""
8+
PRESET="libcudacxx-nvrtc"
9+
CMAKE_OPTIONS="-DCMAKE_CXX_STANDARD=${CXX_STANDARD} -DCMAKE_CUDA_STANDARD=${CXX_STANDARD}"
1010

1111
configure_and_build_preset "libcudacxx NVRTC" "$PRESET" "$CMAKE_OPTIONS"
1212

ci/test_libcudacxx.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ print_environment_details
77

88
"./build_libcudacxx.sh" "$@"
99

10-
PRESET="libcudacxx-cpp${CXX_STANDARD}"
11-
CMAKE_OPTIONS=""
10+
PRESET="libcudacxx"
11+
CMAKE_OPTIONS="-DCMAKE_CXX_STANDARD=${CXX_STANDARD} -DCMAKE_CUDA_STANDARD=${CXX_STANDARD}"
1212

1313
configure_preset libcudacxx "$PRESET" "$CMAKE_OPTIONS"
1414

15-
test_preset "libcudacxx (CTest)" "libcudacxx-ctest-cpp${CXX_STANDARD}"
15+
test_preset "libcudacxx (CTest)" "libcudacxx-ctest"
1616

1717
sccache -z > /dev/null || :
18-
test_preset "libcudacxx (lit)" "libcudacxx-lit-cpp${CXX_STANDARD}"
18+
test_preset "libcudacxx (lit)" "libcudacxx-lit"
1919
sccache --show-adv-stats || :
2020

2121
print_time_summary

ci/windows/build_libcudacxx.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ If($CURRENT_PATH -ne "ci") {
2222

2323
Import-Module $PSScriptRoot/build_common.psm1 -ArgumentList @($CXX_STANDARD, $CUDA_ARCH, $CMAKE_OPTIONS)
2424

25-
$PRESET = "libcudacxx-cpp${CXX_STANDARD}"
26-
$LOCAL_CMAKE_OPTIONS = ""
25+
$PRESET = "libcudacxx"
26+
$LOCAL_CMAKE_OPTIONS = "-DCMAKE_CXX_STANDARD=$CXX_STANDARD -DCMAKE_CUDA_STANDARD=$CXX_STANDARD"
2727

2828
configure_and_build_preset "libcudacxx" $PRESET $LOCAL_CMAKE_OPTIONS
2929

cmake/CCCLBuildCompilerTargets.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ function(
7676
endif()
7777
endif()
7878

79+
# Similarly, we expect the CXX and CUDA standards to match, if either is set:
80+
if (CCCL_TOPLEVEL_PROJECT AND (CMAKE_CXX_STANDARD OR CMAKE_CUDA_STANDARD))
81+
if (NOT CMAKE_CXX_STANDARD EQUAL CMAKE_CUDA_STANDARD)
82+
message(
83+
FATAL_ERROR
84+
"CCCL developer builds require that CMAKE_CXX_STANDARD matches "
85+
"CMAKE_CUDA_STANDARD when either is set:\n"
86+
"CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD}\n"
87+
"CMAKE_CUDA_STANDARD: ${CMAKE_CUDA_STANDARD}\n"
88+
"Rerun cmake with:\n"
89+
"\t\"-DCMAKE_CUDA_STANDARD=<std> -DCMAKE_CXX_STANDARD=<std>\"."
90+
)
91+
endif()
92+
endif()
93+
7994
add_library(${interface_target} INTERFACE)
8095

8196
foreach (cuda_option IN LISTS cuda_compile_options)

docs/cccl/development/build_and_bisect_tools.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@ Build and run a single CUB test in a devcontainer with specific CTK and host::
6868
Precompile the libcudacxx lit suite::
6969

7070
ci/util/build_and_test_targets.sh \
71-
--preset libcudacxx-cpp20 \
71+
--preset libcudacxx \
7272
--build-targets libcudacxx.test.lit.precompile
7373

7474
Precompile a single libcudacxx lit test (no execution)::
7575

7676
ci/util/build_and_test_targets.sh \
77-
--preset libcudacxx-cpp20 \
77+
--preset libcudacxx \
7878
--lit-precompile-tests \
7979
"std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp"
8080

8181
Execute one or more libcudacxx lit tests::
8282

8383
ci/util/build_and_test_targets.sh \
84-
--preset libcudacxx-cpp20 \
84+
--preset libcudacxx \
8585
--lit-tests \
8686
"std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp"
8787

0 commit comments

Comments
 (0)