libcudf  24.04.00
Files | Classes | Macros
Exception

Files

file  error.hpp
 

Classes

struct  cudf::stacktrace_recorder
 The struct to store the current stacktrace upon its construction. More...
 
struct  cudf::logic_error
 Exception thrown when logical precondition is violated. More...
 
struct  cudf::cuda_error
 Exception thrown when a CUDA error is encountered. More...
 
struct  cudf::fatal_cuda_error
 
struct  cudf::data_type_error
 Exception thrown when an operation is attempted on an unsupported dtype. More...
 

Macros

#define CUDF_EXPECTS(...)
 Macro for checking (pre-)conditions that throws an exception when a condition is violated. More...
 
#define CUDF_FAIL(...)
 Indicates that an erroneous code path has been taken. More...
 
#define CUDF_CUDA_TRY(call)
 Error checking macro for CUDA runtime API functions. More...
 
#define CUDF_CHECK_CUDA(stream)
 Debug macro to check for CUDA errors. More...
 

Detailed Description

Macro Definition Documentation

◆ CUDF_CHECK_CUDA

#define CUDF_CHECK_CUDA (   stream)
Value:
do { \
CUDF_CUDA_TRY(cudaStreamSynchronize(stream)); \
CUDF_CUDA_TRY(cudaPeekAtLastError()); \
} while (0);

Debug macro to check for CUDA errors.

In a non-release build, this macro will synchronize the specified stream before error checking. In both release and non-release builds, this macro checks for any pending CUDA errors from previous calls. If an error is reported, an exception is thrown detailing the CUDA error that occurred.

The intent of this macro is to provide a mechanism for synchronous and deterministic execution for debugging asynchronous CUDA execution. It should be used after any asynchronous CUDA call, e.g., cudaMemcpyAsync, or an asynchronous kernel launch.

Definition at line 283 of file error.hpp.

◆ CUDF_CUDA_TRY

#define CUDF_CUDA_TRY (   call)
Value:
do { \
cudaError_t const status = (call); \
if (cudaSuccess != status) { cudf::detail::throw_cuda_error(status, __FILE__, __LINE__); } \
} while (0);

Error checking macro for CUDA runtime API functions.

Invokes a CUDA runtime API function call, if the call does not return cudaSuccess, invokes cudaGetLastError() to clear the error and throws an exception detailing the CUDA error that occurred

Definition at line 263 of file error.hpp.

◆ CUDF_EXPECTS

#define CUDF_EXPECTS (   ...)
Value:
GET_CUDF_EXPECTS_MACRO(__VA_ARGS__, CUDF_EXPECTS_3, CUDF_EXPECTS_2) \
(__VA_ARGS__)

Macro for checking (pre-)conditions that throws an exception when a condition is violated.

Defaults to throwing cudf::logic_error, but a custom exception may also be specified.

Example usage:

// throws cudf::logic_error
CUDF_EXPECTS(p != nullptr, "Unexpected null pointer");
// throws std::runtime_error
CUDF_EXPECTS(p != nullptr, "Unexpected nullptr", std::runtime_error);
#define CUDF_EXPECTS(...)
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
Definition: error.hpp:177
Parameters
...This macro accepts either two or three arguments:
  • The first argument must be an expression that evaluates to true or false, and is the condition being checked.
  • The second argument is a string literal used to construct the what of the exception.
  • When given, the third argument is the exception to be thrown. When not specified, defaults to cudf::logic_error.
Exceptions
<tt>_exception_type</tt>if the condition evaluates to 0 (false).

Definition at line 177 of file error.hpp.

◆ CUDF_FAIL

#define CUDF_FAIL (   ...)
Value:
GET_CUDF_FAIL_MACRO(__VA_ARGS__, CUDF_FAIL_2, CUDF_FAIL_1) \
(__VA_ARGS__)

Indicates that an erroneous code path has been taken.

Example usage:

{c++}
// Throws `cudf::logic_error`
CUDF_FAIL("Unsupported code path");
// Throws `std::runtime_error`
CUDF_FAIL("Unsupported code path", std::runtime_error);
#define CUDF_FAIL(...)
Indicates that an erroneous code path has been taken.
Definition: error.hpp:216
Parameters
...This macro accepts either one or two arguments:
  • The first argument is a string literal used to construct the what of the exception.
  • When given, the second argument is the exception to be thrown. When not specified, defaults to cudf::logic_error.
Exceptions
<tt>_exception_type</tt>if the condition evaluates to 0 (false).

Definition at line 216 of file error.hpp.