From 007c0bdb2c145ca43b4fc88108c09fabce035c73 Mon Sep 17 00:00:00 2001 From: Cedric Augonnet Date: Mon, 13 Jan 2025 22:33:42 +0100 Subject: [PATCH 1/2] Ensure cuda/stream_ref can be used without a CUDA compiler --- libcudacxx/include/cuda/stream_ref | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libcudacxx/include/cuda/stream_ref b/libcudacxx/include/cuda/stream_ref index a8b044909eb..ffa548003d6 100644 --- a/libcudacxx/include/cuda/stream_ref +++ b/libcudacxx/include/cuda/stream_ref @@ -164,7 +164,11 @@ public: break; default: ::cudaGetLastError(); // Clear CUDA error state +#ifdef _CCCL_HAS_CUDA_COMPILER ::cuda::__throw_cuda_error(__result, "Failed to query stream."); +#else + throw ::std::runtime_error("Failed to query stream."); +#endif } return true; } From 6b0eb76c9d468800db1eb46f26251364534f2851 Mon Sep 17 00:00:00 2001 From: Cedric Augonnet Date: Tue, 14 Jan 2025 09:25:37 +0100 Subject: [PATCH 2/2] Take _CCCL_NO_EXCEPTIONS into accounts --- libcudacxx/include/cuda/stream_ref | 38 +++++++++++++++++------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/libcudacxx/include/cuda/stream_ref b/libcudacxx/include/cuda/stream_ref index ffa548003d6..df22c7adc19 100644 --- a/libcudacxx/include/cuda/stream_ref +++ b/libcudacxx/include/cuda/stream_ref @@ -9,7 +9,7 @@ //===----------------------------------------------------------------------===// #ifndef _CUDA_STREAM_REF -#define _CUDA_STREAM_REF +# define _CUDA_STREAM_REF /* stream_ref synopsis @@ -38,22 +38,22 @@ private: } // cuda */ -#include +# include // cuda_runtime_api needs to come first -#include +# include -#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) -# pragma GCC system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) -# pragma clang system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) -# pragma system_header -#endif // no system header +# if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) +# pragma GCC system_header +# elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) +# pragma clang system_header +# elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) +# pragma system_header +# endif // no system header -#include -#include -#include +# include +# include +# include _LIBCUDACXX_BEGIN_NAMESPACE_CUDA @@ -164,11 +164,15 @@ public: break; default: ::cudaGetLastError(); // Clear CUDA error state -#ifdef _CCCL_HAS_CUDA_COMPILER +# ifdef _CCCL_HAS_CUDA_COMPILER ::cuda::__throw_cuda_error(__result, "Failed to query stream."); -#else +# else +# ifndef _CCCL_NO_EXCEPTIONS throw ::std::runtime_error("Failed to query stream."); -#endif +# else + ::std::terminate(); +# else +# endif } return true; } @@ -190,4 +194,4 @@ public: _LIBCUDACXX_END_NAMESPACE_CUDA -#endif //_CUDA_STREAM_REF +# endif //_CUDA_STREAM_REF