Ginkgo  Generated from pipelines/1554403166 branch based on develop. Ginkgo version 1.9.0
A numerical linear algebra library targeting many-core architectures
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
gko::preconditioner::Jacobi< ValueType, IndexType > Class Template Reference

A block-Jacobi preconditioner is a block-diagonal linear operator, obtained by inverting the diagonal blocks of the source operator. More...

#include <ginkgo/core/preconditioner/jacobi.hpp>

Inheritance diagram for gko::preconditioner::Jacobi< ValueType, IndexType >:
[legend]
Collaboration diagram for gko::preconditioner::Jacobi< ValueType, IndexType >:
[legend]

Classes

class  Factory
 
struct  parameters_type
 

Public Types

using value_type = ValueType
 
using index_type = IndexType
 
using mat_data = matrix_data< ValueType, IndexType >
 
using transposed_type = Jacobi< ValueType, IndexType >
 
- Public Types inherited from gko::EnablePolymorphicAssignment< Jacobi< ValueType, IndexType > >
using result_type = Jacobi< ValueType, IndexType >
 
- Public Types inherited from gko::ConvertibleTo< Jacobi< ValueType, IndexType > >
using result_type = Jacobi< ValueType, IndexType >
 
- Public Types inherited from gko::ConvertibleTo< matrix::Dense< ValueType > >
using result_type = matrix::Dense< ValueType >
 
- Public Types inherited from gko::WritableToMatrixData< ValueType, IndexType >
using value_type = ValueType
 
using index_type = IndexType
 

Public Member Functions

size_type get_num_blocks () const noexcept
 Returns the number of blocks of the operator. More...
 
const block_interleaved_storage_scheme< index_type > & get_storage_scheme () const noexcept
 Returns the storage scheme used for storing Jacobi blocks. More...
 
const value_type * get_blocks () const noexcept
 Returns the pointer to the memory used for storing the block data. More...
 
const remove_complex< value_type > * get_conditioning () const noexcept
 Returns an array of 1-norm condition numbers of the blocks. More...
 
size_type get_num_stored_elements () const noexcept
 Returns the number of elements explicitly stored in the matrix. More...
 
void convert_to (matrix::Dense< value_type > *result) const override
 Converts the implementer to an object of type result_type. More...
 
void move_to (matrix::Dense< value_type > *result) override
 Converts the implementer to an object of type result_type by moving data from this object. More...
 
void write (mat_data &data) const override
 Writes a matrix to a matrix_data structure. More...
 
std::unique_ptr< LinOptranspose () const override
 Returns a LinOp representing the transpose of the Transposable object. More...
 
std::unique_ptr< LinOpconj_transpose () const override
 Returns a LinOp representing the conjugate transpose of the Transposable object. More...
 
Jacobioperator= (const Jacobi &other)
 Copy-assigns a Jacobi preconditioner. More...
 
Jacobioperator= (Jacobi &&other)
 Move-assigns a Jacobi preconditioner. More...
 
 Jacobi (const Jacobi &other)
 Copy-constructs a Jacobi preconditioner. More...
 
 Jacobi (Jacobi &&other)
 Move-assigns a Jacobi preconditioner. More...
 
const parameters_typeget_parameters () const
 
- Public Member Functions inherited from gko::EnableLinOp< Jacobi< ValueType, IndexType > >
const Jacobi< ValueType, IndexType > * apply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const
 
Jacobi< ValueType, IndexType > * apply (ptr_param< const LinOp > b, ptr_param< LinOp > x)
 
const Jacobi< ValueType, IndexType > * apply (ptr_param< const LinOp > alpha, ptr_param< const LinOp > b, ptr_param< const LinOp > beta, ptr_param< LinOp > x) const
 
Jacobi< ValueType, IndexType > * apply (ptr_param< const LinOp > alpha, ptr_param< const LinOp > b, ptr_param< const LinOp > beta, ptr_param< LinOp > x)
 
- Public Member Functions inherited from gko::EnableAbstractPolymorphicObject< Jacobi< ValueType, IndexType >, LinOp >
std::unique_ptr< Jacobi< ValueType, IndexType > > create_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< Jacobi< ValueType, IndexType > > create_default () const
 
std::unique_ptr< Jacobi< ValueType, IndexType > > clone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< Jacobi< ValueType, IndexType > > clone () const
 
Jacobi< ValueType, IndexType > * copy_from (const PolymorphicObject *other)
 
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, Jacobi< ValueType, IndexType > > * copy_from (std::unique_ptr< Derived > &&other)
 
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, Jacobi< ValueType, IndexType > > * copy_from (const std::unique_ptr< Derived > &other)
 
Jacobi< ValueType, IndexType > * copy_from (const std::shared_ptr< const PolymorphicObject > &other)
 
Jacobi< ValueType, IndexType > * move_from (ptr_param< PolymorphicObject > other)
 
Jacobi< ValueType, IndexType > * clear ()
 
- Public Member Functions inherited from gko::LinOp
LinOpapply (ptr_param< const LinOp > b, ptr_param< LinOp > x)
 Applies a linear operator to a vector (or a sequence of vectors). More...
 
const LinOpapply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const
 
LinOpapply (ptr_param< const LinOp > alpha, ptr_param< const LinOp > b, ptr_param< const LinOp > beta, ptr_param< LinOp > x)
 Performs the operation x = alpha * op(b) + beta * x. More...
 
const LinOpapply (ptr_param< const LinOp > alpha, ptr_param< const LinOp > b, ptr_param< const LinOp > beta, ptr_param< LinOp > x) const
 
const dim< 2 > & get_size () const noexcept
 Returns the size of the operator. More...
 
virtual bool apply_uses_initial_guess () const
 Returns true if the linear operator uses the data given in x as an initial guess. More...
 
LinOpoperator= (const LinOp &)=default
 Copy-assigns a LinOp. More...
 
LinOpoperator= (LinOp &&other)
 Move-assigns a LinOp. More...
 
 LinOp (const LinOp &)=default
 Copy-constructs a LinOp. More...
 
 LinOp (LinOp &&other)
 Move-constructs a LinOp. More...
 
- Public Member Functions inherited from gko::EnableAbstractPolymorphicObject< LinOp >
std::unique_ptr< LinOpcreate_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< LinOpcreate_default () const
 
std::unique_ptr< LinOpclone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< LinOpclone () const
 
LinOpcopy_from (const PolymorphicObject *other)
 
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, LinOp > * copy_from (std::unique_ptr< Derived > &&other)
 
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, LinOp > * copy_from (const std::unique_ptr< Derived > &other)
 
LinOpcopy_from (const std::shared_ptr< const PolymorphicObject > &other)
 
LinOpmove_from (ptr_param< PolymorphicObject > other)
 
LinOpclear ()
 
- Public Member Functions inherited from gko::PolymorphicObject
PolymorphicObjectoperator= (const PolymorphicObject &)
 
std::unique_ptr< PolymorphicObjectcreate_default (std::shared_ptr< const Executor > exec) const
 Creates a new "default" object of the same dynamic type as this object. More...
 
std::unique_ptr< PolymorphicObjectcreate_default () const
 Creates a new "default" object of the same dynamic type as this object. More...
 
std::unique_ptr< PolymorphicObjectclone (std::shared_ptr< const Executor > exec) const
 Creates a clone of the object. More...
 
std::unique_ptr< PolymorphicObjectclone () const
 Creates a clone of the object. More...
 
PolymorphicObjectcopy_from (const PolymorphicObject *other)
 Copies another object into this object. More...
 
template<typename Derived , typename Deleter >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, PolymorphicObject > * copy_from (std::unique_ptr< Derived, Deleter > &&other)
 Moves another object into this object. More...
 
template<typename Derived , typename Deleter >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, PolymorphicObject > * copy_from (const std::unique_ptr< Derived, Deleter > &other)
 Copies another object into this object. More...
 
PolymorphicObjectcopy_from (const std::shared_ptr< const PolymorphicObject > &other)
 Copies another object into this object. More...
 
PolymorphicObjectmove_from (ptr_param< PolymorphicObject > other)
 Moves another object into this object. More...
 
PolymorphicObjectclear ()
 Transforms the object into its default state. More...
 
std::shared_ptr< const Executorget_executor () const noexcept
 Returns the Executor of the object. More...
 
- Public Member Functions inherited from gko::log::EnableLogging< PolymorphicObject >
void add_logger (std::shared_ptr< const Logger > logger) override
 
void remove_logger (const Logger *logger) override
 
void remove_logger (ptr_param< const Logger > logger)
 
const std::vector< std::shared_ptr< const Logger > > & get_loggers () const override
 
void clear_loggers () override
 
- Public Member Functions inherited from gko::log::Loggable
void remove_logger (ptr_param< const Logger > logger)
 
- Public Member Functions inherited from gko::EnablePolymorphicAssignment< Jacobi< ValueType, IndexType > >
void convert_to (result_type *result) const override
 Converts the implementer to an object of type result_type. More...
 
void move_to (result_type *result) override
 Converts the implementer to an object of type result_type by moving data from this object. More...
 
- Public Member Functions inherited from gko::ConvertibleTo< Jacobi< ValueType, IndexType > >
void convert_to (ptr_param< result_type > result) const
 
void move_to (ptr_param< result_type > result)
 
- Public Member Functions inherited from gko::ConvertibleTo< matrix::Dense< ValueType > >
void convert_to (ptr_param< result_type > result) const
 
void move_to (ptr_param< result_type > result)
 

Static Public Member Functions

static auto build () -> decltype(Factory ::create())
 
static parameters_type parse (const config::pnode &config, const config::registry &context, const config::type_descriptor &td_for_child=config::make_type_descriptor< ValueType, IndexType >())
 Create the parameters from the property_tree. More...
 

Friends

class EnableLinOp< Jacobi >
 
class EnablePolymorphicObject< Jacobi, LinOp >
 

Detailed Description

template<typename ValueType = default_precision, typename IndexType = int32>
class gko::preconditioner::Jacobi< ValueType, IndexType >

A block-Jacobi preconditioner is a block-diagonal linear operator, obtained by inverting the diagonal blocks of the source operator.

The Jacobi class implements the inversion of the diagonal blocks using Gauss-Jordan elimination with column pivoting, and stores the inverse explicitly in a customized format.

If the diagonal blocks of the matrix are not explicitly set by the user, the implementation will try to automatically detect the blocks by first finding the natural blocks of the matrix, and then applying the supervariable agglomeration procedure on them. However, if problem-specific knowledge regarding the block diagonal structure is available, it is usually beneficial to explicitly pass the starting rows of the diagonal blocks, as the block detection is merely a heuristic and cannot perfectly detect the diagonal block structure. The current implementation supports blocks of up to 32 rows / columns.

The implementation also includes an improved, adaptive version of the block-Jacobi preconditioner, which can store some of the blocks in lower precision and thus improve the performance of preconditioner application by reducing the amount of memory transfers. This variant can be enabled by setting the Jacobi::Factory's storage_optimization parameter. Refer to the documentation of the parameter for more details.

Template Parameters
ValueTypeprecision of matrix elements
IndexTypeintegral type used to store pointers to the start of each block
Note
The current implementation supports blocks of up to 32 rows / columns.
When using the adaptive variant, there may be a trade-off in terms of slightly longer preconditioner generation due to extra work required to detect the optimal precision of the blocks.
When the max_block_size is set to 1, specialized kernels are used, both for generation (inverting the diagonals) and application (diagonal scaling) to reduce the overhead involved in the usual (adaptive) block case.

Constructor & Destructor Documentation

◆ Jacobi() [1/2]

template<typename ValueType = default_precision, typename IndexType = int32>
gko::preconditioner::Jacobi< ValueType, IndexType >::Jacobi ( const Jacobi< ValueType, IndexType > &  other)

Copy-constructs a Jacobi preconditioner.

Inherits executor, copies all data and parameters.

◆ Jacobi() [2/2]

template<typename ValueType = default_precision, typename IndexType = int32>
gko::preconditioner::Jacobi< ValueType, IndexType >::Jacobi ( Jacobi< ValueType, IndexType > &&  other)

Move-assigns a Jacobi preconditioner.

Inherits executor, moves all data and parameters. The moved-from object will be empty (0x0 and default parameters).

Member Function Documentation

◆ conj_transpose()

template<typename ValueType = default_precision, typename IndexType = int32>
std::unique_ptr<LinOp> gko::preconditioner::Jacobi< ValueType, IndexType >::conj_transpose ( ) const
overridevirtual

Returns a LinOp representing the conjugate transpose of the Transposable object.

Returns
a pointer to the new conjugate transposed object

Implements gko::Transposable.

◆ convert_to()

template<typename ValueType = default_precision, typename IndexType = int32>
void gko::preconditioner::Jacobi< ValueType, IndexType >::convert_to ( matrix::Dense< value_type > *  result) const
overridevirtual

Converts the implementer to an object of type result_type.

Parameters
resultthe object used to store the result of the conversion

Implements gko::ConvertibleTo< matrix::Dense< ValueType > >.

◆ get_blocks()

template<typename ValueType = default_precision, typename IndexType = int32>
const value_type* gko::preconditioner::Jacobi< ValueType, IndexType >::get_blocks ( ) const
inlinenoexcept

Returns the pointer to the memory used for storing the block data.

Element (i, j) of block b is stored in position (get_block_pointers()[b] + i) * stride + j of the array.

Returns
the pointer to the memory used for storing the block data

References gko::array< ValueType >::get_const_data().

◆ get_conditioning()

template<typename ValueType = default_precision, typename IndexType = int32>
const remove_complex<value_type>* gko::preconditioner::Jacobi< ValueType, IndexType >::get_conditioning ( ) const
inlinenoexcept

Returns an array of 1-norm condition numbers of the blocks.

Returns
an array of 1-norm condition numbers of the blocks
Note
This value is valid only if adaptive precision variant is used, and implementations of the standard non-adaptive variant are allowed to omit the calculation of condition numbers.

References gko::array< ValueType >::get_const_data().

◆ get_num_blocks()

template<typename ValueType = default_precision, typename IndexType = int32>
size_type gko::preconditioner::Jacobi< ValueType, IndexType >::get_num_blocks ( ) const
inlinenoexcept

Returns the number of blocks of the operator.

Returns
the number of blocks of the operator

◆ get_num_stored_elements()

template<typename ValueType = default_precision, typename IndexType = int32>
size_type gko::preconditioner::Jacobi< ValueType, IndexType >::get_num_stored_elements ( ) const
inlinenoexcept

Returns the number of elements explicitly stored in the matrix.

Returns
the number of elements explicitly stored in the matrix

References gko::array< ValueType >::get_size().

◆ get_storage_scheme()

template<typename ValueType = default_precision, typename IndexType = int32>
const block_interleaved_storage_scheme<index_type>& gko::preconditioner::Jacobi< ValueType, IndexType >::get_storage_scheme ( ) const
inlinenoexcept

Returns the storage scheme used for storing Jacobi blocks.

Returns
the storage scheme used for storing Jacobi blocks

◆ move_to()

template<typename ValueType = default_precision, typename IndexType = int32>
void gko::preconditioner::Jacobi< ValueType, IndexType >::move_to ( matrix::Dense< value_type > *  result)
overridevirtual

Converts the implementer to an object of type result_type by moving data from this object.

This method is used when the implementer is a temporary object, and move semantics can be used.

Parameters
resultthe object used to emplace the result of the conversion
Note
ConvertibleTo::move_to can be implemented by simply calling ConvertibleTo::convert_to. However, this operation can often be optimized by exploiting the fact that implementer's data can be moved to the result.

Implements gko::ConvertibleTo< matrix::Dense< ValueType > >.

◆ operator=() [1/2]

template<typename ValueType = default_precision, typename IndexType = int32>
Jacobi& gko::preconditioner::Jacobi< ValueType, IndexType >::operator= ( const Jacobi< ValueType, IndexType > &  other)

Copy-assigns a Jacobi preconditioner.

Preserves executor, copies all data and parameters.

◆ operator=() [2/2]

template<typename ValueType = default_precision, typename IndexType = int32>
Jacobi& gko::preconditioner::Jacobi< ValueType, IndexType >::operator= ( Jacobi< ValueType, IndexType > &&  other)

Move-assigns a Jacobi preconditioner.

Preserves executor, moves all data and parameters. The moved-from object will be empty (0x0 and default parameters).

◆ parse()

template<typename ValueType = default_precision, typename IndexType = int32>
static parameters_type gko::preconditioner::Jacobi< ValueType, IndexType >::parse ( const config::pnode config,
const config::registry context,
const config::type_descriptor td_for_child = config::make_type_descriptor< ValueType, IndexType >() 
)
static

Create the parameters from the property_tree.

Because this is directly tied to the specific type, the value/index type settings within config are ignored and type_descriptor is only used for children configs.

Parameters
configthe property tree for setting
contextthe registry
td_for_childthe type descriptor for children configs. The default uses the value/index type of this class.
Returns
parameters
Note
Jacobi does not support block_pointers and storage_optimization array.

◆ transpose()

template<typename ValueType = default_precision, typename IndexType = int32>
std::unique_ptr<LinOp> gko::preconditioner::Jacobi< ValueType, IndexType >::transpose ( ) const
overridevirtual

Returns a LinOp representing the transpose of the Transposable object.

Returns
a pointer to the new transposed object

Implements gko::Transposable.

◆ write()

template<typename ValueType = default_precision, typename IndexType = int32>
void gko::preconditioner::Jacobi< ValueType, IndexType >::write ( mat_data data) const
overridevirtual

Writes a matrix to a matrix_data structure.

Parameters
datathe matrix_data structure

Implements gko::WritableToMatrixData< ValueType, IndexType >.


The documentation for this class was generated from the following file: