Loading...
Searching...
No Matches
Error handling
Internal routines

## Macros

#define | check_error(err)
| Checks if err is not success, and prints an error message.
#define | check_xerror(err, func, file, line)
| Checks if err is not success, and prints an error message.
#define | CHECK(err)
| Macro checks the return code of a function; if non-zero, sets info to err, then does goto cleanup.
#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.

## Functions

const char * | magma_cublasGetErrorString (cublasStatus_t err)
void | magma_xerror (cudaError_t err, const char *func, const char *file, int line)
| Prints error message to stderr.
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)
magma_int_t | cusparse2magma_error (cusparseStatus_t status)
| Maps a cuSPARSE error to a MAGMA error.

## Detailed Description

## Macro Definition Documentation

## check_error

#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] | err | Error code.

## check_xerror

#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] | err | Error code.
  [in] | func | Function where error occurred.
  [in] | file | File where error occurred.
  [in] | line | Line where error occurred.

## CHECK

#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

## 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

## magma_cublasGetErrorString()

const char * magma_cublasGetErrorString | ( | cublasStatus_t | err | ) |

Returns
  String describing cuBLAS errors (cublasStatus_t). CUDA provides cudaGetErrorString, but not cublasGetErrorString.

Parameters

  [in] | err | Error code.

## magma_xerror() [1/3]

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] | err | Error code.
  [in] | func | Function where error occurred; inserted by check_error().
  [in] | file | File where error occurred; inserted by check_error().
  [in] | line | Line where error occurred; inserted by check_error().

## magma_xerror() [2/3]

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

See also
  magma_xerror

## magma_xerror() [3/3]

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

See also
  magma_xerror
  magma_xerror

## cusparse2magma_error()

magma_int_t cusparse2magma_error | ( | cusparseStatus_t | status | ) |

Maps a cuSPARSE error to a MAGMA error.

Parameters

  [in] | status | cuSPARSE error

Returns
  MAGMA error