void _THAssertionFailed(const char *file, const int line, const char *exp, const char *fmt, ...) { char msg[1024]; va_list args; va_start(args, fmt); vsnprintf(msg, 1024, fmt, args); va_end(args); _THError(file, line, "Assertion `%s' failed. %s", exp, msg); }
void __THCudaCheck(cudaError_t err, const char *file, const int line) { if(err != cudaSuccess) { _THError(file, line, "cuda runtime error (%d) : %s", err, cudaGetErrorString(err)); } }
void __THCudaCheck(cudaError_t err, const char *file, const int line) { if(err != cudaSuccess) { static int alreadyFailed = 0; if(!alreadyFailed) { fprintf(stderr, "THCudaCheck FAIL file=%s line=%i error=%i : %s\n", file, line, err, cudaGetErrorString(err)); alreadyFailed = 1; } _THError(file, line, "cuda runtime error (%d) : %s", err, cudaGetErrorString(err)); } }
void __THCusparseCheck(cusparseStatus_t status, const char *file, const int line) { if(status != CUSPARSE_STATUS_SUCCESS) { const char* errmsg = NULL; switch(status) { case CUSPARSE_STATUS_NOT_INITIALIZED: errmsg = "library not initialized"; break; case CUSPARSE_STATUS_ALLOC_FAILED: errmsg = "resource allocation failed"; break; case CUSPARSE_STATUS_INVALID_VALUE: errmsg = "an invalid numeric value was used as an argument"; break; case CUSPARSE_STATUS_ARCH_MISMATCH: errmsg = "an absent device architectural feature is required"; break; case CUSPARSE_STATUS_MAPPING_ERROR: errmsg = "an access to GPU memory space failed"; break; case CUSPARSE_STATUS_EXECUTION_FAILED: errmsg = "the GPU program failed to execute"; break; case CUSPARSE_STATUS_INTERNAL_ERROR: errmsg = "an internal operation failed"; break; case CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED: errmsg = "the matrix type is not supported by this function"; break; default: errmsg = "unknown error"; break; } _THError(file, line, "cusparse runtime error : %s", errmsg); } }