Jacobi< ValueType, IndexType > Class Template Reference

Jacobi&lt; ValueType, IndexType &gt; Class Template Reference#

Reference API: gko::preconditioner::Jacobi< ValueType, IndexType > Class Template Reference
Reference API

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

Inheritance 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< ConcreteLinOp >
using result_type = ConcreteLinOp
 
- Public Types inherited from gko::ConvertibleTo< ResultType >
using result_type = ResultType
 
- 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
 
const block_interleaved_storage_scheme< index_type > & get_storage_scheme () const noexcept
 
const value_type * get_blocks () const noexcept
 
const remove_complex< value_type > * get_conditioning () const noexcept
 
size_type get_num_stored_elements () const noexcept
 
void convert_to (matrix::Dense< value_type > *result) const override
 
void move_to (matrix::Dense< value_type > *result) override
 
void write (mat_data &data) const override
 
std::unique_ptr< LinOptranspose () const override
 
std::unique_ptr< LinOpconj_transpose () const override
 
Jacobioperator= (const Jacobi &other)
 
Jacobioperator= (Jacobi &&other)
 
 Jacobi (const Jacobi &other)
 
 Jacobi (Jacobi &&other)
 
const parameters_typeget_parameters () const
 
- Public Member Functions inherited from gko::EnableLinOp< ConcreteLinOp, PolymorphicBase >
const ConcreteLinOp * apply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const
 
ConcreteLinOp * apply (ptr_param< const LinOp > b, ptr_param< LinOp > x)
 
const ConcreteLinOp * apply (ptr_param< const LinOp > alpha, ptr_param< const LinOp > b, ptr_param< const LinOp > beta, ptr_param< LinOp > x) const
 
ConcreteLinOp * 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< AbstractObject, PolymorphicBase >
std::unique_ptr< AbstractObject > create_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< AbstractObject > create_default () const
 
std::unique_ptr< AbstractObject > clone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< AbstractObject > clone () const
 
AbstractObject * copy_from (const PolymorphicObject *other)
 
template<typename Derived >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, AbstractObject > * copy_from (std::unique_ptr< Derived > &&other)
 
template<typename Derived >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, AbstractObject > * copy_from (const std::unique_ptr< Derived > &other)
 
AbstractObject * copy_from (const std::shared_ptr< const PolymorphicObject > &other)
 
AbstractObject * move_from (ptr_param< PolymorphicObject > other)
 
AbstractObject * clear ()
 
- Public Member Functions inherited from gko::PolymorphicObject
PolymorphicObjectoperator= (const PolymorphicObject &)
 
std::unique_ptr< PolymorphicObjectcreate_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< PolymorphicObjectcreate_default () const
 
std::unique_ptr< PolymorphicObjectclone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< PolymorphicObjectclone () const
 
PolymorphicObjectcopy_from (const PolymorphicObject *other)
 
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)
 
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)
 
PolymorphicObjectcopy_from (const std::shared_ptr< const PolymorphicObject > &other)
 
PolymorphicObjectmove_from (ptr_param< PolymorphicObject > other)
 
PolymorphicObjectclear ()
 
std::shared_ptr< const Executorget_executor () const noexcept
 
- 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< ConcreteLinOp >
void convert_to (result_type *result) const override
 
void move_to (result_type *result) override
 
- Public Member Functions inherited from gko::ConvertibleTo< ResultType >
virtual void convert_to (result_type *result) const =0
 
void convert_to (ptr_param< result_type > result) const
 
virtual void move_to (result_type *result)=0
 
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 >())
 

Protected Member Functions

 Jacobi (std::shared_ptr< const Executor > exec)
 
 Jacobi (const Factory *factory, std::shared_ptr< const LinOp > system_matrix)
 
block_interleaved_storage_scheme< index_type > compute_storage_scheme (uint32 max_block_size, uint32 param_max_block_stride)
 
void generate (const LinOp *system_matrix, bool skip_sorting)
 
void detect_blocks (const matrix::Csr< ValueType, IndexType > *system_matrix)
 
void apply_impl (const LinOp *b, LinOp *x) const override
 
void apply_impl (const LinOp *alpha, const LinOp *b, const LinOp *beta, LinOp *x) const override
 
- Protected Member Functions inherited from gko::EnableLinOp< ConcreteLinOp, PolymorphicBase >
ConcreteLinOp * self () noexcept
 
const ConcreteLinOp * self () const noexcept
 
- Protected Member Functions inherited from gko::EnablePolymorphicObject< ConcreteObject, PolymorphicBase >
std::unique_ptr< PolymorphicObjectcreate_default_impl (std::shared_ptr< const Executor > exec) const override
 
PolymorphicObjectcopy_from_impl (const PolymorphicObject *other) override
 
PolymorphicObjectcopy_from_impl (std::unique_ptr< PolymorphicObject > other) override
 
PolymorphicObjectmove_from_impl (PolymorphicObject *other) override
 
PolymorphicObjectmove_from_impl (std::unique_ptr< PolymorphicObject > other) override
 
PolymorphicObjectclear_impl () override
 
- Protected Member Functions inherited from gko::PolymorphicObject
 PolymorphicObject (std::shared_ptr< const Executor > exec)
 
 PolymorphicObject (const PolymorphicObject &other)
 
- Protected Member Functions inherited from gko::log::EnableLogging< PolymorphicObject >
void log (Params &&... params) const
 

Friends

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

Additional Inherited Members

- Protected Attributes inherited from gko::log::EnableLogging< PolymorphicObject >
std::vector< std::shared_ptr< const Logger > > loggers_
 

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/4]

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/4]

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).

◆ Jacobi() [3/4]

template<typename ValueType = default_precision, typename IndexType = int32>
gko::preconditioner::Jacobi< ValueType, IndexType >::Jacobi ( std::shared_ptr< const Executor exec)
inlineexplicitprotected

◆ Jacobi() [4/4]

template<typename ValueType = default_precision, typename IndexType = int32>
gko::preconditioner::Jacobi< ValueType, IndexType >::Jacobi ( const Factory factory,
std::shared_ptr< const LinOp system_matrix 
)
inlineexplicitprotected

Member Function Documentation

◆ compute_storage_scheme()

template<typename ValueType = default_precision, typename IndexType = int32>
block_interleaved_storage_scheme< index_type > gko::preconditioner::Jacobi< ValueType, IndexType >::compute_storage_scheme ( uint32  max_block_size,
uint32  param_max_block_stride 
)
inlineprotected

Computes the storage scheme suitable for storing blocks of a given maximum size.

Parameters
max_block_sizethe maximum size of the blocks
Returns
a suitable storage scheme

References gko::PolymorphicObject::get_executor(), gko::get_significant_bit(), gko::get_superior_power(), and gko::preconditioner::Jacobi< ValueType, IndexType >::parameters_type::max_block_size.

◆ 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.

◆ detect_blocks()

template<typename ValueType = default_precision, typename IndexType = int32>
void gko::preconditioner::Jacobi< ValueType, IndexType >::detect_blocks ( const matrix::Csr< ValueType, IndexType > *  system_matrix)
protected

Detects the diagonal blocks and allocates the memory needed to store the preconditioner.

Parameters
system_matrixthe source matrix whose diagonal block pattern is to be detected

◆ generate()

template<typename ValueType = default_precision, typename IndexType = int32>
void gko::preconditioner::Jacobi< ValueType, IndexType >::generate ( const LinOp system_matrix,
bool  skip_sorting 
)
protected

Generates the preconditioner.

Parameters
system_matrixthe source matrix used to generate the preconditioner
skip_sortingdetermines if the sorting of system_matrix can be skipped (therefore, marking that it is already sorted)

Referenced by gko::preconditioner::Jacobi< ValueType, IndexType >::Jacobi().

◆ 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

◆ 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: