目录
错误检测
CUDA error的函数
__host__ __device__ const char* cudaGetErrorName ( cudaError_t error )
Returns the string representation of an error code enum name.
__host__ __device__ const char* cudaGetErrorString ( cudaError_t error )
Returns the description string for an error code. 返回错误的具体表述
__host__ __device__cudaError_t cudaGetLastError ( void )
Returns the last error from a runtime call.
__host__ __device__cudaError_t cudaPeekAtLastError ( void )
Returns the last error from a runtime call.
封装
//用error.cuh 进行文件封装
#pragma once
#include <stdio.h>
#define CHECK(call) \
do \
{ \
const cudaError_t error_code = call; \
if (error_code != cudaSuccess) \
{ \
printf("CUDA Error:\n"); \
printf(" File: %s\n", __FILE__); \
printf(" Line: %d\n", __LINE__); \
printf(" Error code: %d\n", error_code); \
printf(" Error text: %s\n", \
cudaGetErrorString(error_code)); \
exit(1); \
}