主页
libcuspatial
cucim
cudf-java
cudf
cugraph
cuml
cuproj
cuspatial
cuvs
cuxfilter
dask-cuda
dask-cudf
kvikio
libcudf
libcuml
libcuproj
libcuspatial
libkvikio
librmm
libucxx
raft
rapids-cmake
rapidsmpf
rmm
稳定版 (25.04)
稳定版 (25.04)
旧版 (25.02)
加载中...
搜索中...
无匹配项
include
cuspatial
error.hpp
前往此文件的文档
1
/*
2
* 版权所有 (c) 2020-2023, NVIDIA CORPORATION.
3
*
4
* 根据 Apache 许可证 2.0 版本(“许可证”)获得许可;
5
* 除非遵守许可证,否则您不得使用此文件。
6
* 您可以在以下位置获取许可证副本
7
*
8
* https://apache.ac.cn/licenses/LICENSE-2.0
9
*
10
* 除非适用法律要求或书面同意,否则软件
11
* 根据许可证分发是基于“现状”,
12
* 不附带任何明示或默示的保证或条件。
13
* 请参阅许可证以了解管理权限和
14
* 限制的特定语言。
15
*/
16
17
#pragma once
18
19
#include <cuspatial/assert.cuh>
20
21
#include <cuda_runtime_api.h>
22
23
#include <stdexcept>
24
#include <string>
25
26
namespace
cuspatial {
27
32
40
struct
logic_error :
public
std::logic_error {
41
logic_error(
char
const
*
const
message) : std::logic_error(message) {}
42
logic_error(std::string
const
& message) : std::logic_error(message) {}
43
};
44
48
struct
cuda_error :
public
std::runtime_error {
49
cuda_error(std::string
const
& message) : std::runtime_error(message) {}
50
};
51
55
56
}
// namespace cuspatial
57
58
#define CUSPATIAL_STRINGIFY_DETAIL(x) #x
59
#define CUSPATIAL_STRINGIFY(x) CUSPATIAL_STRINGIFY_DETAIL(x)
60
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)
80
100
#ifndef __CUDA_ARCH__
101
#define CUSPATIAL_HOST_DEVICE_EXPECTS(cond, reason) CUSPATIAL_EXPECTS(cond, reason)
102
#else
103
#define CUSPATIAL_HOST_DEVICE_EXPECTS(cond, reason) cuspatial_assert(cond&& reason)
104
#endif
105
119
#define CUSPATIAL_FAIL(reason) \
120
throw cuspatial::logic_error("cuSpatial failure at: " __FILE__ \
121
":" CUSPATIAL_STRINGIFY(__LINE__) ": " reason)
122
123
namespace
cuspatial {
124
namespace
detail {
125
126
inline
void
throw_cuda_error(cudaError_t error,
const
char
* file,
unsigned
int
line)
127
{
128
throw
cuspatial::cuda_error
(std::string{
129
"遇到 CUDA 错误于: "
+ std::string{file} +
":"
+ std::to_string(line) +
": "
+
130
std::to_string(error) +
" "
+ cudaGetErrorName(error) +
" "
+ cudaGetErrorString(error)});
131
}
132
133
}
// namespace detail
134
}
// namespace cuspatial
135
143
#define CUSPATIAL_CUDA_TRY(call) \
144
do { \
145
cudaError_t const status = (call); \
146
if (cudaSuccess != status) { \
147
cudaGetLastError(); \
148
cuspatial::detail::throw_cuda_error(status, __FILE__, __LINE__); \
149
} \
150
} while (0);
151
165
#ifndef NDEBUG
166
#define CUSPATIAL_CHECK_CUDA(stream) \
167
do { \
168
CUSPATIAL_CUDA_TRY(cudaStreamSynchronize(stream)); \
169
CUSPATIAL_CUDA_TRY(cudaPeekAtLastError()); \
170
} while (0);
171
#else
172
#define CUSPATIAL_CHECK_CUDA(stream) CUSPATIAL_CUDA_TRY(cudaPeekAtLastError());
173
#endif
cuspatial::cuda_error
遇到 CUDA 错误时抛出的异常。
定义
error.hpp:48
生成者
1.13.2