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

Closed
1 task done
caugonnet opened this issue Jan 14, 2025 · 4 comments · Fixed by #3472
Closed
1 task done
Assignees
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
@miscco miscco self-assigned this Jan 15, 2025
@bdice
Copy link
Contributor

bdice commented Jan 21, 2025

Thanks @caugonnet for filing this. This is also blocking my work to add Cython bindings for any_resource (#2824) in RMM. I cannot build RMM with a new CCCL version.

@jrhemstad
Copy link
Collaborator

@miscco @wmaxey don't we do host-only compiler testing for libcu++ headers already?

@vyasr
Copy link
Contributor

vyasr commented Jan 21, 2025

Note that this is currently the (proximate, perhaps not terminal) cause of the failures of the RAPIDS builds in CI.

@miscco
Copy link
Collaborator

miscco commented Jan 21, 2025

@miscco @wmaxey don't we do host-only compiler testing for libcu++ headers already?

Yes we do but we intentionally did not test the headers in <cuda/...> but only those in <cuda/std/...>

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
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants