Ginkgo
Generated from pipelines/1330831941 branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
|
This type is a device-side equivalent to matrix_data. More...
#include <ginkgo/core/base/device_matrix_data.hpp>
Classes | |
struct | arrays |
Stores the internal arrays of a device_matrix_data object. More... | |
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) | |
Initializes a new device_matrix_data object. More... | |
device_matrix_data (std::shared_ptr< const Executor > exec, const device_matrix_data &data) | |
Initializes a device_matrix_data object by copying an existing object on another executor. More... | |
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. More... | |
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 |
Copies the device_matrix_data entries to the host to return a regular matrix_data object with the same dimensions and entries. More... | |
void | 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. | |
void | remove_zeros () |
Removes all zero entries from the storage. More... | |
void | sum_duplicates () |
Sums up all duplicate entries pointing to the same non-zero location. More... | |
std::shared_ptr< const Executor > | get_executor () const |
Returns the executor used to store the device_matrix_data entries. More... | |
dim< 2 > | get_size () const |
Returns the dimensions of the matrix. More... | |
size_type | get_num_elems () const |
Returns the number of stored elements of the matrix. More... | |
size_type | get_num_stored_elements () const |
Returns the number of stored elements of the matrix. More... | |
index_type * | get_row_idxs () |
Returns a pointer to the row index array. More... | |
const index_type * | get_const_row_idxs () const |
Returns a pointer to the constant row index array. More... | |
index_type * | get_col_idxs () |
Returns a pointer to the column index array. More... | |
const index_type * | get_const_col_idxs () const |
Returns a pointer to the constant column index array. More... | |
value_type * | get_values () |
Returns a pointer to the value array. More... | |
const value_type * | get_const_values () const |
Returns a pointer to the constant value array. More... | |
void | resize_and_reset (size_type new_num_entries) |
Resizes the internal storage to the given number of stored matrix entries. More... | |
void | resize_and_reset (dim< 2 > new_size, size_type new_num_entries) |
Resizes the matrix and internal storage to the given dimensions. More... | |
arrays | empty_out () |
Moves out the internal arrays of the device_matrix_data object and resets it to an empty 0x0 matrix. More... | |
Static Public Member Functions | |
static device_matrix_data | create_from_host (std::shared_ptr< const Executor > exec, const host_type &data) |
Creates a device_matrix_data object from the given host data on the given executor. More... | |
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).
ValueType | the type used to store matrix values |
IndexType | the type used to store matrix row and column indices |
|
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.
exec | the executor to be used to store the matrix entries |
size | the matrix dimensions |
num_entries | the number of entries to be stored |
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.
exec | the executor to be used to store the matrix entries |
data | the device_matrix data object to copy, potentially stored on another executor. |
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.
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 |
|
inline |
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 |
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.
Referenced by gko::ReadableFromMatrixData< ValueType, int32 >::read().
|
static |
Creates a device_matrix_data object from the given host data on the given executor.
exec | the executor to create the device_matrix_data on. |
data | the data to be wrapped or copied into a device_matrix_data. |
data
copied to the device executor. 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.
|
inline |
Returns a pointer to the column index array.
References gko::array< ValueType >::get_data().
|
inline |
Returns a pointer to the constant column index array.
References gko::array< ValueType >::get_const_data().
|
inline |
Returns a pointer to the constant row index array.
References gko::array< ValueType >::get_const_data().
|
inline |
Returns a pointer to the constant value array.
References gko::array< ValueType >::get_const_data().
|
inline |
Returns the executor used to store the device_matrix_data entries.
References gko::array< ValueType >::get_executor().
|
inline |
Returns the number of stored elements of the matrix.
References gko::device_matrix_data< ValueType, IndexType >::get_num_stored_elements().
|
inline |
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().
|
inline |
Returns a pointer to the row index array.
References gko::array< ValueType >::get_data().
|
inline |
Returns the dimensions of the matrix.
|
inline |
Returns a pointer to the value array.
References gko::array< ValueType >::get_data().
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.
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.
new_size | the new matrix dimensions. |
new_num_entries | the new number of stored matrix entries. |
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.
new_num_entries | the new number of stored matrix entries. |
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.