19#include <cuspatial/assert.cuh>
21#include <cuda_runtime_api.h>
41 logic_error(
char const*
const message) : std::logic_error(message) {}
42 logic_error(std::string
const& message) : std::logic_error(message) {}
49 cuda_error(std::string
const& message) : std::runtime_error(message) {}
58#define CUSPATIAL_STRINGIFY_DETAIL(x) #x
59#define CUSPATIAL_STRINGIFY(x) CUSPATIAL_STRINGIFY_DETAIL(x)
76#define CUSPATIAL_EXPECTS(cond, reason) \
77 (!!(cond)) ? static_cast<void>(0) \
78 : throw cuspatial::logic_error("cuSpatial failure at: " __FILE__ \
79 ":" CUSPATIAL_STRINGIFY(__LINE__) ": " reason)
101#define CUSPATIAL_HOST_DEVICE_EXPECTS(cond, reason) CUSPATIAL_EXPECTS(cond, reason)
103#define CUSPATIAL_HOST_DEVICE_EXPECTS(cond, reason) cuspatial_assert(cond&& reason)
119#define CUSPATIAL_FAIL(reason) \
120 throw cuspatial::logic_error("cuSpatial failure at: " __FILE__ \
121 ":" CUSPATIAL_STRINGIFY(__LINE__) ": " reason)
126inline void throw_cuda_error(cudaError_t error,
const char* file,
unsigned int line)
129 "CUDA error encountered at: " + std::string{file} +
":" + std::to_string(line) +
": " +
130 std::to_string(error) +
" " + cudaGetErrorName(error) +
" " + cudaGetErrorString(error)});
143#define CUSPATIAL_CUDA_TRY(call) \
145 cudaError_t const status = (call); \
146 if (cudaSuccess != status) { \
147 cudaGetLastError(); \
148 cuspatial::detail::throw_cuda_error(status, __FILE__, __LINE__); \
166#define CUSPATIAL_CHECK_CUDA(stream) \
168 CUSPATIAL_CUDA_TRY(cudaStreamSynchronize(stream)); \
169 CUSPATIAL_CUDA_TRY(cudaPeekAtLastError()); \
172#define CUSPATIAL_CHECK_CUDA(stream) CUSPATIAL_CUDA_TRY(cudaPeekAtLastError());
Exception thrown when a CUDA error is encountered.
Exception thrown when logical precondition is violated.