Loading...
Searching...
No Matches
Classes | Macros | Functions
error.hpp File Reference
#include <cuspatial/assert.cuh>
#include <cuda_runtime_api.h>
#include <stdexcept>
#include <string>

Go to the source code of this file.

Classes

struct  cuspatial::logic_error
 Exception thrown when logical precondition is violated. More...
 
struct  cuspatial::cuda_error
 Exception thrown when a CUDA error is encountered. More...
 

Macros

#define CUSPATIAL_STRINGIFY_DETAIL(x)   #x
 
#define CUSPATIAL_STRINGIFY(x)   CUSPATIAL_STRINGIFY_DETAIL(x)
 
#define CUSPATIAL_EXPECTS(cond, reason)
 Macro for checking (pre-)conditions that throws an exception when a condition is violated.
 
#define CUSPATIAL_HOST_DEVICE_EXPECTS(cond, reason)   CUSPATIAL_EXPECTS(cond, reason)
 Macro for checking (pre-)conditions that throws an exception when a condition is violated.
 
#define CUSPATIAL_FAIL(reason)
 Indicates that an erroneous code path has been taken.
 
#define CUSPATIAL_CUDA_TRY(call)
 Error checking macro for CUDA runtime API functions.
 
#define CUSPATIAL_CHECK_CUDA(stream)
 Debug macro to check for CUDA errors.
 

Functions

void cuspatial::detail::throw_cuda_error (cudaError_t error, const char *file, unsigned int line)
 

Macro Definition Documentation

◆ CUSPATIAL_CHECK_CUDA

#define CUSPATIAL_CHECK_CUDA ( stream)
Value:
do { \
CUSPATIAL_CUDA_TRY(cudaStreamSynchronize(stream)); \
CUSPATIAL_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 166 of file error.hpp.

◆ CUSPATIAL_CUDA_TRY

#define CUSPATIAL_CUDA_TRY ( call)
Value:
do { \
cudaError_t const status = (call); \
if (cudaSuccess != status) { \
cudaGetLastError(); \
cuspatial::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 143 of file error.hpp.

◆ CUSPATIAL_EXPECTS

#define CUSPATIAL_EXPECTS ( cond,
reason )
Value:
(!!(cond)) ? static_cast<void>(0) \
: throw cuspatial::logic_error("cuSpatial failure at: " __FILE__ \
":" CUSPATIAL_STRINGIFY(__LINE__) ": " reason)

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

------------------------------------------------------------------------—*

Example usage:

CUSPATIAL_EXPECTS(lhs->dtype == rhs->dtype, "Column type mismatch");
#define CUSPATIAL_EXPECTS(cond, reason)
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
Definition error.hpp:76
Parameters
[in]condExpression that evaluates to true or false
[in]reasonString literal description of the reason that cond is expected to be true

Exceptions
cuspatial::logic_errorif the condition evaluates to false.

Definition at line 76 of file error.hpp.

◆ CUSPATIAL_FAIL

#define CUSPATIAL_FAIL ( reason)
Value:
throw cuspatial::logic_error("cuSpatial failure at: " __FILE__ \
":" CUSPATIAL_STRINGIFY(__LINE__) ": " reason)
Exception thrown when logical precondition is violated.
Definition error.hpp:40

Indicates that an erroneous code path has been taken.

------------------------------------------------------------------------—*

In host code, throws a cuspatial::logic_error.

Example usage:

CUSPATIAL_FAIL("Non-arithmetic operation is not supported");
#define CUSPATIAL_FAIL(reason)
Indicates that an erroneous code path has been taken.
Definition error.hpp:119

Parameters
reasonString literal description of the reason

Definition at line 119 of file error.hpp.

◆ CUSPATIAL_HOST_DEVICE_EXPECTS

#define CUSPATIAL_HOST_DEVICE_EXPECTS ( cond,
reason )   CUSPATIAL_EXPECTS(cond, reason)

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

------------------------------------------------------------------------—*

Example usage:

CUSPATIAL_HOST_DEVICE_EXPECTS(lhs->dtype == rhs->dtype, "Column type mismatch");
#define CUSPATIAL_HOST_DEVICE_EXPECTS(cond, reason)
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
Definition error.hpp:101
Parameters
[in]condExpression that evaluates to true or false
[in]reasonString literal description of the reason that cond is expected to be true

(if on host)

Exceptions
cuspatial::logic_errorif the condition evaluates to false. (if on device)

program terminates and assertion error message is printed to stderr.

Definition at line 101 of file error.hpp.

◆ CUSPATIAL_STRINGIFY

#define CUSPATIAL_STRINGIFY ( x)    CUSPATIAL_STRINGIFY_DETAIL(x)

Definition at line 59 of file error.hpp.

◆ CUSPATIAL_STRINGIFY_DETAIL

#define CUSPATIAL_STRINGIFY_DETAIL ( x)    #x

Definition at line 58 of file error.hpp.

Function Documentation

◆ throw_cuda_error()

void cuspatial::detail::throw_cuda_error ( cudaError_t error,
const char * file,
unsigned int line )
inline

Definition at line 126 of file error.hpp.