[BUG]: thrust/execution_policy.h is not safe to include without cuda runtime available
- Dominant language
- C++
- Stars
- 2.5k
- Forks
- 486
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 295
Description
### Is this a duplicate?
- [x] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this bug and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)
### Type of Bug
Compile-time Error
### Component
Thrust
### Describe the bug
Including the execution_policy.h file in a TU being compiled by a host compiler without the CUDA runtime libraries present triggers an immediate compile error:
```
In file included from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/cuda/config.h:48,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/cuda/detail/execution_policy.h:40,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/iterator/detail/device_system_tag.h:31,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/iterator/iterator_traits.h:74,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/detail/type_traits/pointer_traits.h:31,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/detail/allocator/allocator_traits.h:37,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/detail/execute_with_allocator.h:29,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/execution_policy.h:32,
from /home/vyasr/local/cccl/examples/basic/example.cpp:1:
/home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/cub/../../../cub/cub/detail/detect_cuda_runtime.cuh:49:12: fatal error: cuda_runtime_api.h: No such file or direct
ory
49 | # include
```
### How to Reproduce
With this CMake:
```
cmake_minimum_required(VERSION 3.26.1 FATAL_ERROR)
project(ExecutionPolicyError CXX)
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.2/CPM.cmake
${CMAKE_CURRENT_BINARY_DIR}/CPM.cmake LOG download_log)
include(${CMAKE_CURRENT_BINARY_DIR}/CPM.cmake)
CPMAddPackage(
NAME CCCL
GITHUB_REPOSITORY nvidia/cccl
GIT_TAG main
)
add_executable(example_project example.cpp)
target_link_libraries(example_project PRIVATE CCCL::CCCL)
```
and this C++ file
```
#include
```
running `cmake -S . -B build/ && cmake --build build/` is sufficient to trigger the compilation error.
### Expected behavior
Thrust should be safe to include in host TUs without the CUDA libraries available.
### Reproduction link
_No response_
### Operating System
Ubuntu Linux 24.04
### nvidia-smi output
N/A (not using GPU)
### NVCC version
N/A (not using nvcc)
Contributor guide
Assessment
This issue has not been assessed yet.