NVIDIA / NVIDIA/cccl

[BUG]: thrust/execution_policy.h is not safe to include when compiling with a host compiler

Open
#3,485 1 comment 0 reactions 0 assignees View on GitHub
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

This issue is an extension of #3483. If, given the same example from that issue, the CUDA runtime headers _are_ available, then compilation proceeds further but fails with this traceback
```
-- Build files have been written to: /home/vyasr/local/cccl/examples/basic/build
[ 50%] Building CXX object CMakeFiles/example_project.dir/example.cpp.o
In file included from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/cub/../../../cub/cub/detail/launcher/cuda_runtime.cuh:15,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/cub/../../../cub/cub/util_device.cuh:728,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/cuda/detail/util.h:41,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/cuda/detail/malloc_and_free.h:36,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/detail/adl/malloc_and_free.h:50,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/detail/generic/memory.inl:32,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/detail/generic/memory.h:70,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/detail/reference.h:38,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/memory.h:35,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/detail/allocator/temporary_allocator.h:31,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/detail/temporary_array.h:46,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/cuda/detail/internal/copy_cross_system.h:47,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/cuda/detail/copy.h:79,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/detail/adl/copy.h:50,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/detail/copy.inl:29,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/detail/copy.h:72,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/detail/sequential/merge.inl:28,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/detail/sequential/merge.h:81,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/cpp/detail/merge.h:30,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/cpp/execution_policy.h:59,
from /home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/execution_policy.h:40,
from /home/vyasr/local/cccl/examples/basic/example.cpp:1:
/home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/cuda/detail/core/triple_chevron_launch.h: In member function ‘cudaError_t thr
ust::THRUST_300000_SM___CUDA_ARCH_LIST___NS::cuda_cub::launcher::triple_chevron::doit_host(K, const Args& ...) const’:
/home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/cuda/detail/core/triple_chevron_launch.h:112:10: error: expected primary-expr
ession before ‘<’ token
112 | k<<>>(args...);
| ^
/home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/cuda/detail/core/triple_chevron_launch.h:112:44: error: expected primary-expr
ession before ‘>’ token
112 | k<<>>(args...);
| ^
/home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/cuda/detail/core/triple_chevron_launch.h:112:50: error: expected ‘)’ before ‘
...’ token
112 | k<<>>(args...);
| ^~~
/home/vyasr/local/cccl/examples/basic/build/_deps/cccl-src/lib/cmake/thrust/../../../thrust/thrust/system/cuda/detail/core/triple_chevron_launch.h:112:45: note: to match this ‘(’
112 | k<<>>(args...);
| ^
gmake[2]: *** [CMakeFiles/example_project.dir/build.make:76: CMakeFiles/example_project.dir/example.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:179: CMakeFiles/example_project.dir/all] Error 2
```

### How to Reproduce

Using this CMake (the same as #3483 except that now we use FindCUDAToolkit and link to cudart)
```
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
)
find_package(CUDAToolkit REQUIRED)
add_executable(example_project example.cpp)
target_link_libraries(example_project PRIVATE CCCL::CCCL CUDA::cudart)
```
and this C++ file (same as #3483)
```
#include
```
we observe the above compilation error.

### Expected behavior

I expect this to compile successfully.

### Reproduction link

_No response_

### Operating System

Ubuntu 24.04

### nvidia-smi output

N/A (not compiling for the GPU)

### NVCC version

N/A (not compiling with nvcc)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.