monolish  0.14.2
MONOlithic LIner equation Solvers for Highly-parallel architecture
Public Member Functions | Public Attributes | Private Attributes | List of all members
monolish::matrix::CRS< Float > Class Template Reference

Compressed Row Storage (CRS) format Matrix. More...

#include <monolish_coo.hpp>

Collaboration diagram for monolish::matrix::CRS< Float >:
Collaboration graph

Public Member Functions

void col (const size_t c, vector< Float > &vec) const
 get column vector More...
 
void col (const size_t c, view1D< matrix::Dense< Float >, Float > &vec) const
 
void col (const size_t c, view1D< vector< Float >, Float > &vec) const
 
void compute_hash ()
 compute index array hash (to compare structure) More...
 
void convert (COO< Float > &coo)
 Convert CRS matrix from COO matrix, also compute the hash. More...
 
void convert (CRS< Float > &crs)
 Convert CRS matrix from COO matrix. More...
 
 CRS ()
 
 CRS (const CRS< Float > &mat)
 Create CRS matrix from CRS matrix. More...
 
 CRS (const size_t M, const size_t N, const size_t NNZ)
 declare CRS matrix More...
 
 CRS (const size_t M, const size_t N, const size_t NNZ, const int *rowptr, const int *colind, const Float *value)
 Create CRS matrix from array, also compute the hash. More...
 
 CRS (const size_t M, const size_t N, const size_t NNZ, const int *rowptr, const int *colind, const Float *value, const size_t origin)
 Create CRS matrix from array, also compute the hash. More...
 
 CRS (const size_t M, const size_t N, const std::vector< int > &rowptr, const std::vector< int > &colind, const std::vector< Float > &value)
 Create CRS matrix from std::vector, also compute the hash. More...
 
 CRS (const size_t M, const size_t N, const std::vector< int > &rowptr, const std::vector< int > &colind, const vector< Float > &value)
 Create CRS matrix from std::vector, also compute the hash. More...
 
 CRS (COO< Float > &coo)
 Create CRS matrix from COO matrix, also compute the hash. More...
 
void device_free () const
 free data on GPU More...
 
void diag (vector< Float > &vec) const
 get diag. vector More...
 
void diag (view1D< matrix::Dense< Float >, Float > &vec) const
 
void diag (view1D< vector< Float >, Float > &vec) const
 
bool equal (const CRS< Float > &mat, bool compare_cpu_and_device=false) const
 Comparing matricies (A == mat) More...
 
void fill (Float value)
 fill matrix elements with a scalar value More...
 
size_t get_col () const
 get # of col More...
 
double get_data_size () const
 
bool get_device_mem_stat () const
 true: sended, false: not send More...
 
size_t get_hash () const
 get index array hash (to compare structure) More...
 
size_t get_nnz () const
 get # of non-zeros More...
 
size_t get_row () const
 get # of row More...
 
void nonfree_recv ()
 recv. data to GPU (w/o free) More...
 
bool operator!= (const CRS< Float > &mat) const
 Comparing matricies (A != mat) More...
 
void operator= (const CRS< Float > &mat)
 matrix copy More...
 
bool operator== (const CRS< Float > &mat) const
 Comparing matricies (A == mat) More...
 
void print_all (bool force_cpu=false) const
 print all elements to standard I/O More...
 
void recv ()
 recv. data to GPU, and free data on GPU More...
 
void row (const size_t r, vector< Float > &vec) const
 get row vector More...
 
void row (const size_t r, view1D< matrix::Dense< Float >, Float > &vec) const
 
void row (const size_t r, view1D< vector< Float >, Float > &vec) const
 
void send () const
 send data to GPU More...
 
void set_ptr (const size_t M, const size_t N, const std::vector< int > &rowptr, const std::vector< int > &colind, const std::vector< Float > &value)
 Set CRS array from std::vector. More...
 
std::string type () const
 get format name "CRS" More...
 
 ~CRS ()
 destructor of CRS matrix, free GPU memory More...
 

Public Attributes

std::vector< int > col_ind
 CRS format column index, which stores column numbers of the non-zero elements (size nnz) More...
 
std::vector< int > row_ptr
 CRS format row pointer, which stores the starting points of the rows of the arrays value and col_ind (size M+1) More...
 
std::vector< Float > val
 CRS format value, which stores values of the non-zero elements (size nnz) More...
 

Private Attributes

size_t colN
 # of col More...
 
bool gpu_status = false
 true: sended, false: not send More...
 
size_t nnz
 # of non-zero element More...
 
size_t rowN
 # of row More...
 
size_t structure_hash
 hash, created from row_ptr and col_ind More...
 

Detailed Description

template<typename Float>
class monolish::matrix::CRS< Float >

Compressed Row Storage (CRS) format Matrix.

Note
  • Multi-threading: true
  • GPU acceleration: true

Definition at line 36 of file monolish_coo.hpp.

Constructor & Destructor Documentation

◆ CRS() [1/8]

template<typename Float >
monolish::matrix::CRS< Float >::CRS ( )
inline

Definition at line 82 of file monolish_crs.hpp.

◆ CRS() [2/8]

template<typename T >
template monolish::matrix::CRS< Float >::CRS ( const size_t  M,
const size_t  N,
const size_t  NNZ 
)

declare CRS matrix

Parameters
M# of row
N# of col
NNZ# of nnz
Note
  • # of computation: (M+1)+2nnz
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 11 of file crs_constructor.cpp.

Here is the call graph for this function:

◆ CRS() [3/8]

template<typename Float >
monolish::matrix::CRS< Float >::CRS ( const size_t  M,
const size_t  N,
const size_t  NNZ,
const int *  rowptr,
const int *  colind,
const Float *  value 
)

Create CRS matrix from array, also compute the hash.

Parameters
M# of row
N# of col
NNZ# of non-zero elements
rowptrrow_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1)
colindcol_ind, which stores the column numbers of the non-zero elements (size nnz)
valuevalue index, which stores the non-zero elements (size nnz)
Note
  • # of computation: (M+1)+2nnz + (M+1)+nnz (compute hash)
  • Multi-threading: false
  • GPU acceleration: false

◆ CRS() [4/8]

template<typename Float >
monolish::matrix::CRS< Float >::CRS ( const size_t  M,
const size_t  N,
const size_t  NNZ,
const int *  rowptr,
const int *  colind,
const Float *  value,
const size_t  origin 
)

Create CRS matrix from array, also compute the hash.

Parameters
M# of row
N# of col
NNZ# of non-zero elements
rowptrrow_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1)
colindn-origin col_ind, which stores the column numbers of the non-zero elements (size nnz)
valuevalue index, which stores the non-zero elements (size nnz)
Note
  • # of computation: (M+1)+2nnz + (M+1)+nnz (compute hash) + nnz(compute origin)
  • Multi-threading: false
  • GPU acceleration: false

◆ CRS() [5/8]

template<typename Float >
monolish::matrix::CRS< Float >::CRS ( const size_t  M,
const size_t  N,
const std::vector< int > &  rowptr,
const std::vector< int > &  colind,
const std::vector< Float > &  value 
)

Create CRS matrix from std::vector, also compute the hash.

Parameters
M# of row
N# of col
rowptrrow_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1)
colindcol_ind, which stores the column numbers of the non-zero elements (size nnz)
valuevalue index, which stores the non-zero elements (size nnz)
Note
  • # of computation: (M+1)+2nnz + (M+1)+nnz (compute hash)
  • Multi-threading: false
  • GPU acceleration: false

◆ CRS() [6/8]

template<typename Float >
monolish::matrix::CRS< Float >::CRS ( const size_t  M,
const size_t  N,
const std::vector< int > &  rowptr,
const std::vector< int > &  colind,
const vector< Float > &  value 
)

Create CRS matrix from std::vector, also compute the hash.

Parameters
M# of row
N# of col
rowptrrow_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1)
colindcol_ind, which stores the column numbers of the non-zero elements (size nnz)
valuevalue index, which stores the non-zero elements (size nnz)
Note
  • # of computation: (M+1)+2nnz + (M+1)+nnz (compute hash)
  • Multi-threading: false
  • GPU acceleration: true

◆ CRS() [7/8]

template<typename Float >
monolish::matrix::CRS< Float >::CRS ( COO< Float > &  coo)
inline

Create CRS matrix from COO matrix, also compute the hash.

Parameters
cooSource COO format matrix
Returns
coo COO format matrix
Note
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 193 of file monolish_crs.hpp.

Here is the call graph for this function:

◆ CRS() [8/8]

template<typename Float >
monolish::matrix::CRS< Float >::CRS ( const CRS< Float > &  mat)

Create CRS matrix from CRS matrix.

Parameters
matCRS format matrix
Note
  • # of computation: (M+1)+2nnz
  • Multi-threading: true
  • GPU acceleration: true
    • # of data transfer: (M+1)+2nnz (only allocation)
      • if mat.gpu_status == true; coping data on CPU and GPU respectively
      • else; coping data only on CPU

◆ ~CRS()

template<typename Float >
monolish::matrix::CRS< Float >::~CRS ( )
inline

destructor of CRS matrix, free GPU memory

Note
  • Multi-threading: false
  • GPU acceleration: true
    • # of data transfer: 0

Definition at line 339 of file monolish_crs.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ col() [1/3]

template<typename Float >
void monolish::matrix::CRS< Float >::col ( const size_t  c,
vector< Float > &  vec 
) const

get column vector

Parameters
ccolumn number
veccolumn vector
Note
  • # of computation: about nnz
  • Multi-threading: true
  • GPU acceleration: true

◆ col() [2/3]

template<typename Float >
void monolish::matrix::CRS< Float >::col ( const size_t  c,
view1D< matrix::Dense< Float >, Float > &  vec 
) const

◆ col() [3/3]

template<typename Float >
void monolish::matrix::CRS< Float >::col ( const size_t  c,
view1D< vector< Float >, Float > &  vec 
) const

◆ compute_hash()

template<typename T >
template void monolish::matrix::CRS< Float >::compute_hash ( )

compute index array hash (to compare structure)

Note
  • # of computation: nnz + rowN + 1
  • Multi-threading: true
  • GPU acceleration: true

Definition at line 9 of file hash.cpp.

Here is the call graph for this function:

◆ convert() [1/2]

template<typename Float >
void monolish::matrix::CRS< Float >::convert ( COO< Float > &  coo)

Convert CRS matrix from COO matrix, also compute the hash.

Parameters
cooCOO format matrix
Note
  • Multi-threading: false
  • GPU acceleration: false
Here is the caller graph for this function:

◆ convert() [2/2]

template<typename Float >
void monolish::matrix::CRS< Float >::convert ( CRS< Float > &  crs)

Convert CRS matrix from COO matrix.

Parameters
crsCRS format matrix
Note
  • Multi-threading: true
  • GPU acceleration: false

◆ device_free()

template<typename T >
template void monolish::matrix::CRS< Float >::device_free ( ) const

free data on GPU

Note
  • Multi-threading: false
  • GPU acceleration: true
    • # of data transfer: 0

Definition at line 153 of file gpu_comm.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ diag() [1/3]

template<typename Float >
void monolish::matrix::CRS< Float >::diag ( vector< Float > &  vec) const

get diag. vector

Parameters
vecdiag. vector
Note
  • # of computation: M
  • Multi-threading: true
  • GPU acceleration: true

◆ diag() [2/3]

template<typename Float >
void monolish::matrix::CRS< Float >::diag ( view1D< matrix::Dense< Float >, Float > &  vec) const

◆ diag() [3/3]

template<typename Float >
void monolish::matrix::CRS< Float >::diag ( view1D< vector< Float >, Float > &  vec) const

◆ equal()

template<typename Float >
template bool monolish::matrix::CRS< Float >::equal ( const CRS< Float > &  mat,
bool  compare_cpu_and_device = false 
) const

Comparing matricies (A == mat)

Parameters
matCRS matrix
compare_cpu_and_devicecompare data on both CPU and GPU
Returns
true or false
Note
  • # of computation: (M+1)+2nnz
  • Multi-threading: true
  • GPU acceleration: true

Definition at line 10 of file compare_crs.cpp.

Here is the call graph for this function:

◆ fill()

template<typename Float >
template void monolish::matrix::CRS< Float >::fill ( Float  value)

fill matrix elements with a scalar value

Parameters
valuescalar value
Note
  • # of computation: N
  • Multi-threading: true
  • GPU acceleration: true

Definition at line 9 of file fill_crs.cpp.

Here is the call graph for this function:

◆ get_col()

template<typename Float >
size_t monolish::matrix::CRS< Float >::get_col ( ) const
inline

get # of col

Note
  • # of computation: 1
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 252 of file monolish_crs.hpp.

Here is the caller graph for this function:

◆ get_data_size()

template<typename Float >
double monolish::matrix::CRS< Float >::get_data_size ( ) const
inline

Definition at line 393 of file monolish_crs.hpp.

Here is the call graph for this function:

◆ get_device_mem_stat()

template<typename Float >
bool monolish::matrix::CRS< Float >::get_device_mem_stat ( ) const
inline

true: sended, false: not send

Returns
gpu status

Definition at line 330 of file monolish_crs.hpp.

Here is the caller graph for this function:

◆ get_hash()

template<typename Float >
size_t monolish::matrix::CRS< Float >::get_hash ( ) const
inline

get index array hash (to compare structure)

Note
  • # of computation: 1

Definition at line 286 of file monolish_crs.hpp.

Here is the caller graph for this function:

◆ get_nnz()

template<typename Float >
size_t monolish::matrix::CRS< Float >::get_nnz ( ) const
inline

get # of non-zeros

Note
  • # of computation: 1
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 261 of file monolish_crs.hpp.

Here is the caller graph for this function:

◆ get_row()

template<typename Float >
size_t monolish::matrix::CRS< Float >::get_row ( ) const
inline

get # of row

Note
  • # of computation: 1
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 243 of file monolish_crs.hpp.

Here is the caller graph for this function:

◆ nonfree_recv()

template<typename T >
template void monolish::matrix::CRS< Float >::nonfree_recv ( )

recv. data to GPU (w/o free)

Note
  • Multi-threading: false
  • GPU acceleration: true
    • # of data transfer: (M+1) + 2nnz

Definition at line 134 of file gpu_comm.cpp.

Here is the call graph for this function:

◆ operator!=()

template<typename Float >
template bool monolish::matrix::CRS< Float >::operator!= ( const CRS< Float > &  mat) const

Comparing matricies (A != mat)

Parameters
matCRS matrix
Returns
true or false
Note
  • # of computation: (M+1)+2nnz
  • Multi-threading: true
  • GPU acceleration: true
    • if gpu_status == true; compare data on GPU
    • else; compare data on CPU

Definition at line 80 of file compare_crs.cpp.

Here is the call graph for this function:

◆ operator=()

template<typename Float >
template void monolish::matrix::CRS< Float >::operator= ( const CRS< Float > &  mat)

matrix copy

Note
  • # of computation: (M+1)+2nnz
  • Multi-threading: true
  • GPU acceleration: true
    • # of data transfer:
      • if gpu_status == true; coping data on GPU
      • else; coping data on CPU

Definition at line 10 of file copy_crs.cpp.

Here is the call graph for this function:

◆ operator==()

template<typename Float >
template bool monolish::matrix::CRS< Float >::operator== ( const CRS< Float > &  mat) const

Comparing matricies (A == mat)

Parameters
matCRS matrix
Returns
true or false
Note
  • # of computation: (M+1)+2nnz
  • Multi-threading: true
  • GPU acceleration: true
    • if gpu_status == true; compare data on GPU
    • else; compare data on CPU

Definition at line 68 of file compare_crs.cpp.

Here is the call graph for this function:

◆ print_all()

template<typename T >
template void monolish::matrix::CRS< Float >::print_all ( bool  force_cpu = false) const

print all elements to standard I/O

Parameters
force_cpuIgnore device status and output CPU data
Note
  • # of computation: nnz
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 17 of file IO_crs.cpp.

Here is the call graph for this function:

◆ recv()

template<typename T >
template void monolish::matrix::CRS< Float >::recv ( )

recv. data to GPU, and free data on GPU

Note
  • Multi-threading: false
  • GPU acceleration: true
    • # of data transfer: (M+1) + 2nnz

Definition at line 113 of file gpu_comm.cpp.

Here is the call graph for this function:

◆ row() [1/3]

template<typename Float >
void monolish::matrix::CRS< Float >::row ( const size_t  r,
vector< Float > &  vec 
) const

get row vector

Parameters
rrow number
vecrow vector
Note
  • # of computation: about nnz / M
  • Multi-threading: true
  • GPU acceleration: true

◆ row() [2/3]

template<typename Float >
void monolish::matrix::CRS< Float >::row ( const size_t  r,
view1D< matrix::Dense< Float >, Float > &  vec 
) const

◆ row() [3/3]

template<typename Float >
void monolish::matrix::CRS< Float >::row ( const size_t  r,
view1D< vector< Float >, Float > &  vec 
) const

◆ send()

template<typename T >
template void monolish::matrix::CRS< Float >::send ( ) const

send data to GPU

Note
  • Multi-threading: false
  • GPU acceleration: true
    • # of data transfer: (M+1) + 2nnz

Definition at line 89 of file gpu_comm.cpp.

Here is the call graph for this function:

◆ set_ptr()

template<typename Float >
template void monolish::matrix::CRS< Float >::set_ptr ( const size_t  M,
const size_t  N,
const std::vector< int > &  rowptr,
const std::vector< int > &  colind,
const std::vector< Float > &  value 
)

Set CRS array from std::vector.

Parameters
M# of row
N# of col
rowptrrow_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1)
colindcol_ind, which stores the column numbers of the non-zero elements (size nnz)
valuevalue index, which stores the non-zero elements (size nnz)
Note
  • # of computation: 3
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 41 of file copy_crs.cpp.

Here is the call graph for this function:

◆ type()

template<typename Float >
std::string monolish::matrix::CRS< Float >::type ( ) const
inline

get format name "CRS"

Note
  • # of computation: 1
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 270 of file monolish_crs.hpp.

Member Data Documentation

◆ col_ind

template<typename Float >
std::vector<int> monolish::matrix::CRS< Float >::col_ind

CRS format column index, which stores column numbers of the non-zero elements (size nnz)

Definition at line 74 of file monolish_crs.hpp.

◆ colN

template<typename Float >
size_t monolish::matrix::CRS< Float >::colN
private

# of col

Definition at line 46 of file monolish_crs.hpp.

◆ gpu_status

template<typename Float >
bool monolish::matrix::CRS< Float >::gpu_status = false
mutableprivate

true: sended, false: not send

Definition at line 56 of file monolish_crs.hpp.

◆ nnz

template<typename Float >
size_t monolish::matrix::CRS< Float >::nnz
private

# of non-zero element

Definition at line 51 of file monolish_crs.hpp.

◆ row_ptr

template<typename Float >
std::vector<int> monolish::matrix::CRS< Float >::row_ptr

CRS format row pointer, which stores the starting points of the rows of the arrays value and col_ind (size M+1)

Definition at line 80 of file monolish_crs.hpp.

◆ rowN

template<typename Float >
size_t monolish::matrix::CRS< Float >::rowN
private

# of row

Definition at line 41 of file monolish_crs.hpp.

◆ structure_hash

template<typename Float >
size_t monolish::matrix::CRS< Float >::structure_hash
private

hash, created from row_ptr and col_ind

Definition at line 61 of file monolish_crs.hpp.

◆ val

template<typename Float >
std::vector<Float> monolish::matrix::CRS< Float >::val

CRS format value, which stores values of the non-zero elements (size nnz)

Definition at line 68 of file monolish_crs.hpp.


The documentation for this class was generated from the following files: