gko::batch::preconditioner::Jacobi#

Batched block-Jacobi preconditioner. Inverts the per-item diagonal blocks of every batch entry and stores the inverses for re-use on each apply. Block size is uniform across items. When the block size is 1 the preconditioner degenerates to pointwise diagonal scaling — the common batched-iterative-solve default.

template<typename ValueType = default_precision, typename IndexType = int32>
class Jacobi #

Inherits from

  • public gko::batch::EnableBatchLinOp<Jacobi<default_precision, int32>>

A block-Jacobi preconditioner is a block-diagonal linear operator, obtained by inverting the diagonal blocks (stored in a dense row major fashion) of the source operator.

With the batched preconditioners, it is required that all items in the batch have the same sparsity pattern. The detection of the blocks and the block pointers require that the sparsity pattern of all the items be the same. Other cases is undefined behaviour. The input batch matrix must be in batch::Csr matrix format or must be convertible to batch::Csr matrix format. The block detection algorithm and the conversion to dense blocks kernels require this assumption.

Note

In a fashion similar to the non-batched Jacobi preconditioner, the maximum possible size of the diagonal blocks is equal to the maximum warp size on the device (32 for NVIDIA GPUs, 64 for AMD GPUs).

Template Parameters:
  • ValueType – value precision of matrix elements

  • IndexType – index precision of matrix elements

Public Functions

inline const index_type *get_const_block_pointers() const noexcept#

Returns the block pointers.

Note

Returns nullptr in case of a scalar jacobi preconditioner (max_block_size = 1).

Returns:

the block pointers

inline const index_type *get_const_map_block_to_row() const noexcept#

Returns the mapping between the blocks and the row id.

Note

Returns nullptr in case of a scalar jacobi preconditioner (max_block_size = 1).

inline const index_type *get_const_blocks_cumulative_offsets(
) const noexcept#

Returns the cumulative blocks storage array

Note

Returns nullptr in case of a scalar jacobi preconditioner (max_block_size = 1).

inline uint32 get_max_block_size() const noexcept#

Returns the max block size.

Returns:

the max block size

inline size_type get_num_blocks() const noexcept#

Returns the number of blocks in an individual batch entry.

Returns:

the number of blocks in an individual batch entry.

inline const value_type *get_const_blocks() const noexcept#

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

Element \((i, j)\) of the block that belongs to batch entry batch_id and has local id block_id within that entry is stored at the address

get_const_blocks()
    + detail::get_global_block_offset(batch_id, num_blocks, block_id,
                                      cumulative_blocks_storage)
    + i * detail::get_stride(block_id, block_pointers)
    + j

Note

Returns nullptr in case of a scalar jacobi preconditioner (max_block_size = 1). The blocks array is empty in case of scalar jacobi preconditioner as the preconditioner is generated inside the batched solver kernel.

Returns:

the pointer to the memory used for storing the block data

inline size_type get_num_stored_elements() const noexcept#

Returns the number of elements explicitly stored in the dense blocks.

Note

Returns 0 in case of scalar jacobi preconditioner as the preconditioner is generated inside the batched solver kernels, hence, blocks array storage is not required.

Returns:

the number of elements explicitly stored in the dense blocks.

struct parameters_type#

Public Members

uint32 max_block_size#

Maximal size of diagonal blocks.

Note

This value has to be between 1 and 32 (NVIDIA)/64 (AMD). For efficiency, when the max_block_size is set to 1, specialized kernels are used and the additional objects (block_ptrs etc) are set to null values.

Note

Unlike the regular block Jacobi preconditioner, for the batched preconditioner, smaller blocks are more efficient, as the matrices themselves are considerably smaller.

gko::array<index_type> block_pointers#

Starting (row / column) indexes of individual blocks, for a single batch item.

An index past the last block has to be supplied as the last value. I.e. the size of the array has to be the number of blocks plus 1, where the first value is 0, and the last value is the number of rows / columns of the matrix.

Note

Even if not set explicitly, this parameter will be set to automatically detected values once the preconditioner is generated.

Note

If the parameter is set automatically, the size of the array does not correlate to the number of blocks, and is implementation defined. To obtain the number of blocks n use Jacobi::get_num_blocks(). The starting indexes of the blocks are stored in the first n+1 values of this array.

Note

If the block-diagonal structure can be determined from the problem characteristics, it may be beneficial to pass this information specifically via this parameter, as the autodetection procedure is only a rough approximation of the true block structure.

Note

The maximum block size set by the max_block_size parameter has to be respected when setting this parameter. Failure to do so will lead to undefined behavior.