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]: Libcudaxx headers such as <cuda/stream_ref> should compile even without CUDA compilers #3372

Open
1 task done
caugonnet opened this issue Jan 14, 2025 · 0 comments
Labels
bug Something isn't working right.

Comments

@caugonnet
Copy link
Contributor

Is this a duplicate?

Type of Bug

Compile-time Error

Component

libcu++

Describe the bug

When using non CUDA compilers on the <cuda/stream_ref> header from libcudacxx, the ::cuda::__throw_cuda_error(__result, "Failed to query stream."); call is not compiling because libcudacxx/include/cuda/std/__exception/cuda_error.h only defines __throw_cuda_error for CUDA compilers.

This issue is raised in practice when compiling cuGraph with a recent version of CCCL.

One strategy could be to implement ::cuda::__throw_cuda_error for non CUDA compilers (#3369 ) but the first argument is a cudaError_t which is not necessarily defined (eg. in Thrust with a host backend). Pretending we did implement it by simply throwing away the cuda error is also a suspicious strategy.

The other strategy is to adapt call sites (<cuda/stream_ref> in this case) to avoid ::cuda::__throw_cuda_error. This is what #3370 implements, but does a lot of code bloating to replace ::cuda::__throw_cuda_error(__result, "Failed to query stream."); in the "unlikely" situation where we have a non CUDA compiler.

#  ifdef _CCCL_HAS_CUDA_COMPILER
        ::cuda::__throw_cuda_error(__result, "Failed to query stream.");
#  else
#    ifndef _CCCL_NO_EXCEPTIONS
        throw ::std::runtime_error("Failed to query stream.");
#    else
        ::std::terminate();
#    else
#    endif

How to Reproduce

Compile the cpp lib for that branch which updates CCCL in cuGraph rapidsai/cugraph#4833

Expected behavior

  • Provide a <cuda/stream_ref> which can be included from any C++ compiler
  • Define/Document whether ::cuda::__throw_cuda_error can be used without a CUDA compiler

Infrastructure :

  • Possibly add CI tests to assess whether CCCL features are available on non CUDA compilers
  • Automatically check in CI that all headers can be included from g++/clang even if features are disabled (generating some simple code that includes the file with an int main() {} ?)

Reproduction link

No response

Operating System

No response

nvidia-smi output

No response

NVCC version

No response

@caugonnet caugonnet added the bug Something isn't working right. label Jan 14, 2025
@github-project-automation github-project-automation bot moved this to Todo in CCCL Jan 14, 2025
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