I use the following macro to handle CUFFT errors:
#define cufftSafeCall(err) __cufftSafeCall(err, __FILE__, __LINE__) inline void __cufftSafeCall(cufftResult err, const char *file, const int line) { if( CUFFT_SUCCESS != err) { fprintf(stderr, "cufftSafeCall() CUFFT error in file <%s>, line %i.\n", file, line); getch(); exit(-1); } }
This macro does not return a message string from an error code. The book "CUDA Programming: A Developer's Guide to Parallel Computing with GPUs" suggests using the following macro
#define CUDA_CALL(call) { const cudaError_t err = (call); \ if(err != cudaSuccess) \ { \ fprintf(stderr, "CUDA error in file '%s', line %d\n %s\nerror %d: %s\nterminating!\n",__FILE__, __LINE__,err, \ cudaGetErrorString(err)); \ cudaDeviceReset(); assert(0); \ } }
(note: it was somewhat configured without changing the functionality). The book says: "This method works for all CUDA calls, except for kernel calls." However, when using CUDA_CALL when calling the CUFFT routine, the compiler returns
a value of type "cufftResult" cannot be used to initialize an entity of type "const cudaError_t".
It seems that cufftResult and cudaError_t not immediately compatible.
Studying a bit more from this channel of the NVIDIA CUDA Library , it seems that cudaGetErrorString requires the input type cudaError_t .
My questions are as follows:
- Is there a way to make
cufftResult and cudaError_t compatible so that I can use CUDA_CALL in CUFFT routines and get the message string from the error code? - Is there any technical reason why another error occurs for the CUFFT library? :-)
Thanks.
EDIT AFTER OPENING OF ROBERT CROWELL
I changed the CufftSafeCall procedure as
inline void __cufftSafeCall(cufftResult err, const char *file, const int line) { if( CUFFT_SUCCESS != err) { fprintf(stderr, "CUFFT error in file '%s', line %d\n %s\nerror %d: %s\nterminating!\n",__FILE__, __LINE__,err, \ _cudaGetErrorEnum(err)); \ cudaDeviceReset(); assert(0); \ }
}
to return also an error type string.