Skip to content

Commit

Permalink
Try to just use int for cuda_error
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Jan 14, 2025
1 parent cb1346d commit d440fb4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 4 additions & 2 deletions libcudacxx/include/cuda/std/__cuda/api_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
# pragma system_header
#endif // no system header

#if _CCCL_HAS_CUDA_COMPILER
#if _CCCL_CUDA_COMPILER(CLANG)
# include <cuda_runtime_api.h>
#endif // _CCCL_CUDA_COMPILER(CLANG)

# include <cuda/std/__exception/cuda_error.h>
#include <cuda/std/__exception/cuda_error.h>

#if _CCCL_HAS_CUDA_COMPILER
# define _CCCL_TRY_CUDA_API(_NAME, _MSG, ...) \
{ \
const ::cudaError_t __status = _NAME(__VA_ARGS__); \
Expand Down
12 changes: 5 additions & 7 deletions libcudacxx/include/cuda/std/__exception/cuda_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
# pragma system_header
#endif // no system header

#include <cuda_runtime_api.h>

#include <cuda/std/__exception/terminate.h>

#if !_CCCL_COMPILER(NVRTC)
Expand All @@ -47,19 +45,19 @@ class cuda_error : public ::std::runtime_error
char __buffer[256];
};

static char* __format_cuda_error(::cudaError_t __status, const char* __msg, char* __msg_buffer) noexcept
static char* __format_cuda_error(const int __status, const char* __msg, char* __msg_buffer) noexcept
{
::snprintf(__msg_buffer, 256, "cudaError %d: %s", __status, __msg);
return __msg_buffer;
}

public:
cuda_error(::cudaError_t __status, const char* __msg, __msg_storage __msg_buffer = {0}) noexcept
cuda_error(const int __status, const char* __msg, __msg_storage __msg_buffer = {0}) noexcept
: ::std::runtime_error(__format_cuda_error(__status, __msg, __msg_buffer.__buffer))
{}
};

_CCCL_NORETURN _LIBCUDACXX_HIDE_FROM_ABI void __throw_cuda_error(::cudaError_t __status, const char* __msg)
_CCCL_NORETURN _LIBCUDACXX_HIDE_FROM_ABI void __throw_cuda_error(const int __status, const char* __msg)
{
NV_IF_ELSE_TARGET(NV_IS_HOST,
(throw ::cuda::cuda_error(__status, __msg);),
Expand All @@ -69,10 +67,10 @@ _CCCL_NORETURN _LIBCUDACXX_HIDE_FROM_ABI void __throw_cuda_error(::cudaError_t _
class cuda_error
{
public:
_LIBCUDACXX_HIDE_FROM_ABI cuda_error(::cudaError_t, const char*) noexcept {}
_LIBCUDACXX_HIDE_FROM_ABI cuda_error(const int, const char*) noexcept {}
};

_CCCL_NORETURN _LIBCUDACXX_HIDE_FROM_ABI void __throw_cuda_error(::cudaError_t, const char*)
_CCCL_NORETURN _LIBCUDACXX_HIDE_FROM_ABI void __throw_cuda_error(const int, const char*)
{
_CUDA_VSTD_NOVERSION::terminate();
}
Expand Down

0 comments on commit d440fb4

Please sign in to comment.