加载中...
搜索中...
无匹配项
error.hpp 文件参考
#include <cuspatial/assert.cuh>
#include <cuda_runtime_api.h>
#include <stdexcept>
#include <string>

查看此文件的源代码。

结构体  cuspatial::logic_error
 违反逻辑前置条件时抛出的异常。 更多...
 
结构体  cuspatial::cuda_error
 遇到 CUDA 错误时抛出的异常。 更多...
 

#define CUSPATIAL_STRINGIFY_DETAIL(x)
 
#define CUSPATIAL_STRINGIFY(x)
 
#define CUSPATIAL_EXPECTS(cond, reason)
 用于检查(前置)条件的宏,当条件被违反时抛出异常。
 
#define CUSPATIAL_HOST_DEVICE_EXPECTS(cond, reason)
 用于检查(前置)条件的宏,当条件被违反时抛出异常。
 
#define CUSPATIAL_FAIL(reason)
 表示已执行到错误的的代码路径。
 
#define CUSPATIAL_CUDA_TRY(call)
 用于 CUDA 运行时 API 函数的错误检查宏。
 
#define CUSPATIAL_CHECK_CUDA(stream)
 用于检查 CUDA 错误的调试宏。
 

函数

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

宏定义文档

◆ CUSPATIAL_CHECK_CUDA

#define CUSPATIAL_CHECK_CUDA ( stream)
do { \
CUSPATIAL_CUDA_TRY(cudaStreamSynchronize(stream)); \
CUSPATIAL_CUDA_TRY(cudaPeekAtLastError()); \
} while (0);

用于检查 CUDA 错误的调试宏。

在非发布版本构建中,此宏将在错误检查之前同步指定的流。在发布和非发布版本构建中,此宏都会检查之前调用中是否有任何待处理的 CUDA 错误。如果报告了错误,则会抛出异常,详细说明发生的 CUDA 错误。

此宏旨在为调试异步 CUDA 执行提供同步且确定性的执行机制。它应在任何异步 CUDA 调用(例如 cudaMemcpyAsync)或异步核函数启动之后使用。

定义于文件 error.hpp166 行。

◆ CUSPATIAL_CUDA_TRY

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

用于 CUDA 运行时 API 函数的错误检查宏。

调用 CUDA 运行时 API 函数,如果调用未返回 cudaSuccess,则调用 cudaGetLastError() 清除错误并抛出详细说明发生的 CUDA 错误的异常

定义于文件 error.hpp143 行。

◆ CUSPATIAL_EXPECTS

#define CUSPATIAL_EXPECTS ( cond,
reason )
(!!(cond)) ? static_cast<void>(0) \
: throw cuspatial::logic_error("cuSpatial failure at: " __FILE__ \
":" CUSPATIAL_STRINGIFY(__LINE__) ": " reason)
违反逻辑前置条件时抛出的异常。

用于检查(前置)条件的宏,当条件被违反时抛出异常。

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

使用示例

CUSPATIAL_EXPECTS(lhs->dtype == rhs->dtype, "Column type mismatch");
#define CUSPATIAL_EXPECTS(cond, reason)
用于检查(前置)条件的宏,当条件被违反时抛出异常。
参数
[in]cond求值为 true 或 false 的表达式
[in]reason描述 cond 期望为 true 的原因的字符串字面量

autotoc_md88

异常
cuspatial::logic_error如果条件求值为 false。

定义于文件 error.hpp76 行。

◆ CUSPATIAL_FAIL

#define CUSPATIAL_FAIL ( reason)
throw cuspatial::logic_error("cuSpatial failure at: " __FILE__ \
":" CUSPATIAL_STRINGIFY(__LINE__) ": " reason)

表示已执行到错误的的代码路径。

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

在主机代码中,抛出 cuspatial::logic_error

使用示例

CUSPATIAL_FAIL("Non-arithmetic operation is not supported");
#define CUSPATIAL_FAIL(reason)
表示已执行到错误的的代码路径。

autotoc_md90

参数
[in]reason原因的字符串字面量描述

定义于文件 error.hpp119 行。

◆ CUSPATIAL_HOST_DEVICE_EXPECTS

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

用于检查(前置)条件的宏,当条件被违反时抛出异常。

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

使用示例

CUSPATIAL_HOST_DEVICE_EXPECTS(lhs->dtype == rhs->dtype, "Column type mismatch");
#define CUSPATIAL_HOST_DEVICE_EXPECTS(cond, reason)
用于检查(前置)条件的宏,当条件被违反时抛出异常。
参数
[in]cond求值为 true 或 false 的表达式
[in]reason描述 cond 期望为 true 的原因的字符串字面量

(如果在主机上)

异常
cuspatial::logic_error如果条件求值为 false。(如果在设备上)

程序终止,断言错误消息打印到 stderr。

定义于文件 error.hpp101 行。

◆ CUSPATIAL_STRINGIFY

#define CUSPATIAL_STRINGIFY ( x)
CUSPATIAL_STRINGIFY_DETAIL(x)

定义于文件 error.hpp59 行。

◆ CUSPATIAL_STRINGIFY_DETAIL

#define CUSPATIAL_STRINGIFY_DETAIL ( x)
#x

定义于文件 error.hpp58 行。

函数文档

◆ throw_cuda_error()

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

定义于文件 error.hpp126 行。