MAGMA  2.3.0
Matrix Algebra for GPU and Multicore Architectures
 All Classes Files Functions Friends Groups Pages
Error handling

Macros

#define check_error(err)
 Checks if err is not success, and prints an error message. More...
 
#define check_xerror(err, func, file, line)
 Checks if err is not success, and prints an error message. More...
 
#define CHECK(err)
 Macro checks the return code of a function; if non-zero, sets info to err, then does goto cleanup. More...
 
#define CHECK_CUSPARSE(err)
 Macro checks the return code of a cusparse function; if non-zero, maps the cusparse error to a magma error and sets info, then does goto cleanup. More...
 

Functions

void magma_xerror (cudaError_t err, const char *func, const char *file, int line)
 Prints error message to stderr. More...
 
void magma_xerror (cublasStatus_t err, const char *func, const char *file, int line)
 
void magma_xerror (magma_int_t err, const char *func, const char *file, int line)
 
const char * magma_cublasGetErrorString (cublasStatus_t err)
 
magma_int_t cusparse2magma_error (cusparseStatus_t status)
 Maps a cuSPARSE error to a MAGMA error. More...
 

Detailed Description

Macro Definition Documentation

#define check_error (   err)

Checks if err is not success, and prints an error message.

Similar to assert(), if NDEBUG is defined, this does nothing. This version adds the current func, file, and line to the error message.

Parameters
[in]errError code.
#define check_xerror (   err,
  func,
  file,
  line 
)

Checks if err is not success, and prints an error message.

Similar to assert(), if NDEBUG is defined, this does nothing. This version takes func, file, and line as arguments to add to error message.

Parameters
[in]errError code.
[in]funcFunction where error occurred.
[in]fileFile where error occurred.
[in]lineLine where error occurred.
#define CHECK (   err)

Macro checks the return code of a function; if non-zero, sets info to err, then does goto cleanup.

err is evaluated only once. Assumes variable info and label cleanup exist. Usually, all paths (successful and error) exit through the cleanup code. Example:

magma_int_t function()
{
    magma_int_t info = 0;
    double *A=NULL, *B=NULL;
    CHECK( magma_malloc( &A, sizeA ));
    CHECK( magma_malloc( &B, sizeB ));
    ...
cleanup:
    magma_free( A );
    magma_free( B );
    return info;
}
See Also
CHECK_CUSPARSE
#define CHECK_CUSPARSE (   err)

Macro checks the return code of a cusparse function; if non-zero, maps the cusparse error to a magma error and sets info, then does goto cleanup.

See Also
CHECK

Function Documentation

void magma_xerror ( cudaError_t  err,
const char *  func,
const char *  file,
int  line 
)

Prints error message to stderr.

C++ function overloaded for different error types (CUDA, cuBLAS, MAGMA errors). Note CUDA and cuBLAS errors are enums, so can be differentiated. Used by the check_error() and check_xerror() macros.

Parameters
[in]errError code.
[in]funcFunction where error occurred; inserted by check_error().
[in]fileFile where error occurred; inserted by check_error().
[in]lineLine where error occurred; inserted by check_error().
void magma_xerror ( cublasStatus_t  err,
const char *  func,
const char *  file,
int  line 
)
See Also
magma_xerror
void magma_xerror ( magma_int_t  err,
const char *  func,
const char *  file,
int  line 
)
See Also
magma_xerror
const char* magma_cublasGetErrorString ( cublasStatus_t  err)
Returns
String describing cuBLAS errors (cublasStatus_t). CUDA provides cudaGetErrorString, but not cublasGetErrorString.
Parameters
[in]errError code.
magma_int_t cusparse2magma_error ( cusparseStatus_t  status)

Maps a cuSPARSE error to a MAGMA error.

Parameters
[in]statuscuSPARSE error
Returns
MAGMA error