LAMA
|
Error handling for CUDA ( runtime, api, cublas, cusparse ) More...
#include <lama/exception/Exception.hpp>
#include <lama/exception/LAMAAssert.hpp>
#include <cuda.h>
#include <cublas.h>
Go to the source code of this file.
Namespaces | |
namespace | lama |
The namespace lama holds everything of the C++ Library lama. | |
Defines | |
#define | LAMA_CUDA_DRV_CALL(call, msg) |
Macro for CUDA driver API calls to catch errors. | |
#define | LAMA_CUDA_RT_CALL(call, msg) |
#define | LAMA_CUBLAS_CALL(call, msg) |
#define | LAMA_CUSPARSE_CALL(call, msg) |
#define | LAMA_CHECK_CUDA_ACCESS |
#define | LAMA_CHECK_CUDA_ERROR |
#define | LAMA_CHECK_CUBLAS_ERROR |
Functions | |
const char * | lama::cudaDriverErrorString (CUresult res) |
Function that translates enum CUresult to strings. | |
const char * | lama::cublasErrorString (cublasStatus res) |
Function that translates enum cublasStatus to strings. |
Error handling for CUDA ( runtime, api, cublas, cusparse )
#define LAMA_CHECK_CUBLAS_ERROR |
{ \
LAMA_CUBLAS_CALL( cublasGetError(), "last error CUBLAS" ) \
}
Referenced by lama::CUDABLAS1::asum(), lama::CUDABLAS1::axpy(), lama::CUDABLAS1::copy(), lama::CUDABLAS1::dot(), lama::CUDABLAS2::ger(), lama::CUDABLAS1::iamax(), lama::CUDABLAS1::nrm2(), lama::CUDABLAS1::rot(), lama::CUDABLAS1::rotm(), lama::CUDABLAS1::scal(), lama::CUDABLAS1::swap(), and lama::CUDAContext::~CUDAContext().
#define LAMA_CHECK_CUDA_ACCESS |
{ \ CUcontext pctx; \ const int cudaErrorValue = cuCtxGetCurrent( &pctx ); \ LAMA_ASSERT_EQUAL_ERROR( cudaErrorValue, cudaSuccess ) \ LAMA_ASSERT_ERROR( pctx, "No current context, forgotten LAMA_CONTEXT_ACCESS ?" ); \ }
Referenced by lama::CUDABLAS1::ass(), lama::CUDABLAS1::asum(), lama::CUDABLAS1::axpy(), lama::CUDABLAS1::copy(), lama::CUDABLAS1::dot(), lama::CUDABLAS2::gbmv(), lama::CUDABLAS3::gemm(), lama::CUDABLAS2::gemv(), lama::CUDABLAS2::ger(), lama::CUDABLAS1::iamax(), lama::CUDABLAS1::nrm2(), lama::CUDABLAS1::rot(), lama::CUDABLAS1::rotm(), lama::CUDABLAS2::sbmv(), lama::CUDABLAS1::scal(), lama::CUDABLAS2::spmv(), lama::CUDABLAS2::spr(), lama::CUDABLAS2::spr2(), lama::CUDABLAS1::sum(), lama::CUDABLAS1::swap(), lama::CUDABLAS2::symv(), lama::CUDABLAS2::syr(), lama::CUDABLAS2::syr2(), lama::CUDABLAS2::tbmv(), lama::CUDABLAS2::tbsv(), lama::CUDABLAS2::tpmv(), lama::CUDABLAS2::tpsv(), lama::CUDABLAS2::trmv(), lama::CUDABLAS3::trsm(), and lama::CUDABLAS2::trsv().
#define LAMA_CHECK_CUDA_ERROR |
{ \
LAMA_CUDA_RT_CALL( cudaGetLastError(), "last error CUBLAS" ) \
}
Referenced by lama::CUDABLAS1::ass(), lama::CUDABLAS1::asum(), lama::CUDABLAS1::axpy(), lama::CUDABLAS1::copy(), lama::CUDABLAS1::dot(), lama::CUDABLAS1::iamax(), lama::CUDALAPACK::laswp(), lama::CUDABLAS1::nrm2(), lama::CUDABLAS1::rot(), lama::CUDABLAS1::rotm(), lama::CUDABLAS1::scal(), lama::CUDABLAS1::sum(), lama::CUDABLAS1::swap(), and lama::CUDABLAS1::viamax().
#define LAMA_CUBLAS_CALL | ( | call, | |
msg | |||
) |
{ \ cublasStatus res = call; \ if ( CUBLAS_STATUS_SUCCESS != res ) \ { \ std::ostringstream errorStr; \ errorStr << "CUBLAS error in line " << __LINE__; \ errorStr << " of file " << __FILE__ << std::endl; \ errorStr << " Call : " #call; \ errorStr << " Msg : " << msg << std::endl; \ errorStr << " Error: "; \ errorStr << cublasErrorString( res ); \ errorStr << ", cublasStatus = " << res << "\n"; \ lama::Exception::addCallStack( errorStr ); \ fprintf(stderr, "%s\n", errorStr.str().c_str() ); \ throw lama::Exception( errorStr.str() ); \ } \ }
Referenced by lama::CUDAContext::CUDAContext(), lama::CUDABLAS2::gbmv(), lama::CUDABLAS3::gemm(), lama::CUDABLAS2::gemv(), lama::CUDABLAS2::ger(), lama::CUDABLAS2::sbmv(), lama::CUDABLAS2::spmv(), lama::CUDABLAS2::spr(), lama::CUDABLAS2::spr2(), lama::CUDABLAS2::symv(), lama::CUDABLAS2::syr(), lama::CUDABLAS2::syr2(), lama::CUDABLAS2::tbmv(), lama::CUDABLAS2::tbsv(), lama::CUDABLAS2::tpmv(), lama::CUDABLAS2::tpsv(), lama::CUDABLAS2::trmv(), lama::CUDABLAS3::trsm(), and lama::CUDABLAS2::trsv().
#define LAMA_CUDA_DRV_CALL | ( | call, | |
msg | |||
) |
{ \ CUresult res = call; \ if ( CUDA_SUCCESS != res ) \ { \ std::ostringstream errorStr; \ errorStr << "CUDA driver error in line " << __LINE__; \ errorStr << " of file " << __FILE__ << std::endl; \ errorStr << " Msg : " << msg << std::endl; \ errorStr << " Call : " #call; \ errorStr << " Error: "; \ errorStr << lama::cudaDriverErrorString( res ); \ errorStr << ", CUresult = " << res << "\n"; \ lama::Exception::addCallStack( errorStr ); \ fprintf(stderr, "%s\n", errorStr.str().c_str() ); \ throw lama::Exception( errorStr.str() ); \ } \ }
Macro for CUDA driver API calls to catch errors.
Referenced by lama::CUDAHostContext::allocate(), lama::CUDAContext::allocate(), lama::LUSolver::computeLUFactorization(), lama::CUDAStreamSyncToken::createEvent(), lama::CUDAStreamSyncToken::createTimingEvent(), lama::CUDAContext::CUDAContext(), lama::CUDAContext::disable(), lama::CUDAContext::enable(), lama::CUDAHostContext::free(), lama::CUDAContext::free(), lama::CUDAStreamSyncToken::getTime(), lama::CUDAContext::memcpy(), lama::CUDAContext::memcpyAsync(), lama::CUDAContext::memcpyAsyncFromCUDAHost(), lama::CUDAContext::memcpyAsyncToCUDAHost(), lama::CUDAContext::memcpyFromCUDAHost(), lama::CUDAContext::memcpyFromHost(), lama::CUDAContext::memcpyToCUDAHost(), lama::CUDAContext::memcpyToHost(), lama::CUDAStreamSyncToken::probeEvent(), lama::CUDAStreamSyncToken::queryEvent(), lama::CUDAStreamSyncToken::recordEvent(), lama::CUDAStreamSyncToken::synchronizeEvent(), lama::CUDAStreamSyncToken::wait(), and lama::CUDAContext::~CUDAContext().
#define LAMA_CUDA_RT_CALL | ( | call, | |
msg | |||
) |
{ \ cudaError_t res = call; \ if ( cudaSuccess != res ) \ { \ std::ostringstream errorStr; \ errorStr << "CUDA runtime error in line " << __LINE__; \ errorStr << " of file " << __FILE__ << std::endl; \ errorStr << " Call : " #call; \ errorStr << " Msg : " << msg << std::endl; \ errorStr << " Error: "; \ errorStr << cudaGetErrorString( res ); \ errorStr << ", cudaError_t = " << res << "\n"; \ lama::Exception::addCallStack( errorStr ); \ fprintf(stderr, "%s\n", errorStr.str().c_str() ); \ throw lama::Exception( errorStr.str() ); \ } \ }
Referenced by lama::CUDABLAS2::gbmv(), lama::CUDABLAS3::gemm(), lama::CUDABLAS2::gemv(), lama::CUDABLAS2::ger(), lama::CUDAHostContext::memcpyAsync(), lama::CUDABLAS2::sbmv(), lama::CUDABLAS2::spmv(), lama::CUDABLAS2::spr(), lama::CUDABLAS2::spr2(), lama::CUDABLAS2::symv(), lama::CUDABLAS2::syr(), lama::CUDABLAS2::syr2(), lama::CUDABLAS2::tbmv(), lama::CUDABLAS2::tbsv(), lama::CUDABLAS2::tpmv(), lama::CUDABLAS2::tpsv(), lama::CUDABLAS2::trmv(), lama::CUDABLAS3::trsm(), and lama::CUDABLAS2::trsv().
#define LAMA_CUSPARSE_CALL | ( | call, | |
msg | |||
) |
{ \ cusparseStatus_t res = call; \ if ( CUSPARSE_STATUS_SUCCESS != res ) \ { \ std::ostringstream errorStr; \ errorStr << "CUSparse error in line " << __LINE__; \ errorStr << " of file " << __FILE__ << std::endl; \ errorStr << " Call : " #call; \ errorStr << " Msg : " << msg << std::endl; \ errorStr << " Error: "; \ errorStr << "cusparseStatus = " << res << "\n"; \ lama::Exception::addCallStack( errorStr ); \ fprintf(stderr, "%s\n", errorStr.str().c_str() ); \ throw lama::Exception( errorStr.str() ); \ } \ }
Referenced by lama::CUDAContext::CUDAContext().