LAMA
/home/brandes/workspace/LAMA/src/lama/cuda/CUDAError.hpp File Reference

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.

Detailed Description

Error handling for CUDA ( runtime, api, cublas, cusparse )

Author:
Thomas Brandes
Date:
15.07.2012 $Id$

Define Documentation

#define LAMA_CUBLAS_CALL (   call,
  msg 
)
Value:
{                                                                                   \
    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 
)
Value:
{                                                                                   \
    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 
)
Value:
{                                                                                   \
    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 
)
Value:
{                                                                                   \
    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().