Error early when the CUDA backend is used without a CUDA compiler - #11059
Error early when the CUDA backend is used without a CUDA compiler#11059abdeltaehass wants to merge 2 commits into
Conversation
Including a Thrust header with the default CUDA device system and a non-CUDA compiler failed with ~1300 unrelated CUB errors that never named the cause. Add a check in thrust/system/cuda/config.h that reports it directly, with THRUST_IGNORE_CUDA_COMPILER_CHECK to opt out. Tested with clang++ and g++, C++17 and C++20: - message is now the first error for host_vector, sort, universal_vector and device_vector - thrust/version.h still compiles - THRUST_DEVICE_SYSTEM=CPP unaffected, 0 errors - silent under __CUDACC__ and _NVHPC_CUDA - opt-out macro restores the previous behavior Fixes NVIDIA#806
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughChangesCUDA diagnostic
Assessment against linked issues
Suggested reviewers: Merge Risk: ⚪ Minimal · up to This localized change improves the error shown when the CUDA backend is used without a CUDA compiler, without introducing a merge-blocking correctness or production risk; it is merge-ready after normal checks and review. Comment |
| #if !_CCCL_CUDA_COMPILATION() && !defined(THRUST_IGNORE_CUDA_COMPILER_CHECK) | ||
| # error The Thrust CUDA device system requires a CUDA compiler. Either compile as CUDA, or set \ | ||
| THRUST_DEVICE_SYSTEM to THRUST_DEVICE_SYSTEM_CPP, THRUST_DEVICE_SYSTEM_OMP, or THRUST_DEVICE_SYSTEM_TBB. \ | ||
| Define THRUST_IGNORE_CUDA_COMPILER_CHECK to ignore this. |
There was a problem hiding this comment.
I believe we conventionally add quotes around the error string
| #if !_CCCL_CUDA_COMPILATION() && !defined(THRUST_IGNORE_CUDA_COMPILER_CHECK) | |
| # error The Thrust CUDA device system requires a CUDA compiler. Either compile as CUDA, or set \ | |
| THRUST_DEVICE_SYSTEM to THRUST_DEVICE_SYSTEM_CPP, THRUST_DEVICE_SYSTEM_OMP, or THRUST_DEVICE_SYSTEM_TBB. \ | |
| Define THRUST_IGNORE_CUDA_COMPILER_CHECK to ignore this. | |
| #if !_CCCL_CUDA_COMPILATION() && !defined(THRUST_IGNORE_CUDA_COMPILER_CHECK) | |
| # error "The Thrust CUDA device system requires a CUDA compiler. Either compile as CUDA, or set \ | |
| THRUST_DEVICE_SYSTEM to THRUST_DEVICE_SYSTEM_CPP, THRUST_DEVICE_SYSTEM_OMP, or THRUST_DEVICE_SYSTEM_TBB. \ | |
| Define THRUST_IGNORE_CUDA_COMPILER_CHECK to ignore this." |
Review feedback: CCCL conventionally wraps #error strings in quotes.
Including a Thrust header with the default CUDA device system and a non-CUDA compiler failed with ~1300 unrelated CUB errors, starting with
unknown type name 'cudaError_t', none of which named the cause.This adds a check in
thrust/system/cuda/config.hthat reports it directly:It goes in
thrust/system/cuda/config.hrather thanthrust/detail/config/device_system.hbecausethrust/version.hincludes the latter and compiles fine without CUDA today. Placed here it also fires before CUB is pulled in, so the useful line comes first. It does not reduce the total error count, since#errordoes not stop preprocessing.Tested with clang++ and g++, C++17 and C++20:
host_vector,sort,universal_vectoranddevice_vectorthrust/version.hstill compilesTHRUST_DEVICE_SYSTEM=CPPunaffected, 0 errors__CUDACC__and_NVHPC_CUDATHRUST_IGNORE_CUDA_COMPILER_CHECKrestores the previous behaviorNo test is included: Thrust has no compile-failure test targets and all of its tests are
.cu, so there is no harness for a non-CUDA translation unit. The existingTHRUST_IGNORE_CUB_VERSION_CHECKerror in the same file is untested for the same reason. Happy to add one if you'd like it wired up.Fixes #806