Skip to content
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

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

Open
1 task done
vyasr opened this issue Jan 22, 2025 · 1 comment
Open
1 task done
Labels
bug Something isn't working right.

Comments

@vyasr
Copy link
Contributor

vyasr commented Jan 22, 2025

Is this a duplicate?

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<<<grid, block, shared_mem, stream>>>(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<<<grid, block, shared_mem, stream>>>(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<<<grid, block, shared_mem, stream>>>(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<<<grid, block, shared_mem, stream>>>(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 <thrust/execution_policy.h>

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)

@vyasr vyasr added the bug Something isn't working right. label Jan 22, 2025
@github-project-automation github-project-automation bot moved this to Todo in CCCL Jan 22, 2025
@vyasr
Copy link
Contributor Author

vyasr commented Jan 22, 2025

#3378 by @caugonnet is a potential fix for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working right.
Projects
Status: Todo
Development

No branches or pull requests

1 participant