gko::matrix::RowGatherer#

Gathers rows by index. Stores an array of source-row indices; apply(b, x) writes x[i] = b[row_indices[i]]. The communication primitive behind the off-diagonal SpMV in distributed matrices and a useful tool for any rearrange-by-index workload.

template<typename IndexType = int32>
class RowGatherer #

Inherits from

RowGatherer is a matrix “format” which stores the gather indices arrays which can be used to gather rows to another matrix.

Note

This format is used mainly to allow for an abstraction of the rowgatherer and provides the user with an apply method which calls the respective Dense rowgatherer operation. As such it only stores an array of the rowgatherer indices.

Template Parameters:

IndexType – precision of rowgatherer array indices.

Public Functions

inline index_type *get_row_idxs() noexcept#

Returns a pointer to the row index array for gathering.

Returns:

the pointer to the row index array for gathering.

inline const index_type *get_const_row_idxs() const noexcept#

Returns a pointer to the row index array for gathering.

Note

This is the constant version of the function, which can be significantly more memory efficient than the non-constant version, so always prefer this version.

Returns:

the pointer to the row index array for gathering.

Public Static Functions

static std::unique_ptr<RowGatherer> create(
std::shared_ptr<const Executor> exec,
const dim<2> &size = {},
)#

Creates uninitialized RowGatherer arrays of the specified size.

Parameters:
  • execExecutor associated to the matrix

  • size – size of the RowGatherable matrix

Returns:

A smart pointer to the newly created matrix.

static std::unique_ptr<RowGatherer> create(
std::shared_ptr<const Executor> exec,
const dim<2> &size,
array<index_type> row_idxs,
)#

Creates a RowGatherer matrix from an already allocated (and initialized) row gathering array

Note

If row_idxs is not an rvalue, not an array of IndexType, or is on the wrong executor, an internal copy will be created, and the original array data will not be used in the matrix.

Parameters:
  • execExecutor associated to the matrix

  • size – size of the rowgatherer array.

  • row_idxs – array of rowgatherer array

Returns:

A smart pointer to the newly created matrix.

static std::unique_ptr<const RowGatherer> create_const(
std::shared_ptr<const Executor> exec,
const dim<2> &size,
gko::detail::const_array_view<IndexType> &&row_idxs,
)#

Creates a constant (immutable) RowGatherer matrix from a constant array.

Parameters:
  • exec – the executor to create the matrix on

  • size – the dimensions of the matrix

  • row_idxs – the gathered row indices of the matrix

Returns:

A smart pointer to the constant matrix wrapping the input arrays (if they reside on the same executor as the matrix) or a copy of the arrays on the correct executor.