-
Notifications
You must be signed in to change notification settings - Fork 326
Enhance RDC detection and add _CCCL_HAS_DEVICE_RUNTIME() macro
#7049
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,4 +48,45 @@ | |
| # define _CCCL_PDL_TRIGGER_NEXT_LAUNCH() | ||
| #endif // _CCCL_HAS_PDL() | ||
|
|
||
| // Check whether the relocatable device code (RDC) is being generated. | ||
| #if defined(__CUDACC_RDC__) || defined(__CLANG_RDC__) || defined(_NVHPC_RDC) | ||
| # define _CCCL_HAS_RDC() 1 | ||
| #else // ^^^ has RDC ^^^ / vvv no RDC vvv | ||
| # define _CCCL_HAS_RDC() 0 | ||
| #endif // ^^^ no RDC ^^^ | ||
|
|
||
| // Check whether extensible whole program is being compiled. | ||
| #if defined(__CUDACC_EWP__) | ||
| # define _CCCL_HAS_EWP() 1 | ||
| #else // ^^^ has EWP ^^^ / vvv no EWP vvv | ||
| # define _CCCL_HAS_EWP() 0 | ||
| #endif // ^^^ no EWP ^^^ | ||
|
|
||
| // Control whether device runtime APIs can be used, because they require libcudadevrt to be linked. Defaults to true | ||
| // when RDC or EWP are enabled. Can be disabled by defining CCCL_DISABLE_DEVICE_RUNTIME. | ||
| #if (_CCCL_HAS_RDC() || _CCCL_HAS_EWP()) && !defined(CCCL_DISABLE_DEVICE_RUNTIME) | ||
| # define _CCCL_HAS_DEVICE_RUNTIME() 1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. relocatable device code does not strictly require
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what do you mean. Using CUDA device runtime APIs require either RDC or EWP + link
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe I'm reading it in the wrong way.
these are perfectly fine. My issue is about RDC, relocatable device code. If we have RDC, this doesn't automatically translate in having
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not, because the user needn't to link |
||
| #else // ^^^ has device runtime ^^^ / vvv no device runtime vvv | ||
| # define _CCCL_HAS_DEVICE_RUNTIME() 0 | ||
| #endif // ^^^ no device runtime ^^^ | ||
|
|
||
| // Some functions can be called from host or device code and launch kernels inside. Thus, they use CUDA Dynamic | ||
| // Parallelism (CDP) and require compiling with Relocatable Device Code (RDC) or extensible whole program (EWP) and link | ||
| // with device runtime library. CDP is unsupported with clang-cuda below 22. | ||
| // TODO(bgruber): remove CUB_DISABLE_CDP in CCCL 4.0 | ||
| #if _CCCL_HAS_DEVICE_RUNTIME() && !defined(CCCL_DISABLE_CDP) && !defined(CUB_DISABLE_CDP) \ | ||
| && !_CCCL_CUDA_COMPILER(CLANG, <, 22) | ||
| // We have CDP, so host and device APIs can call kernels | ||
| # define _CCCL_HAS_CDP() 1 | ||
| #else // ^^^ has CDP ^^^ / vvv no CDP vvv | ||
| // We don't have CDP, only host APIs can call kernels | ||
| # define _CCCL_HAS_CDP() 0 | ||
| #endif // ^^^ no CDP ^^^ | ||
|
|
||
| #if _CCCL_HAS_CDP() | ||
| # ifdef CUDA_FORCE_CDP1_IF_SUPPORTED | ||
| # error "CUDA Dynamic Parallelism 1 is no longer supported. Please undefine CUDA_FORCE_CDP1_IF_SUPPORTED." | ||
| # endif // CUDA_FORCE_CDP1_IF_SUPPORTED | ||
| #endif // _CCCL_HAS_CDP() | ||
|
|
||
| #endif // __CCCL_CUDA_CAPABILITIES | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: this looks a bit weird, but I think it's correct. For nvc++,
_CCCL_HOST_COMPILATIONis defined for the combined host/device path, so we still need theNV_IF_TARGETinside.