CCCL Internal Macros
The document describes the main internal macros used by CCCL. They are not intended to be used by end users, but for development of CCCL features only. We reserve the right to change them at any time without warning.
Compiler Macros
Host compiler macros:
|
Clang |
|
GCC |
|
Nvidia HPC compiler |
|
Microsoft Visual Studio |
|
Microsoft Visual Studio 2019 |
|
Microsoft Visual Studio 2022 |
The _CCCL_COMPILER
function-like macro can also be used to check the version of a compiler.
_CCCL_COMPILER(MSVC, <, 19, 24)
_CCCL_COMPILER(GCC, >=, 9)
Pitfalls: _CCCL_COMPILER(GCC, >, 9)
internally expands _CCCL_COMPILER(GCC, >, 9, 0)
to matches any GCC 9.x. Avoid using >
and rather use >=
CUDA compiler macros:
|
Nvidia compiler |
|
Nvidia HPC compiler |
|
Nvidia Runtime Compiler |
|
Clang |
The _CCCL_CUDA_COMPILER
function-like macro can also be used to check the version of a compiler.
_CCCL_CUDA_COMPILER(NVCC, <, 12, 3)
_CCCL_CUDA_COMPILER(CLANG, >=, 14)
CUDA identification/version macros:
|
CUDA compiler is available |
|
CUDA version below 12.7 |
|
CUDA version at least 12.7 |
PTX macros:
|
Alias of |
|
PTX ISA version available with the current CUDA compiler, e.g. PTX ISA 8.4 ( |
Architecture Macros
The following macros are used to check the target architecture. They comply with the compiler supported by the CUDA toolkit. Compilers outside the CUDA toolkit may define such macros in a different way.
|
ARM 64-bit, including MSVC emulation |
|
X86 64-bit. False on ARM 64-bit MSVC emulation |
OS Macros
|
Windows, including NVRTC LLP64 |
|
Linux, including NVRTC LP64 |
|
Android |
|
QNX |
Execution Space
Functions
|
Host function |
|
Device function |
|
Host/Device function |
In addition, _CCCL_EXEC_CHECK_DISABLE
disables the execution space check for the NVHPC compiler
Target Macros
|
Enable |
|
Enable |
|
Enable a single code block if any of |
Possible TARGET
values:
|
Any target |
|
Host-code target |
|
Device-code target |
|
SM architecture is at least |
|
SM architecture is exactly |
Usage example:
NV_IF_TARGET(NV_IS_DEVICE, (auto x = threadIdx.x; return x;));
NV_IF_ELSE_TARGET(NV_IS_HOST, (return 0;), (auto x = threadIdx.x; return x;));
NV_DISPATCH_TARGET(NV_PROVIDES_SM_90, (return "Hopper+";),
NV_IS_EXACTLY_SM_75, (return "Turing";),
NV_IS_HOST, (return "Host";))
Pitfalls:
All target macros generate the code in a local scope, i.e.
{ code }
.NV_DISPATCH_TARGET
is NOT a switch statement. It enables the code associated with the first condition satisfied.The target macros take
code
as an argument, so it is not possible to use any conditional compilation, .e.g#if _CCCL_STD_VER >= 20
within a target macro
CUDA attributes
|
Grid constant kernel parameter |
|
Host/device global scope constant ( |
Non-standard Types Support
|
|
|
|
|
|
|
|
|
|
|
Disable |
|
Disable |
|
Disable |
|
Disable |
|
Disable |
|
|
|
|
C++ Language Macros
The following macros are required only if the target C++ version does not support the corresponding attribute
|
C++ standard version, e.g. |
|
Portable |
|
Enable |
|
Enable |
|
Enable |
|
Enable |
|
Portable |
Concept-like Macros:
|
|
|
|
|
Selects variable template |
|
Traits conjunction only used with |
Usage example:
_CCCL_TEMPLATE(typename T)
_CCCL_REQUIRES(_CCCL_TRAIT(is_integral, T) _CCCL_AND(sizeof(T) > 1))
_CCCL_TEMPLATE(typename T)
_CCCL_REQUIRES(_CCCL_TRAIT(is_arithmetic, T) _CCCL_AND (!_CCCL_TRAIT(is_integral, T)))
Portable feature testing:
|
Portable |
|
Portable |
|
Portable |
Portable attributes:
|
Portable |
|
Portable |
|
Portable |
|
Portable |
|
Portable |
|
Portable |
|
Portable |
|
Portable |
|
Portable “always inline” attribute |
Portable Builtin Macros:
|
Portable |
|
Portable |
|
Portable |
|
Portable |
Portable Keyword Macros
|
Portable |
|
Portable |
|
Portable |
|
Portable |
Visibility Macros
|
Hidden visibility attribute (e.g. |
|
Hidden visibility (i.e. |
|
Host/device function with hidden visibility. Most libcu++ functions are hidden with this attribute |
Other Common Macros
|
|
|
|
|
Defined during Doxygen parsing |
Debugging Macros
|
Portable CCCL assert macro. Requires ( |
|
Portable |
|
Enable assertions |
|
Enable host-side assertions |
|
Enable device-side assertions |
|
Enable debug mode (and assertions) |
Warning Suppression Macros
|
Portable |
|
Portable |
|
Push common msvc warning suppressions |
|
Pop common msvc warning suppressions |
Compiler-specific Suppression Macros:
|
Suppress clang warning, e.g. |
|
Suppress gcc warning, e.g. |
|
Suppress nvhpc warning, e.g. |
|
Suppress msvc warning, e.g. |
|
Suppress nvcc warning, e.g. |
Usage example:
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_GCC("-Wattributes")
// code ..
_CCCL_DIAG_POP