Exceptions#
Every Ginkgo exception derives from gko::Error, which carries the file, line
and message and is itself a std::runtime_error. Catching gko::Error handles the
exception types listed below.
Exception |
Thrown when |
|---|---|
|
it is not possible to perform the requested operation on the given object type |
|
an operation is called that is part of a module that was not compiled on the system |
|
an operation has not yet been implemented (but will be implemented in the future) |
|
an operation is applied to |
|
an operation is applied to a |
|
two values are not equal |
|
a memory allocation fails |
|
a memory access is detected to be out of bounds |
|
an object is in an invalid state |
|
an object contains invalid data, described by the invariant it violated; raised by |
-
class Error #
Inherits from
public std::runtime_error
The Error class is used to report exceptional behaviour in library functions. Ginkgo uses C++ exception mechanism to this end, and the Error class represents a base class for all types of errors. The exact list of errors which could occur during the execution of a certain library routine is provided in the documentation of that routine, along with a short description of the situation when that error can occur. During runtime, these errors can be detected by using standard C++ try-catch blocks, and a human-readable error description can be obtained by calling the Error::what() method.
As an example, trying to compute a matrix-vector product with arguments of incompatible size will result in a DimensionMismatch error, which is demonstrated in the following program.
#include <ginkgo.h> #include <iostream> using namespace gko; int main() { auto omp = create<OmpExecutor>(); auto A = randn_fill<matrix::Csr<float>>(5, 5, 0f, 1f, omp); auto x = fill<matrix::Dense<float>>(6, 1, 1f, omp); try { auto y = apply(A, x); } catch(Error e) { // an error occurred, write the message to screen and exit std::cout << e.what() << std::endl; return -1; } return 0; }
Subclassed by
gko::BlockSizeError< IndexType >
gko::CublasError
gko::CudaError
gko::CufftError
gko::CurandError
gko::CusparseError
gko::HipError
gko::HipblasError
gko::HipfftError
gko::HiprandError
gko::HipsparseError
gko::KernelNotFound
gko::MetisError
gko::MpiError
gko::OverflowError
gko::StreamError
gko::UnsupportedMatrixProperty
Public Functions
- inline Error(
- const std::string &file,
- int line,
- const std::string &what,
Initializes an error.
- Parameters:
file – The name of the offending source file
line – The source code line number where the error occurred
what – The error message
-
class NotSupported #
Inherits from
public gko::Error
NotSupported is thrown in case it is not possible to perform the requested operation on the given object type.
-
class NotCompiled #
Inherits from
public gko::Error
NotCompiled is thrown when attempting to call an operation which is a part of a module that was not compiled on the system.
-
class NotImplemented #
Inherits from
public gko::Error
NotImplemented is thrown in case an operation has not yet been implemented (but will be implemented in the future).
-
class DimensionMismatch #
Inherits from
public gko::Error
DimensionMismatch is thrown if an operation is being applied to LinOps of incompatible size.
-
class BadDimension #
Inherits from
public gko::Error
BadDimension is thrown if an operation is being applied to a LinOp with bad dimensions.
-
class ValueMismatch #
Inherits from
public gko::Error
ValueMismatch is thrown if two values are not equal.
-
class AllocationError #
Inherits from
public gko::Error
AllocationError is thrown if a memory allocation fails.
-
class OutOfBoundsError #
Inherits from
public gko::Error
OutOfBoundsError is thrown if a memory access is detected to be out-of-bounds.
-
class InvalidStateError #
Inherits from
public gko::Error
Exception thrown if an object is in an invalid state.
-
class InvalidData #
Inherits from
public gko::Error
InvalidData is thrown in case an object in Ginkgo contains invalid data, either because the data was user-provided, or because of a bug. Invalid data is described by the invariant it violated.
See also