Utility Error#
- group utility_error
Defines
-
CUDF_EXPECTS(...)#
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);
- 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
.
- Throws <tt>_exception_type</tt>:
if the condition evaluates to 0 (false).
-
CUDF_FAIL(...)#
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);
- 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
.
- Throws <tt>_exception_type</tt>:
if the condition evaluates to 0 (false).
-
CUDF_CUDA_TRY(call)#
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
-
CUDF_CHECK_CUDA(stream)#
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.
-
struct stacktrace_recorder#
- #include <error.hpp>
The struct to store the current stacktrace upon its construction.
Subclassed by cudf::cuda_error, cudf::data_type_error, cudf::logic_error
Public Functions
-
inline char const *stacktrace() const#
Get the stored stacktrace captured during object construction.
- Returns:
The pointer to a null-terminated string storing the output stacktrace
-
inline char const *stacktrace() const#
-
struct logic_error : public std::logic_error, public cudf::stacktrace_recorder#
- #include <error.hpp>
Exception thrown when logical precondition is violated.
This exception should not be thrown directly and is instead thrown by the CUDF_EXPECTS macro.
Public Functions
-
inline logic_error(char const *const message)#
Constructs a logic_error with the error message.
- Parameters:
message – Message to be associated with the exception
-
inline logic_error(std::string const &message)#
Construct a new logic error object with error message.
- Parameters:
message – Message to be associated with the exception
-
inline logic_error(char const *const message)#
-
struct cuda_error : public std::runtime_error, public cudf::stacktrace_recorder#
- #include <error.hpp>
Exception thrown when a CUDA error is encountered.
Subclassed by cudf::fatal_cuda_error
Public Functions
-
inline cuda_error(std::string const &message, cudaError_t const &error)#
Construct a new cuda error object with error message and code.
- Parameters:
message – Error message
error – CUDA error code
-
inline cudaError_t error_code() const#
Returns the CUDA error code associated with the exception.
- Returns:
CUDA error code
-
inline cuda_error(std::string const &message, cudaError_t const &error)#
-
struct fatal_cuda_error : public cudf::cuda_error#
Public Functions
-
inline cuda_error(std::string const &message, cudaError_t const &error)#
Construct a new cuda error object with error message and code.
- Parameters:
message – Error message
error – CUDA error code
-
inline cuda_error(std::string const &message, cudaError_t const &error)#
-
struct data_type_error : public std::invalid_argument, public cudf::stacktrace_recorder#
- #include <error.hpp>
Exception thrown when an operation is attempted on an unsupported dtype.
This exception should be thrown when an operation is attempted on an unsupported data_type. This exception should not be thrown directly and is instead thrown by the CUDF_EXPECTS or CUDF_FAIL macros.
Public Functions
-
inline data_type_error(char const *const message)#
Constructs a data_type_error with the error message.
- Parameters:
message – Message to be associated with the exception
-
inline data_type_error(std::string const &message)#
Construct a new data_type_error object with error message.
- Parameters:
message – Message to be associated with the exception
-
inline data_type_error(char const *const message)#
-
CUDF_EXPECTS(...)#