gko::PolymorphicObject#

The base of every Ginkgo object. It holds the executor and provides validate_data(). That function checks an object’s stored data and throws gko::InvalidData on a violation. Ginkgo never calls it on its own; call it after filling a matrix from external data.

The checks depend on the format:

Format

What validate_data() checks

matrix::Csr

row pointers are non-descending and within [0, nnz]; column indices are within [0, num_cols) and unique within each row; all values are finite

matrix::Coo

row indices are non-descending and within [0, num_rows); column indices are within [0, num_cols); all values are finite

matrix::Ell

the column indices of non-padding entries are below num_cols and unique within each row; the stored values are finite

matrix::Dense, matrix::Diagonal

all values are finite

matrix::Permutation

the index array is a bijection on [0, n)

Other types keep the default, which accepts the object. The check copies the data to the host and scans it, so it costs a device-to-host transfer and \(O(\text{nnz})\) work.

auto A = gko::matrix::Csr<double, int>::create(exec, gko::dim<2>{3}, 4);
// ... fill A's row pointers, column indices and values from external data
try {
    A->validate_data();
} catch (const gko::InvalidData& e) {
    std::cerr << "invalid matrix: " << e.what() << '\n';
}
class PolymorphicObject #

Inherits from

A PolymorphicObject is the abstract base for all “heavy” objects in Ginkgo that behave polymorphically.

It defines the basic utilities (copying moving, cloning, clearing the objects) for all such objects. It takes into account that these objects are dynamically allocated, managed by smart pointers, and used polymorphically. Additionally, it assumes their data can be allocated on different executors, and that they can be copied between those executors.

Note

Most of the public methods of this class should not be overridden directly, and are thus not virtual. Instead, there are equivalent protected methods (ending in <method_name>_impl) that should be overridden instead. This allows polymorphic objects to implement default behavior around virtual methods (parameter checking, type casting).

Subclassed by

Public Functions

inline virtual void validate_data() const#

Throws gko::InvalidData exception if we found the data inside the object does not fulfill certain property up to our knowledge.

inline std::shared_ptr<const Executor> get_executor(
) const noexcept#

Returns the Executor of the object.

Returns:

Executor of the object