Skip to content

Commit bb1c7e7

Browse files
authored
Move our CUDACC version checks towards the new version check design (#2826)
* Move our CUDACC version checks towards the new version check design While we are at it just drop _CCCL_CUDACC_VER_BUILD, we never care about that
1 parent 649035a commit bb1c7e7

Some content is hidden

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

55 files changed

+160
-186
lines changed

cub/cub/agent/agent_merge.cuh

+3-3
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ struct agent_t
172172

173173
// if items are provided, merge them
174174
static constexpr bool have_items = !std::is_same<item_type, NullType>::value;
175-
#ifdef _CCCL_CUDACC_BELOW_11_8
175+
#if _CCCL_CUDACC_BELOW(11, 8)
176176
if (have_items) // nvcc 11.1 cannot handle #pragma unroll inside if constexpr but 11.8 can.
177177
// nvcc versions between may work
178-
#else
178+
#else // ^^^ _CCCL_CUDACC_BELOW(11, 8) ^^^ / vvv _CCCL_CUDACC_AT_LEAST(11, 8)
179179
_CCCL_IF_CONSTEXPR (have_items)
180-
#endif
180+
#endif // _CCCL_CUDACC_AT_LEAST(11, 8)
181181
{
182182
item_type items_loc[items_per_thread];
183183
gmem_to_reg<threads_per_block, IsFullTile>(

cub/cub/agent/agent_merge_sort.cuh

+3-3
Original file line numberDiff line numberDiff line change
@@ -634,12 +634,12 @@ struct AgentMerge
634634
}
635635

636636
// if items are provided, merge them
637-
#ifdef _CCCL_CUDACC_BELOW_11_8
637+
#if _CCCL_CUDACC_BELOW(11, 8)
638638
if (!KEYS_ONLY) // nvcc 11.1 cannot handle #pragma unroll inside if constexpr but 11.8 can.
639639
// nvcc versions between may work
640-
#else
640+
#else // ^^^ _CCCL_CUDACC_BELOW(11, 8) ^^^ / vvv _CCCL_CUDACC_AT_LEAST(11, 8)
641641
_CCCL_IF_CONSTEXPR (!KEYS_ONLY)
642-
#endif
642+
#endif // _CCCL_CUDACC_AT_LEAST(11, 8)
643643
{
644644
CTA_SYNC();
645645

cub/cub/device/dispatch/dispatch_transform.cuh

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
# pragma system_header
1414
#endif // no system header
1515

16-
#if defined(_CCCL_CUDA_COMPILER) && _CCCL_CUDACC_VER < 1105000
16+
#if defined(_CCCL_CUDA_COMPILER) && _CCCL_CUDACC_BELOW(11, 5)
1717
_CCCL_NV_DIAG_SUPPRESS(186)
1818
# include <cuda_pipeline_primitives.h>
1919
// we cannot re-enable the warning here, because it is triggered outside the translation unit
2020
// see also: https://godbolt.org/z/1x8b4hn3G
21-
#endif // defined(_CCCL_CUDA_COMPILER) && _CCCL_CUDACC_VER < 1105000
21+
#endif // defined(_CCCL_CUDA_COMPILER) && _CCCL_CUDACC_BELOW(11, 5)
2222

2323
#include <cub/detail/uninitialized_copy.cuh>
2424
#include <cub/util_arch.cuh>
@@ -55,9 +55,9 @@ CUB_NAMESPACE_BEGIN
5555

5656
// The ublkcp kernel needs PTX features that are only available and understood by nvcc >=12.
5757
// Also, cooperative groups do not support NVHPC yet.
58-
#if _CCCL_CUDACC_VER_MAJOR >= 12 && !defined(_CCCL_CUDA_COMPILER_NVHPC)
58+
#if _CCCL_CUDACC_AT_LEAST(12, 0) && !defined(_CCCL_CUDA_COMPILER_NVHPC)
5959
# define _CUB_HAS_TRANSFORM_UBLKCP
60-
#endif // _CCCL_CUDACC_VER_MAJOR >= 12 && !defined(_CCCL_CUDA_COMPILER_NVHPC)
60+
#endif // _CCCL_CUDACC_AT_LEAST(12, 0) && !defined(_CCCL_CUDA_COMPILER_NVHPC)
6161

6262
namespace detail
6363
{

cub/cub/launcher/cuda_driver.cuh

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# pragma system_header
1111
#endif // no system header
1212

13-
#if !defined(_CCCL_CUDACC_BELOW_12_0)
13+
#if _CCCL_CUDACC_AT_LEAST(12, 0)
1414

1515
# include <cuda.h>
1616

@@ -80,4 +80,4 @@ struct CudaDriverLauncherFactory
8080

8181
CUB_NAMESPACE_END
8282

83-
#endif // !defined(_CCCL_CUDACC_BELOW_12_0)
83+
#endif // _CCCL_CUDACC_AT_LEAST(12, 0)

cub/cub/util_type.cuh

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
#include <cuda/std/type_traits>
5252

5353
#if defined(_CCCL_HAS_NVBF16)
54-
# if !defined(_CCCL_CUDACC_BELOW_11_8)
54+
# if _CCCL_CUDACC_AT_LEAST(11, 8)
5555
// cuda_fp8.h resets default for C4127, so we have to guard the inclusion
5656
_CCCL_DIAG_PUSH
5757
# include <cuda_fp8.h>
5858
_CCCL_DIAG_POP
59-
# endif // !_CCCL_CUDACC_BELOW_11_8
59+
# endif // _CCCL_CUDACC_AT_LEAST(11, 8)
6060
#endif // _CCCL_HAS_NV_BF16
6161

6262
#ifdef _CCCL_COMPILER_NVRTC
@@ -73,12 +73,12 @@ CUB_NAMESPACE_BEGIN
7373
# define CUB_IS_INT128_ENABLED 1
7474
# endif // !defined(__CUDACC_RTC_INT128__)
7575
# else // !defined(__CUDACC_RTC__)
76-
# if _CCCL_CUDACC_VER >= 1105000
76+
# if _CCCL_CUDACC_AT_LEAST(11, 5)
7777
# if defined(_CCCL_COMPILER_GCC) || defined(_CCCL_COMPILER_CLANG) || defined(_CCCL_COMPILER_ICC) \
7878
|| _CCCL_COMPILER(NVHPC)
7979
# define CUB_IS_INT128_ENABLED 1
8080
# endif // GCC || CLANG || ICC || NVHPC
81-
# endif // CTK >= 11.5
81+
# endif // _CCCL_CUDACC_AT_LEAST(11, 5)
8282
# endif // !defined(__CUDACC_RTC__)
8383
#endif // !defined(CUB_IS_INT128_ENABLED)
8484

cudax/include/cuda/experimental/__detail/config.cuh

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// Debuggers do not step into functions marked with __attribute__((__artificial__)).
2525
// This is useful for small wrapper functions that just dispatch to other functions and
2626
// that are inlined into the caller.
27-
#if _CCCL_HAS_ATTRIBUTE(__artificial__) && !defined(_CCCL_CUDACC)
27+
#if _CCCL_HAS_ATTRIBUTE(__artificial__) && !_CCCL_CUDACC
2828
# define _CUDAX_ARTIFICIAL __attribute__((__artificial__))
2929
#else // ^^^ _CCCL_HAS_ATTRIBUTE(__artificial__) ^^^ / vvv !_CCCL_HAS_ATTRIBUTE(__artificial__) vvv
3030
# define _CUDAX_ARTIFICIAL

cudax/include/cuda/experimental/__memory_resource/device_memory_pool.cuh

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#endif // no system header
2323

2424
// cudaMallocAsync was introduced in CTK 11.2
25-
#if !defined(_CCCL_COMPILER_MSVC_2017) && !defined(_CCCL_CUDACC_BELOW_11_2)
25+
#if !defined(_CCCL_COMPILER_MSVC_2017) && _CCCL_CUDACC_AT_LEAST(11, 2)
2626

2727
# if defined(_CCCL_CUDA_COMPILER_CLANG)
2828
# include <cuda_runtime.h>
@@ -133,7 +133,7 @@ private:
133133
static void __cuda_supports_export_handle_type(const int __device_id, cudaMemAllocationHandleType __handle_type)
134134
{
135135
int __supported_handles = static_cast<int>(cudaMemAllocationHandleType::cudaMemHandleTypeNone);
136-
# if !defined(_CCCL_CUDACC_BELOW_11_3)
136+
# if _CCCL_CUDACC_AT_LEAST(11, 3)
137137
if (__handle_type != cudaMemAllocationHandleType::cudaMemHandleTypeNone)
138138
{
139139
const ::cudaError_t __status =
@@ -152,7 +152,7 @@ private:
152152
::cuda::__throw_cuda_error(__status, "Failed to call cudaDeviceGetAttribute");
153153
}
154154
}
155-
# endif //_CCCL_CUDACC_BELOW_11_3
155+
# endif // _CCCL_CUDACC_BELOW(11, 3)
156156
if ((static_cast<int>(__handle_type) & __supported_handles) != static_cast<int>(__handle_type))
157157
{
158158
::cuda::__throw_cuda_error(
@@ -428,6 +428,6 @@ public:
428428

429429
# endif // _CCCL_STD_VER >= 2014
430430

431-
#endif // !_CCCL_COMPILER_MSVC_2017 && !_CCCL_CUDACC_BELOW_11_2
431+
#endif // !_CCCL_COMPILER_MSVC_2017 && _CCCL_CUDACC_AT_LEAST(11, 2)
432432

433433
#endif // _CUDAX__MEMORY_RESOURCE_DEVICE_MEMORY_POOL

cudax/include/cuda/experimental/__memory_resource/device_memory_resource.cuh

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#endif // no system header
2323

2424
// cudaMallocAsync was introduced in CTK 11.2
25-
#if !defined(_CCCL_COMPILER_MSVC_2017) && !defined(_CCCL_CUDACC_BELOW_11_2)
25+
#if !defined(_CCCL_COMPILER_MSVC_2017) && _CCCL_CUDACC_AT_LEAST(11, 2)
2626

2727
# if defined(_CCCL_CUDA_COMPILER_CLANG)
2828
# include <cuda_runtime.h>
@@ -417,6 +417,6 @@ static_assert(_CUDA_VMR::resource_with<device_memory_resource, _CUDA_VMR::device
417417

418418
# endif // _CCCL_STD_VER >= 2014
419419

420-
#endif // !_CCCL_COMPILER_MSVC_2017 && !_CCCL_CUDACC_BELOW_11_2
420+
#endif // !_CCCL_COMPILER_MSVC_2017 && _CCCL_CUDACC_AT_LEAST(11, 2)
421421

422422
#endif //_CUDAX__MEMORY_RESOURCE_CUDA_DEVICE_MEMORY_RESOURCE

cudax/test/memory_resource/device_memory_pool.cu

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ TEST_CASE("device_memory_pool construction", "[memory_resource]")
144144
}
145145

146146
// Allocation handles are only supported after 11.2
147-
#if !defined(_CCCL_CUDACC_BELOW_11_2)
147+
#if _CCCL_CUDACC_AT_LEAST(11, 2)
148148
SECTION("Construct with allocation handle")
149149
{
150150
cudax::mr::memory_pool_properties props = {
@@ -163,7 +163,7 @@ TEST_CASE("device_memory_pool construction", "[memory_resource]")
163163
// Ensure that we disable export
164164
CHECK(ensure_export_handle(get, static_cast<cudaMemAllocationHandleType>(props.allocation_handle_type)));
165165
}
166-
#endif // !_CCCL_CUDACC_BELOW_11_2
166+
#endif // _CCCL_CUDACC_AT_LEAST(11, 2)
167167

168168
SECTION("Take ownership of native handle")
169169
{

cudax/test/memory_resource/device_memory_resource.cu

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ TEST_CASE("device_memory_resource construction", "[memory_resource]")
191191
}
192192

193193
// Allocation handles are only supported after 11.2
194-
#if !defined(_CCCL_CUDACC_BELOW_11_2)
194+
#if _CCCL_CUDACC_AT_LEAST(11, 2)
195195
SECTION("Construct with allocation handle")
196196
{
197197
cuda::experimental::mr::memory_pool_properties props = {
@@ -214,7 +214,7 @@ TEST_CASE("device_memory_resource construction", "[memory_resource]")
214214
// Ensure that we disable export
215215
CHECK(ensure_export_handle(get, static_cast<cudaMemAllocationHandleType>(props.allocation_handle_type)));
216216
}
217-
#endif // !_CCCL_CUDACC_BELOW_11_2
217+
#endif // _CCCL_CUDACC_AT_LEAST(11, 2)
218218
}
219219

220220
static void ensure_device_ptr(void* ptr)

docs/repo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ doxygen_predefined = [
402402
"__device__",
403403
"__host__",
404404
"__global__",
405+
"_CCCL_CUDACC_AT_LEAST(x, y)=1",
406+
"_CCCL_CUDACC_BELOW(x, y)=0",
405407
"_CCCL_DEVICE=",
406408
"_CCCL_EXEC_CHECK_DISABLE=",
407409
"_CCCL_FORCEINLINE=",

libcudacxx/include/cuda/std/__cccl/attributes.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
// However, MSVC implements [[msvc::no_unique_address]] which does what
6565
// [[no_unique_address]] is supposed to do, in general.
6666
# define _CCCL_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
67-
#elif defined(_CCCL_CUDACC_BELOW_11_3) || (_CCCL_HAS_CPP_ATTRIBUTE(no_unique_address) < 201803L)
67+
#elif _CCCL_CUDACC_BELOW(11, 3) || (_CCCL_HAS_CPP_ATTRIBUTE(no_unique_address) < 201803L)
6868
# define _CCCL_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS
6969
# define _CCCL_NO_UNIQUE_ADDRESS
7070
#elif _CCCL_HAS_CPP_ATTRIBUTE(no_unique_address)
@@ -88,18 +88,18 @@
8888

8989
// NVCC below 11.3 does not support nodiscard on friend operators
9090
// It always fails with clang
91-
#if defined(_CCCL_CUDACC_BELOW_11_3) || defined(_CCCL_COMPILER_CLANG)
91+
#if _CCCL_CUDACC_BELOW(11, 3) || defined(_CCCL_COMPILER_CLANG)
9292
# define _CCCL_NODISCARD_FRIEND friend
93-
#else // ^^^ _CCCL_CUDACC_BELOW_11_3 ^^^ / vvv !_CCCL_CUDACC_BELOW_11_3 vvv
93+
#else // ^^^ _CCCL_CUDACC_BELOW(11, 3) ^^^ / vvv _CCCL_CUDACC_AT_LEAST(11, 3) vvv
9494
# define _CCCL_NODISCARD_FRIEND _CCCL_NODISCARD friend
95-
#endif // !_CCCL_CUDACC_BELOW_11_3 && !_CCCL_COMPILER_CLANG
95+
#endif // _CCCL_CUDACC_AT_LEAST(11, 3) && !_CCCL_COMPILER_CLANG
9696

9797
// NVCC below 11.3 does not support attributes on alias declarations
98-
#ifdef _CCCL_CUDACC_BELOW_11_3
98+
#if _CCCL_CUDACC_BELOW(11, 3)
9999
# define _CCCL_ALIAS_ATTRIBUTE(...)
100-
#else // ^^^ _CCCL_CUDACC_BELOW_11_3 ^^^ / vvv !_CCCL_CUDACC_BELOW_11_3 vvv
100+
#else // ^^^ _CCCL_CUDACC_BELOW(11, 3) ^^^ / vvv _CCCL_CUDACC_AT_LEAST(11, 3) vvv
101101
# define _CCCL_ALIAS_ATTRIBUTE(...) __VA_ARGS__
102-
#endif // !_CCCL_CUDACC_BELOW_11_3
102+
#endif // _CCCL_CUDACC_AT_LEAST(11, 3)
103103

104104
#if defined(_CCCL_COMPILER_MSVC)
105105
# define _CCCL_NORETURN __declspec(noreturn)

0 commit comments

Comments
 (0)