我有一个关于 this error-handler 的幼稚问题我在 Stack Overflow 上找到了。在这里:
#define CUDA_HANDLE_ERROR(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
{
fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
if (abort) exit(code);
}
}
我唯一没有得到的是 gpuAssert(..)
的参数部分中的 bool abort = true
语句。
这个abort
标志的目的是什么?
最佳答案
好吧,当我们调用那个函数时, 是否必须放置 abort 参数。
但是如果你调用 gpuAssert(code, file, line, false) 那么中止标志将为假, 然后程序不会退出。
因为中止标志默认为true,但是我们可以将其设置为false。
关于c++ - 这个标志的目的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57200210/