24 #ifndef SKA_CHEETAH_CUDA_UTILS_ERRORHANDLING_H 25 #define SKA_CHEETAH_CUDA_UTILS_ERRORHANDLING_H 29 #include <cuda_runtime.h> 44 #define CU_MSG "[ cuda msg ] " 53 #define CUDA_ERROR_CHECK(ans) { cuda_assert_success((ans), __FILE__, __LINE__); } 60 inline void cuda_assert_success(cudaError_t code,
const char *file,
int line)
62 if (code != cudaSuccess)
68 std::stringstream error_msg;
69 error_msg <<
"CUDA failed with error: " 70 << cudaGetErrorString(code) << std::endl
71 <<
"File: " << file << std::endl
72 <<
"Line: " << line << std::endl;
73 throw std::runtime_error(error_msg.str());
80 #define CUFFT_ERROR_CHECK(ans) { cufft_assert_success((ans), __FILE__, __LINE__); } 86 inline void cufft_assert_success(cufftResult code,
const char *file,
int line)
88 if (code != CUFFT_SUCCESS)
90 std::stringstream error_msg;
91 error_msg <<
"CUFFT failed with error: ";
94 case CUFFT_INVALID_PLAN:
95 error_msg <<
"CUFFT_INVALID_PLAN";
98 case CUFFT_ALLOC_FAILED:
99 error_msg <<
"CUFFT_ALLOC_FAILED";
102 case CUFFT_INVALID_TYPE:
103 error_msg <<
"CUFFT_INVALID_TYPE";
106 case CUFFT_INVALID_VALUE:
107 error_msg <<
"CUFFT_INVALID_VALUE";
110 case CUFFT_INTERNAL_ERROR:
111 error_msg <<
"CUFFT_INTERNAL_ERROR";
114 case CUFFT_EXEC_FAILED:
115 error_msg <<
"CUFFT_EXEC_FAILED";
118 case CUFFT_SETUP_FAILED:
119 error_msg <<
"CUFFT_SETUP_FAILED";
122 case CUFFT_INVALID_SIZE:
123 error_msg <<
"CUFFT_INVALID_SIZE";
126 case CUFFT_UNALIGNED_DATA:
127 error_msg <<
"CUFFT_UNALIGNED_DATA";
131 error_msg <<
"CUFFT_UNKNOWN_ERROR";
133 error_msg << std::endl
134 <<
"File: " << file << std::endl
135 <<
"Line: " << line << std::endl;
136 throw std::runtime_error(error_msg.str());
139 #endif // ENABLE_CUDA 141 #endif //SKA_CHEETAH_CUDA_UTILS_ERRORHANDLING_H