X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=WCudaMSE%2FBilatTools_Cuda%2Fsrc%2Fcore%2Fcudatools%2Fcpp%2FcudaTools.cpp;fp=WCudaMSE%2FBilatTools_Cuda%2Fsrc%2Fcore%2Fcudatools%2Fcpp%2FcudaTools.cpp;h=c100173f2012ddcb638fbd692c9f4e75225c081f;hb=8d08c12b29c2a14684f35c023ee39e694bb80d25;hp=0000000000000000000000000000000000000000;hpb=226de81f7e1f1fbf4ac79d0d089e8a05ec7159a0;p=GPU.git diff --git a/WCudaMSE/BilatTools_Cuda/src/core/cudatools/cpp/cudaTools.cpp b/WCudaMSE/BilatTools_Cuda/src/core/cudatools/cpp/cudaTools.cpp new file mode 100755 index 0000000..c100173 --- /dev/null +++ b/WCudaMSE/BilatTools_Cuda/src/core/cudatools/cpp/cudaTools.cpp @@ -0,0 +1,101 @@ +#include +#include +#include +#include + +#include "cudaTools.h" +#include "StringTools.h" + +using std::string; +using std::cout; +using std::cerr; +using std::endl; + +/*----------------------------------------------------------------------*\ + |* Declaration *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +/*----------------------------------------------------------------------*\ + |* Implementation *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +/** + * Cuda + */ +void cudaHandleError(cudaError_t error, const char *file, int line) + { + if (error != cudaSuccess) + { + cerr << endl << "[CUDA ERROR] : " << cudaGetErrorString(error) << " in " << file << " at ligne " << line << endl; + exit (EXIT_FAILURE); + } + } + +/** + * Curand + */ +void cudaHandleError(curandStatus_t statut, const char *file, int line) + { + if (statut != CURAND_STATUS_SUCCESS) + { + cerr << endl << "[CURAND ERROR] : " << statut << " in " << file << " at ligne " << line << endl; + exit (EXIT_FAILURE); + } + } + +/** + * Cublas + */ +void cudaHandleError(cublasStatus_t cublasStatus, const char *file, int line) + { + + if (cublasStatus != CUBLAS_STATUS_SUCCESS) + { + switch (cublasStatus) + { + case CUBLAS_STATUS_INVALID_VALUE: + cerr << endl << "[CUBLAS ERROR] : CUBLAS_STATUS_INVALID_VALUE " << " in " << file << " at line " << line << endl; + break; + case CUBLAS_STATUS_NOT_INITIALIZED: + cerr << endl << "[CUBLAS ERROR] : CUBLAS_STATUS_NOT_INITIALIZED " << " in " << file << " at line " << line << endl; + break; + case CUBLAS_STATUS_INTERNAL_ERROR: + cerr << endl << "[CUBLAS ERROR] : CUBLAS_STATUS_INTERNAL_ERROR " << " in " << file << " at line " << line << endl; + break; + case CUBLAS_STATUS_MAPPING_ERROR: + cerr << endl << "[CUBLAS ERROR] : CUBLAS_STATUS_MAPPING_ERROR " << " in " << file << " at line " << line << endl; + break; + + case CUBLAS_STATUS_ALLOC_FAILED: + cerr << endl << "[CUBLAS ERROR] : CUBLAS_STATUS_ALLOC_FAILED " << " in " << file << " at line " << line << endl; + break; + case CUBLAS_STATUS_ARCH_MISMATCH: + cerr << endl << "[CUBLAS ERROR] : CUBLAS_STATUS_ARCH_MISMATCH" << " in " << file << " at line " << line << endl; + break; + case CUBLAS_STATUS_EXECUTION_FAILED: + cerr << endl << "[CUBLAS ERROR] : CUBLAS_STATUS_EXECUTION_FAILED" << " in " << file << " at line " << line << endl; + break; + default: + cerr << endl << "[CUBLAS ERROR] : Unknown error !" << " in " << file << " at line " << line << endl; + break; + } + exit (EXIT_FAILURE); + } + } + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +/*----------------------------------------------------------------------*\ + |* End *| + \*---------------------------------------------------------------------*/ +