|
void | convert_to (Matrix< next_precision< value_type >, local_index_type, global_index_type > *result) const override |
void | move_to (Matrix< next_precision< value_type >, local_index_type, global_index_type > *result) override |
void | read_distributed (const device_matrix_data< value_type, global_index_type > &data, std::shared_ptr< const Partition< local_index_type, global_index_type > > partition, assembly_mode assembly_type=assembly_mode::local_only) |
| Reads a square matrix from the device_matrix_data structure and a global partition.
|
void | read_distributed (const matrix_data< value_type, global_index_type > &data, std::shared_ptr< const Partition< local_index_type, global_index_type > > partition, assembly_mode assembly_type=assembly_mode::local_only) |
| Reads a square matrix from the matrix_data structure and a global partition.
|
void | read_distributed (const device_matrix_data< value_type, global_index_type > &data, std::shared_ptr< const Partition< local_index_type, global_index_type > > row_partition, std::shared_ptr< const Partition< local_index_type, global_index_type > > col_partition, assembly_mode assembly_type=assembly_mode::local_only) |
| Reads a matrix from the device_matrix_data structure, a global row partition, and a global column partition.
|
void | read_distributed (const matrix_data< value_type, global_index_type > &data, std::shared_ptr< const Partition< local_index_type, global_index_type > > row_partition, std::shared_ptr< const Partition< local_index_type, global_index_type > > col_partition, assembly_mode assembly_type=assembly_mode::local_only) |
| Reads a matrix from the matrix_data structure, a global row partition, and a global column partition.
|
std::shared_ptr< const LinOp > | get_local_matrix () const |
| Get read access to the stored local matrix.
|
std::shared_ptr< const LinOp > | get_non_local_matrix () const |
| Get read access to the stored non-local matrix.
|
| Matrix (const Matrix &other) |
| Copy constructs a Matrix.
|
| Matrix (Matrix &&other) noexcept |
| Move constructs a Matrix.
|
Matrix & | operator= (const Matrix &other) |
| Copy assigns a Matrix.
|
Matrix & | operator= (Matrix &&other) |
| Move assigns a Matrix.
|
void | col_scale (ptr_param< const global_vector_type > scaling_factors) |
| Scales the columns of the matrix by the respective entries of the vector.
|
void | row_scale (ptr_param< const global_vector_type > scaling_factors) |
| Scales the rows of the matrix by the respective entries of the vector.
|
const Matrix< default_precision, int32, int64 > * | apply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const |
std::unique_ptr< Matrix< default_precision, int32, int64 > > | create_default (std::shared_ptr< const Executor > exec) const |
std::unique_ptr< Matrix< default_precision, int32, int64 > > | clone (std::shared_ptr< const Executor > exec) const |
Matrix< default_precision, int32, int64 > * | copy_from (const PolymorphicObject *other) |
Matrix< default_precision, int32, int64 > * | move_from (ptr_param< PolymorphicObject > other) |
Matrix< default_precision, int32, int64 > * | clear () |
LinOp * | apply (ptr_param< const LinOp > b, ptr_param< LinOp > x) |
| Applies a linear operator to a vector (or a sequence of vectors).
|
const LinOp * | apply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const |
LinOp * | apply (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.
|
const LinOp * | apply (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.
|
virtual bool | apply_uses_initial_guess () const |
| Returns true if the linear operator uses the data given in x as an initial guess.
|
LinOp & | operator= (const LinOp &)=default |
| Copy-assigns a LinOp.
|
LinOp & | operator= (LinOp &&other) |
| Move-assigns a LinOp.
|
| LinOp (const LinOp &)=default |
| Copy-constructs a LinOp.
|
| LinOp (LinOp &&other) |
| Move-constructs a LinOp.
|
std::unique_ptr< LinOp > | create_default (std::shared_ptr< const Executor > exec) const |
std::unique_ptr< LinOp > | clone (std::shared_ptr< const Executor > exec) const |
LinOp * | copy_from (const PolymorphicObject *other) |
LinOp * | move_from (ptr_param< PolymorphicObject > other) |
LinOp * | clear () |
PolymorphicObject & | operator= (const PolymorphicObject &) |
std::unique_ptr< PolymorphicObject > | create_default (std::shared_ptr< const Executor > exec) const |
| Creates a new "default" object of the same dynamic type as this object.
|
std::unique_ptr< PolymorphicObject > | create_default () const |
| Creates a new "default" object of the same dynamic type as this object.
|
std::unique_ptr< PolymorphicObject > | clone (std::shared_ptr< const Executor > exec) const |
| Creates a clone of the object.
|
std::unique_ptr< PolymorphicObject > | clone () const |
| Creates a clone of the object.
|
PolymorphicObject * | copy_from (const PolymorphicObject *other) |
| Copies another object into this object.
|
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.
|
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.
|
PolymorphicObject * | copy_from (const std::shared_ptr< const PolymorphicObject > &other) |
| Copies another object into this object.
|
PolymorphicObject * | move_from (ptr_param< PolymorphicObject > other) |
| Moves another object into this object.
|
PolymorphicObject * | clear () |
| Transforms the object into its default state.
|
std::shared_ptr< const Executor > | get_executor () const noexcept |
| Returns the Executor of the object.
|
void | add_logger (std::shared_ptr< const Logger > logger) override |
| Adds a new logger to the list of subscribed loggers.
|
void | remove_logger (const Logger *logger) override |
| Removes a logger from the list of subscribed loggers.
|
const std::vector< std::shared_ptr< const Logger > > & | get_loggers () const override |
| Returns the vector containing all loggers registered at this object.
|
void | clear_loggers () override |
| Remove all loggers registered at this object.
|
void | remove_logger (ptr_param< const Logger > logger) |
void | convert_to (result_type *result) const override |
void | move_to (result_type *result) override |
virtual void | convert_to (result_type *result) const=0 |
| Converts the implementer to an object of type result_type.
|
virtual void | move_to (result_type *result)=0 |
| Converts the implementer to an object of type result_type by moving data from this object.
|
| DistributedBase (const DistributedBase &other)=default |
| DistributedBase (DistributedBase &&other)=default |
DistributedBase & | operator= (const DistributedBase &) |
| Copy assignment that doesn't change the used mpi::communicator.
|
DistributedBase & | operator= (DistributedBase &&) noexcept |
| Move assignment that doesn't change the used mpi::communicator.
|
mpi::communicator | get_communicator () const |
| Access the used mpi::communicator.
|
|
static std::unique_ptr< Matrix > | create (std::shared_ptr< const Executor > exec, mpi::communicator comm) |
| Creates an empty distributed matrix.
|
template<typename MatrixType, typename = std::enable_if_t<gko::detail::is_matrix_type_builder< MatrixType, ValueType, LocalIndexType>::value>> |
static std::unique_ptr< Matrix > | create (std::shared_ptr< const Executor > exec, mpi::communicator comm, MatrixType matrix_template) |
| Creates an empty distributed matrix with specified type for local matrices.
|
template<typename LocalMatrixType, typename NonLocalMatrixType, typename = std::enable_if_t< gko::detail::is_matrix_type_builder< LocalMatrixType, ValueType, LocalIndexType>::value && gko::detail::is_matrix_type_builder< NonLocalMatrixType, ValueType, LocalIndexType>::value>> |
static std::unique_ptr< Matrix > | create (std::shared_ptr< const Executor > exec, mpi::communicator comm, LocalMatrixType local_matrix_template, NonLocalMatrixType non_local_matrix_template) |
| Creates an empty distributed matrix with specified types for the local matrix and the non-local matrix.
|
static std::unique_ptr< Matrix > | create (std::shared_ptr< const Executor > exec, mpi::communicator comm, ptr_param< const LinOp > matrix_template) |
| Creates an empty distributed matrix with specified type for local matrices.
|
static std::unique_ptr< Matrix > | create (std::shared_ptr< const Executor > exec, mpi::communicator comm, ptr_param< const LinOp > local_matrix_template, ptr_param< const LinOp > non_local_matrix_template) |
| Creates an empty distributed matrix with specified types for the local matrix and the non-local matrix.
|
static std::unique_ptr< Matrix > | create (std::shared_ptr< const Executor > exec, mpi::communicator comm, dim< 2 > size, std::shared_ptr< LinOp > local_linop) |
| Creates a local-only distributed matrix with existent LinOp.
|
static std::unique_ptr< Matrix > | create (std::shared_ptr< const Executor > exec, mpi::communicator comm, dim< 2 > size, std::shared_ptr< LinOp > local_linop, std::shared_ptr< LinOp > non_local_linop, std::vector< comm_index_type > recv_sizes, std::vector< comm_index_type > recv_offsets, array< local_index_type > recv_gather_idxs) |
| Creates distributed matrix with existent local and non-local LinOp and the corresponding mapping to collect the non-local data from the other ranks.
|
static std::unique_ptr< Matrix > | create (std::shared_ptr< const Executor > exec, mpi::communicator comm, index_map< local_index_type, global_index_type > imap, std::shared_ptr< LinOp > local_linop, std::shared_ptr< LinOp > non_local_linop) |
| Creates distributed matrix with existent local and non-local LinOp and the corresponding mapping to collect the non-local data from the other ranks.
|
template<typename ValueType = default_precision, typename LocalIndexType = int32, typename GlobalIndexType = int64>
class gko::experimental::distributed::Matrix< ValueType, LocalIndexType, GlobalIndexType >
The Matrix class defines a (MPI-)distributed matrix.
The matrix is stored in a row-wise distributed format. Each process owns a specific set of rows, where the assignment of rows is defined by a row Partition. The following depicts the distribution of global rows according to their assigned part-id (which will usually be the owning process id):
Part-Id Global Rows Part-Id Local Rows
0 | .. 1 2 .. .. .. | 0 | .. 1 2 .. .. .. |
1 | 3 4 .. .. .. .. | | 13 .. .. .. 14 .. |
2 | .. 5 6 .. 7 .. | ----> 1 | 3 4 .. .. .. .. |
2 | .. .. .. 8 .. 9 | ----> | .. .. .. 10 11 12 |
1 | .. .. .. 10 11 12 | 2 | .. 5 6 .. 7 .. |
0 | 13 .. .. .. 14 .. | | .. .. .. 8 .. 9 |
The local rows are further split into two matrices on each process. One matrix, called local, contains only entries from columns that are also owned by the process, while the other one, called non_local, contains entries from columns that are not owned by the process. The non-local matrix is stored in a compressed format, where empty columns are discarded and the remaining columns are renumbered. This splitting is depicted in the following:
Part-Id Global Local Non-Local
0 | .. 1 ! 2 .. ! .. .. | | .. 1 | | 2 |
0 | 3 4 ! .. .. ! .. .. | | 3 4 | | .. |
|-----------------------|
1 | .. 5 ! 6 .. ! 7 .. | ----> | 6 .. | | 5 7 .. |
1 | .. .. ! .. 8 ! .. 9 | ----> | 8 .. | | .. .. 9 |
|-----------------------|
2 | .. .. ! .. 10 ! 11 12 | | 11 12 | | .. 10 |
2 | 13 .. ! .. .. ! 14 .. | | 14 .. | | 13 .. |
This uses the same ownership of the columns as for the rows. Additionally, the ownership of the columns may be explicitly defined with an second column partition. If that is not provided, the same row partition will be used for the columns. Using a column partition also allows to create non-square matrices, like the one below:
Part-Id Global Local Non-Local
P_R/P_C 2 2 0 1
0 | .. 1 2 .. | | 2 | | 1 .. |
0 | 3 4 .. .. | | .. | | 3 4 |
|-------------|
1 | .. 5 6 .. | ----> | .. | | 6 5 |
1 | .. .. .. 8 | ----> | 8 | | .. .. |
|-------------|
2 | .. .. .. 10 | | .. .. | | 10 |
2 | 13 .. .. .. | | 13 .. | | .. |
Here P_R denotes the row partition and P_C denotes the column partition.
The Matrix should be filled using the read_distributed method, e.g.
static std::unique_ptr< Matrix > create(std::shared_ptr< const Executor > exec, mpi::communicator comm)
Creates an empty distributed matrix.
static std::unique_ptr< Partition > build_from_mapping(std::shared_ptr< const Executor > exec, const array< comm_index_type > &mapping, comm_index_type num_parts)
Builds a partition from a given mapping global_index -> part_id.
This structure is used as an intermediate data type to store a sparse matrix.
Definition matrix_data.hpp:126
or if different partitions for the rows and columns are used:
mat->read_distributed(
matrix_data, row_part, col_part);
This will set the dimensions of the global and local matrices automatically by deducing the sizes from the partitions.
By default the Matrix type uses Csr for both stored matrices. It is possible to explicitly change the datatype for the stored matrices, with the constraint that the new type should implement the LinOp and ReadableFromMatrixData interface. The type can be set by:
exec, comm,
Ell<ValueType, LocalIndexType>::create(exec).get(),
Coo<ValueType, LocalIndexType>::create(exec).get());
Alternatively, the helper function with_matrix_type can be used:
exec, comm,
auto with_matrix_type(Args &&... create_args)
This function returns a type that delays a call to MatrixType::create.
Definition matrix.hpp:127
- See also
- with_matrix_type
The Matrix LinOp supports the following operations:
A->apply(b, x)
A->apply(alpha, b, beta, x)
The Matrix class defines a (MPI-)distributed matrix.
Definition matrix.hpp:274
Vector is a format which explicitly stores (multiple) distributed column vectors in a dense storage f...
Definition vector.hpp:77
Dense is a matrix format which explicitly stores all values of the matrix.
Definition dense.hpp:120
- Template Parameters
-
ValueType | The underlying value type. |
LocalIndexType | The index type used by the local matrices. |
GlobalIndexType | The type for global indices. |