device_matrix_data< ValueType, IndexType > Class Template Reference#
|
Reference API
|
#include <ginkgo/core/base/device_matrix_data.hpp>
Classes | |
| struct | arrays |
Public Types | |
| using | value_type = ValueType |
| using | index_type = IndexType |
| using | nonzero_type = matrix_data_entry< value_type, index_type > |
| using | host_type = matrix_data< value_type, index_type > |
Public Member Functions | |
| device_matrix_data (std::shared_ptr< const Executor > exec, dim< 2 > size={}, size_type num_entries=0) | |
| device_matrix_data (std::shared_ptr< const Executor > exec, const device_matrix_data &data) | |
| device_matrix_data (std::shared_ptr< const Executor > exec, dim< 2 > size, array< index_type > row_idxs, array< index_type > col_idxs, array< value_type > values) | |
| template<typename InputValueType , typename RowIndexType , typename ColIndexType > | |
| device_matrix_data (std::shared_ptr< const Executor > exec, dim< 2 > size, std::initializer_list< RowIndexType > row_idxs, std::initializer_list< ColIndexType > col_idxs, std::initializer_list< InputValueType > values) | |
| host_type | copy_to_host () const |
| void | fill_zero () |
| void | sort_row_major () |
| void | remove_zeros () |
| void | sum_duplicates () |
| std::shared_ptr< const Executor > | get_executor () const |
| dim< 2 > | get_size () const |
| size_type | get_num_elems () const |
| size_type | get_num_stored_elements () const |
| index_type * | get_row_idxs () |
| const index_type * | get_const_row_idxs () const |
| index_type * | get_col_idxs () |
| const index_type * | get_const_col_idxs () const |
| value_type * | get_values () |
| const value_type * | get_const_values () const |
| void | resize_and_reset (size_type new_num_entries) |
| void | resize_and_reset (dim< 2 > new_size, size_type new_num_entries) |
| arrays | empty_out () |
Static Public Member Functions | |
| static device_matrix_data | create_from_host (std::shared_ptr< const Executor > exec, const host_type &data) |
Detailed Description
class gko::device_matrix_data< ValueType, IndexType >
This type is a device-side equivalent to matrix_data. It stores the data necessary to initialize any matrix format in Ginkgo in individual value, column and row index arrays together with associated matrix dimensions. matrix_data uses array-of-Structs storage (AoS), while device_matrix_data uses Struct-of-Arrays (SoA).
- Note
- To be used with a Ginkgo matrix type, the entry array must be sorted in row-major order, i.e. by row index, then by column index within rows. This can be achieved by calling the sort_row_major function.
- The data must not contain any duplicate (row, column) pairs.
- Template Parameters
-
ValueType the type used to store matrix values IndexType the type used to store matrix row and column indices
Constructor & Destructor Documentation
◆ device_matrix_data() [1/4]
|
explicit |
Initializes a new device_matrix_data object. It uses the given executor to allocate storage for the given number of entries and matrix dimensions.
- Parameters
-
exec the executor to be used to store the matrix entries size the matrix dimensions num_entries the number of entries to be stored
◆ device_matrix_data() [2/4]
| gko::device_matrix_data< ValueType, IndexType >::device_matrix_data | ( | std::shared_ptr< const Executor > | exec, |
| const device_matrix_data< ValueType, IndexType > & | data | ||
| ) |
Initializes a device_matrix_data object by copying an existing object on another executor.
- Parameters
-
exec the executor to be used to store the matrix entries data the device_matrix data object to copy, potentially stored on another executor.
◆ device_matrix_data() [3/4]
| gko::device_matrix_data< ValueType, IndexType >::device_matrix_data | ( | std::shared_ptr< const Executor > | exec, |
| dim< 2 > | size, | ||
| array< index_type > | row_idxs, | ||
| array< index_type > | col_idxs, | ||
| array< value_type > | values | ||
| ) |
Initializes a new device_matrix_data object from existing data.
- Parameters
-
size the matrix dimensions values the array containing the matrix values col_idxs the array containing the matrix column indices row_idxs the array containing the matrix row indices
◆ device_matrix_data() [4/4]
|
inline |
Initializes a new device_matrix_data object from existing data.
- Parameters
-
size the matrix dimensions values the array containing the matrix values col_idxs the array containing the matrix column indices row_idxs the array containing the matrix row indices
Member Function Documentation
◆ copy_to_host()
| host_type gko::device_matrix_data< ValueType, IndexType >::copy_to_host | ( | ) | const |
Copies the device_matrix_data entries to the host to return a regular matrix_data object with the same dimensions and entries.
- Returns
- a matrix_data object with the same dimensions and entries.
Referenced by gko::ReadableFromMatrixData< ValueType, IndexType >::read().
◆ create_from_host()
|
static |
Creates a device_matrix_data object from the given host data on the given executor.
- Parameters
-
exec the executor to create the device_matrix_data on. data the data to be wrapped or copied into a device_matrix_data.
- Returns
- a device_matrix_data object with the same size and entries as
datacopied to the device executor.
◆ empty_out()
| arrays gko::device_matrix_data< ValueType, IndexType >::empty_out | ( | ) |
Moves out the internal arrays of the device_matrix_data object and resets it to an empty 0x0 matrix.
- Returns
- a struct containing the internal arrays.
◆ fill_zero()
| void gko::device_matrix_data< ValueType, IndexType >::fill_zero | ( | ) |
Fills the matrix entries with zeros
◆ get_col_idxs()
|
inline |
Returns a pointer to the column index array
- Returns
- a pointer to the column index array
References gko::array< ValueType >::get_data().
◆ get_const_col_idxs()
|
inline |
Returns a pointer to the constant column index array
- Returns
- a pointer to the constant column index array
References gko::array< ValueType >::get_const_data().
◆ get_const_row_idxs()
|
inline |
Returns a pointer to the constant row index array
- Returns
- a pointer to the constant row index array
References gko::array< ValueType >::get_const_data().
◆ get_const_values()
|
inline |
Returns a pointer to the constant value array
- Returns
- a pointer to the constant value array
References gko::array< ValueType >::get_const_data().
◆ get_executor()
|
inline |
Returns the executor used to store the device_matrix_data entries.
- Returns
- the executor used to store the device_matrix_data entries.
References gko::array< ValueType >::get_executor().
◆ get_num_elems()
|
inline |
Returns the number of stored elements of the matrix.
- Returns
- the number of stored elements of the matrix.
References gko::device_matrix_data< ValueType, IndexType >::get_num_stored_elements().
◆ get_num_stored_elements()
|
inline |
Returns the number of stored elements of the matrix.
- Returns
- the number of stored elements of the matrix.
References gko::array< ValueType >::get_size().
Referenced by gko::device_matrix_data< ValueType, IndexType >::get_num_elems().
◆ get_row_idxs()
|
inline |
Returns a pointer to the row index array
- Returns
- a pointer to the row index array
References gko::array< ValueType >::get_data().
◆ get_size()
|
inline |
Returns the dimensions of the matrix.
- Returns
- the dimensions of the matrix.
◆ get_values()
|
inline |
Returns a pointer to the value array
- Returns
- a pointer to the value array
References gko::array< ValueType >::get_data().
◆ remove_zeros()
| void gko::device_matrix_data< ValueType, IndexType >::remove_zeros | ( | ) |
Removes all zero entries from the storage. This does not modify the storage if there are no zero entries, and keeps the relative order of nonzero entries otherwise.
◆ resize_and_reset() [1/2]
| void gko::device_matrix_data< ValueType, IndexType >::resize_and_reset | ( | dim< 2 > | new_size, |
| size_type | new_num_entries | ||
| ) |
Resizes the matrix and internal storage to the given dimensions. The resulting storage should be assumed uninitialized.
- Parameters
-
new_size the new matrix dimensions. new_num_entries the new number of stored matrix entries.
◆ resize_and_reset() [2/2]
| void gko::device_matrix_data< ValueType, IndexType >::resize_and_reset | ( | size_type | new_num_entries | ) |
Resizes the internal storage to the given number of stored matrix entries. The resulting storage should be assumed uninitialized.
- Parameters
-
new_num_entries the new number of stored matrix entries.
◆ sort_row_major()
| void gko::device_matrix_data< ValueType, IndexType >::sort_row_major | ( | ) |
Sorts the matrix entries in row-major order This means that they will be sorted by row index first, and then by column index inside each row.
◆ sum_duplicates()
| void gko::device_matrix_data< ValueType, IndexType >::sum_duplicates | ( | ) |
Sums up all duplicate entries pointing to the same non-zero location. The output will be sorted in row-major order, and it will only reallocate if duplicates exist.
The documentation for this class was generated from the following file:
- ginkgo/core/base/device_matrix_data.hpp
Generated by