12 template<
class Device>
15 using exspace =
typename Device::execution_space;
29 View<double**,CLayout, Device>
value;
37 View<double*,CLayout, Device>
csr_v;
55 value(
"value",m_in,w_in),
60 Kokkos::deep_copy(
eindex, -1);
76 for(
int i=0; i<
m; i++){
96 Matrix(
int m_in,
int n_in,
int w_in,
int nnz_in,
bool is_csr_in,
int* csr_ridx_or_eindex,
int* csr_cidx_or_nelement,
double* values)
121 template<
class Device2>
153 printf(
"\nWarning: Trying to convert matrix to csr format, but it is already in csr format.\n");
161 for (
int i=0; i<
m; i++){
175 for (
int i=0; i<
m; i++){
185 value = View<double**,CLayout, Device>();
186 eindex = View<int**,CLayout, Device>();
187 nelement = View<int*,CLayout, Device>();
205 DEVICE_PRINTF(
"\n Error: set_value is only allowed when matrix is not in csr format");
210 if(i>=
m || j>=
n || i<0 || j<0){
211 DEVICE_PRINTF(
"\n Error: Out of bounds access in set_value");
219 value(i,l) = value_in;
221 value(i,l) += value_in;
235 DEVICE_PRINTF(
"\nError in set_value: Not enough memory space for matrix.");
251 void mult_org(
const View<double*,CLayout,Device>& x,
const View<double*,Kokkos::LayoutRight,Device>& y)
const{
255 for (
int j=0; j<mat.
nelement(i); j++){
268 void mult_csr(
const View<double*,CLayout,Device>& x,
const View<double*,Kokkos::LayoutRight,Device>& y)
const{
321 void mult_tensor_org(
const View<double**,CLayout,Device>& x,
const View<double**,Kokkos::LayoutRight,Device>& y)
const{
322 int nv = x.extent(1);
328 for (
int j=0; j<=mat.
nelement(i); j++){
341 void mult_tensor_csr(
const View<double**,CLayout,Device>& x,
const View<double**,Kokkos::LayoutRight,Device>& y)
const{
342 int nv = x.extent(1);
363 void mult(
const View<double*,CLayout,Device>& x,
const View<double*,Kokkos::LayoutRight,Device>& y)
const{
393 void mult_tensor(
const View<double**,CLayout,Device>& x,
const View<double**,Kokkos::LayoutRight,Device>& y)
const{
void array_deep_copy(T *array, const Kokkos::View< T *, Kokkos::LayoutRight, Device > &view)
Definition: array_deep_copy.hpp:11
View< int **, CLayout, Device > eindex
column index - 1-indexed!!
Definition: matrix.hpp:30
void mirror_copy(T1 &view_dest, const T2 &view_src)
Definition: my_mirror_view.hpp:122
#define DEVICE_PRINTF(...)
Definition: space_settings.hpp:85
void mult_tensor(const View< double **, CLayout, Device > &x, const View< double **, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.hpp:393
Matrix< Device2 > mirror() const
Definition: matrix.hpp:122
Matrix(int m_in, int n_in, int w_in, int nnz_in, bool is_csr_in, int *csr_ridx_or_eindex, int *csr_cidx_or_nelement, double *values)
Definition: matrix.hpp:96
int nnz
if in CSR format, number of (nonzero) values
Definition: matrix.hpp:35
View< double *, CLayout, Device > csr_v
value of CSR - nnz
Definition: matrix.hpp:37
Definition: matrix.hpp:18
typename HostType::execution_space exspace
Use execution space where matrix views are allocated.
Definition: matrix.hpp:15
Definition: matrix.hpp:19
int n
of columns (size of each row)
Definition: matrix.hpp:27
idx
Definition: diag_f0_df_port1.hpp:32
View< int *, CLayout, Device > csr_cidx
columun index - nnz
Definition: matrix.hpp:38
void mult_tensor_csr(const View< double **, CLayout, Device > &x, const View< double **, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.hpp:341
View< int *, CLayout, Device > csr_ridx
row index for CSR - m+1
Definition: matrix.hpp:36
int m
of rows (size of each column)
Definition: matrix.hpp:26
int width
Definition: matrix.hpp:28
Definition: matrix.hpp:13
bool is_csr
Whether the matrix is in CSR format.
Definition: matrix.hpp:34
Matrix()
Definition: matrix.hpp:42
View< T *, CLayout, Device > my_mirror_view(const View< T *, CLayout, Device > &view, Device nd)
Definition: my_mirror_view.hpp:14
void convert_org_to_csr()
Definition: matrix.hpp:151
Matrix(int m_in, int n_in, int w_in)
Definition: matrix.hpp:51
KOKKOS_INLINE_FUNCTION void set_value(int i, int j, double value_in, SetValueOpt flag) const
Definition: matrix.hpp:203
Type
Definition: matrix.hpp:22
SetValueOpt
Definition: matrix.hpp:17
void mult(const View< double *, CLayout, Device > &x, const View< double *, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.hpp:363
View< int *, CLayout, Device > nelement
of non-zero element of each row
Definition: matrix.hpp:31
Matrix(Type matrix_type, int m_in)
Definition: matrix.hpp:67
void parallel_for(const std::string name, int n_ptl, Function func, Option option, HostAoSoA aosoa_h, DeviceAoSoA aosoa_d)
Definition: streamed_parallel_for.hpp:252
Kokkos::ViewAllocateWithoutInitializing NoInit
Definition: space_settings.hpp:68
Definition: matrix.hpp:23
void mult_org(const View< double *, CLayout, Device > &x, const View< double *, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.hpp:251
View< double **, CLayout, Device > value
matrix value
Definition: matrix.hpp:29
void mult_tensor_org(const View< double **, CLayout, Device > &x, const View< double **, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.hpp:321
void mult_csr(const View< double *, CLayout, Device > &x, const View< double *, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.hpp:268