monolish  0.17.3-dev.23
MONOlithic LInear equation Solvers for Highly-parallel architecture
Public Member Functions | Public Attributes | Private Attributes | List of all members
monolish::tensor::tensor_CRS< Float > Class Template Reference

#include <monolish_tensor_crs.hpp>

Collaboration diagram for monolish::tensor::tensor_CRS< Float >:
Collaboration graph

Public Member Functions

Float * begin ()
 returns a begin iterator More...
 
const Float * begin () const
 returns a begin iterator More...
 
void compute_hash ()
 compute index array hash (to compare structure) More...
 
void convert (const matrix::CRS< Float > &crs)
 
void convert (const tensor::tensor_COO< Float > &coo)
 
void convert (const tensor::tensor_CRS< Float > &crs)
 
Float * data ()
 returns a direct pointer to the tensor More...
 
const Float * data () const
 returns a direct pointer to the tensor More...
 
void device_free () const
 free data on GPU More...
 
Float * end ()
 returns a end iterator More...
 
const Float * end () const
 returns a end iterator More...
 
bool equal (const tensor_CRS< Float > &mat, bool compare_cpu_and_device=false) const
 Comparing matrices (A == mat) More...
 
void fill (Float value)
 fill tensor elements with a scalar value More...
 
size_t get_alloc_nnz () const
 get # of alloced non-zeros More...
 
double get_data_size () const
 Memory data space required by the matrix. More...
 
bool get_device_mem_stat () const
 true: sended, false: not send More...
 
size_t get_first () const
 get first position More...
 
std::shared_ptr< bool > get_gpu_status () const
 gpu status shared pointer 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_offset () const
 get first position (same as get_first()) More...
 
std::vector< size_t > get_shape () const
 get shape More...
 
std::shared_ptr< Float > get_val ()
 get shared_ptr of val More...
 
const std::shared_ptr< Float > get_val () const
 get shared_ptr of val More...
 
void nonfree_recv ()
 recv. data to GPU (w/o free) More...
 
bool operator!= (const tensor_CRS< Float > &mat) const
 Comparing matrices (A != mat) More...
 
void operator= (const tensor_CRS< Float > &mat)
 matrix copy More...
 
bool operator== (const tensor_CRS< Float > &mat) const
 Comparing matrices (A == mat) More...
 
Float & operator[] (size_t i)
 reference to the element at position (v[i]) More...
 
void print_all (bool force_cpu=false) const
 
void recv ()
 recv. data to GPU, and free data on GPU More...
 
void resize (const size_t N, Float Val=0)
 resize tensor value More...
 
void send () const
 send data to GPU More...
 
void set_first (size_t i)
 change first position More...
 
void set_ptr (const std::vector< size_t > &shape, const std::vector< std::vector< int >> &rowptrs, const std::vector< std::vector< int >> &colinds, const size_t vsize, const Float *value)
 
void set_ptr (const std::vector< size_t > &shape, const std::vector< std::vector< int >> &rowptrs, const std::vector< std::vector< int >> &colinds, const size_t vsize, const Float value)
 
void set_ptr (const std::vector< size_t > &shape, const std::vector< std::vector< int >> &rowptrs, const std::vector< std::vector< int >> &colinds, const std::vector< Float > &value)
 
void set_shape (const std::vector< size_t > &shape)
 Set shape. More...
 
 tensor_CRS ()
 
 tensor_CRS (const matrix::CRS< Float > &crs)
 
 tensor_CRS (const std::initializer_list< size_t > &shape_)
 
 tensor_CRS (const std::vector< size_t > &shape_)
 
 tensor_CRS (const std::vector< size_t > &shape_, const std::vector< std::vector< int >> &row_ptrs_, const std::vector< std::vector< int >> &col_inds_, const Float *value)
 
 tensor_CRS (const tensor::tensor_COO< Float > &coo)
 
 tensor_CRS (const tensor::tensor_CRS< Float > &crs)
 
 tensor_CRS (const tensor_CRS< Float > &crs, Float value)
 
std::string type () const
 get format name "tensor_CRS" More...
 
 ~tensor_CRS ()
 

Public Attributes

size_t alloc_nnz = 0
 
std::vector< std::vector< int > > col_inds
 
std::vector< std::vector< int > > row_ptrs
 
std::shared_ptr< Float > val
 
bool val_create_flag = false
 
size_t val_nnz = 0
 

Private Attributes

size_t first = 0
 
std::shared_ptr< bool > gpu_status = std::make_shared<bool>(false)
 
std::vector< size_t > shape
 
size_t structure_hash
 

Detailed Description

template<typename Float>
class monolish::tensor::tensor_CRS< Float >

Definition at line 12 of file monolish_tensor_crs.hpp.

Constructor & Destructor Documentation

◆ tensor_CRS() [1/8]

template<typename Float >
monolish::tensor::tensor_CRS< Float >::tensor_CRS ( )
inline

Definition at line 35 of file monolish_tensor_crs.hpp.

◆ tensor_CRS() [2/8]

template<typename Float >
monolish::tensor::tensor_CRS< Float >::tensor_CRS ( const std::vector< size_t > &  shape_)
inline

Definition at line 39 of file monolish_tensor_crs.hpp.

◆ tensor_CRS() [3/8]

template<typename Float >
monolish::tensor::tensor_CRS< Float >::tensor_CRS ( const std::initializer_list< size_t > &  shape_)
inline

Definition at line 44 of file monolish_tensor_crs.hpp.

◆ tensor_CRS() [4/8]

template<typename Float >
monolish::tensor::tensor_CRS< Float >::tensor_CRS ( const tensor::tensor_COO< Float > &  coo)
inline

Definition at line 51 of file monolish_tensor_crs.hpp.

Here is the call graph for this function:

◆ tensor_CRS() [5/8]

template<typename Float >
monolish::tensor::tensor_CRS< Float >::tensor_CRS ( const tensor::tensor_CRS< Float > &  crs)
inline

Definition at line 58 of file monolish_tensor_crs.hpp.

Here is the call graph for this function:

◆ tensor_CRS() [6/8]

template<typename Float >
monolish::tensor::tensor_CRS< Float >::tensor_CRS ( const matrix::CRS< Float > &  crs)
inline

Definition at line 65 of file monolish_tensor_crs.hpp.

Here is the call graph for this function:

◆ tensor_CRS() [7/8]

template<typename Float >
monolish::tensor::tensor_CRS< Float >::tensor_CRS ( const std::vector< size_t > &  shape_,
const std::vector< std::vector< int >> &  row_ptrs_,
const std::vector< std::vector< int >> &  col_inds_,
const Float *  value 
)

◆ tensor_CRS() [8/8]

template<typename Float >
monolish::tensor::tensor_CRS< Float >::tensor_CRS ( const tensor_CRS< Float > &  crs,
Float  value 
)

◆ ~tensor_CRS()

template<typename Float >
monolish::tensor::tensor_CRS< Float >::~tensor_CRS ( )
inline

Definition at line 235 of file monolish_tensor_crs.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ begin() [1/2]

template<typename Float >
Float* monolish::tensor::tensor_CRS< Float >::begin ( )
inline

returns a begin iterator

Returns
begin iterator
Note
  • # of computation: 1

Definition at line 335 of file monolish_tensor_crs.hpp.

Here is the call graph for this function:

◆ begin() [2/2]

template<typename Float >
const Float* monolish::tensor::tensor_CRS< Float >::begin ( ) const
inline

returns a begin iterator

Returns
begin iterator
Note
  • # of computation: 1

Definition at line 327 of file monolish_tensor_crs.hpp.

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

◆ compute_hash()

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::compute_hash ( )

compute index array hash (to compare structure)

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

◆ convert() [1/3]

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

◆ convert() [2/3]

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::convert ( const tensor::tensor_COO< Float > &  coo)
Here is the caller graph for this function:

◆ convert() [3/3]

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::convert ( const tensor::tensor_CRS< Float > &  crs)

◆ data() [1/2]

template<typename Float >
Float* monolish::tensor::tensor_CRS< Float >::data ( )
inline

returns a direct pointer to the tensor

Returns
A pointer to the first element
Note
  • # of computation: 1

Definition at line 257 of file monolish_tensor_crs.hpp.

◆ data() [2/2]

template<typename Float >
const Float* monolish::tensor::tensor_CRS< Float >::data ( ) const
inline

returns a direct pointer to the tensor

Returns
A const pointer to the first element
Note
  • # of computation: 1

Definition at line 249 of file monolish_tensor_crs.hpp.

Here is the caller graph for this function:

◆ device_free()

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::device_free ( ) const

free data on GPU

Note
  • Multi-threading: false
  • GPU acceleration: true
    • # of data transfer: 0
Here is the caller graph for this function:

◆ end() [1/2]

template<typename Float >
Float* monolish::tensor::tensor_CRS< Float >::end ( )
inline

returns a end iterator

Returns
end iterator
Note
  • # of computation: 1

Definition at line 353 of file monolish_tensor_crs.hpp.

Here is the call graph for this function:

◆ end() [2/2]

template<typename Float >
const Float* monolish::tensor::tensor_CRS< Float >::end ( ) const
inline

returns a end iterator

Returns
end iterator
Note
  • # of computation: 1

Definition at line 343 of file monolish_tensor_crs.hpp.

Here is the call graph for this function:

◆ equal()

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

Comparing matrices (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

◆ fill()

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::fill ( Float  value)

fill tensor elements with a scalar value

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

◆ get_alloc_nnz()

template<typename Float >
size_t monolish::tensor::tensor_CRS< Float >::get_alloc_nnz ( ) const
inline

get # of alloced non-zeros

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

Definition at line 187 of file monolish_tensor_crs.hpp.

◆ get_data_size()

template<typename Float >
double monolish::tensor::tensor_CRS< Float >::get_data_size ( ) const
inline

Memory data space required by the matrix.

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

Definition at line 125 of file monolish_tensor_crs.hpp.

Here is the call graph for this function:

◆ get_device_mem_stat()

template<typename Float >
bool monolish::tensor::tensor_CRS< Float >::get_device_mem_stat ( ) const
inline

true: sended, false: not send

Returns
gpu status

Definition at line 225 of file monolish_tensor_crs.hpp.

Here is the caller graph for this function:

◆ get_first()

template<typename Float >
size_t monolish::tensor::tensor_CRS< Float >::get_first ( ) const
inline

get first position

Returns
first position
Note
  • # of computation: 1

Definition at line 195 of file monolish_tensor_crs.hpp.

Here is the caller graph for this function:

◆ get_gpu_status()

template<typename Float >
std::shared_ptr<bool> monolish::tensor::tensor_CRS< Float >::get_gpu_status ( ) const
inline

gpu status shared pointer

Returns
gpu status shared pointer

Definition at line 231 of file monolish_tensor_crs.hpp.

◆ get_hash()

template<typename Float >
size_t monolish::tensor::tensor_CRS< Float >::get_hash ( ) const
inline

get index array hash (to compare structure)

Note
  • # of computation: 1

Definition at line 319 of file monolish_tensor_crs.hpp.

◆ get_nnz()

template<typename Float >
size_t monolish::tensor::tensor_CRS< Float >::get_nnz ( ) const
inline

get # of non-zeros

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

Definition at line 178 of file monolish_tensor_crs.hpp.

Here is the caller graph for this function:

◆ get_offset()

template<typename Float >
size_t monolish::tensor::tensor_CRS< Float >::get_offset ( ) const
inline

get first position (same as get_first())

Returns
first position
Note
  • # of computation: 1

Definition at line 203 of file monolish_tensor_crs.hpp.

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

◆ get_shape()

template<typename Float >
std::vector<size_t> monolish::tensor::tensor_CRS< Float >::get_shape ( ) const
inline

get shape

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

Definition at line 151 of file monolish_tensor_crs.hpp.

◆ get_val() [1/2]

template<typename Float >
std::shared_ptr<Float> monolish::tensor::tensor_CRS< Float >::get_val ( )
inline

get shared_ptr of val

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

Definition at line 160 of file monolish_tensor_crs.hpp.

◆ get_val() [2/2]

template<typename Float >
const std::shared_ptr<Float> monolish::tensor::tensor_CRS< Float >::get_val ( ) const
inline

get shared_ptr of val

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

Definition at line 169 of file monolish_tensor_crs.hpp.

◆ nonfree_recv()

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::nonfree_recv ( )

recv. data to GPU (w/o free)

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

◆ operator!=()

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

Comparing matrices (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

◆ operator=()

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::operator= ( const tensor_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

◆ operator==()

template<typename Float >
bool monolish::tensor::tensor_CRS< Float >::operator== ( const tensor_CRS< Float > &  mat) const

Comparing matrices (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

◆ operator[]()

template<typename Float >
Float& monolish::tensor::tensor_CRS< Float >::operator[] ( size_t  i)
inline

reference to the element at position (v[i])

Parameters
iPosition of an element in the vector
Returns
vector element (v[i])
Note
  • # of computation: 1
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 386 of file monolish_tensor_crs.hpp.

Here is the call graph for this function:

◆ print_all()

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::print_all ( bool  force_cpu = false) const

◆ recv()

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::recv ( )

recv. data to GPU, and free data on GPU

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

◆ resize()

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::resize ( const size_t  N,
Float  Val = 0 
)
inline

resize tensor value

Parameters
Ntensor size
Note
  • # of computation: N
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 267 of file monolish_tensor_crs.hpp.

Here is the call graph for this function:

◆ send()

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::send ( ) const

send data to GPU

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

◆ set_first()

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::set_first ( size_t  i)
inline

change first position

Note
  • # of computation: 1

Definition at line 210 of file monolish_tensor_crs.hpp.

◆ set_ptr() [1/3]

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::set_ptr ( const std::vector< size_t > &  shape,
const std::vector< std::vector< int >> &  rowptrs,
const std::vector< std::vector< int >> &  colinds,
const size_t  vsize,
const Float *  value 
)

◆ set_ptr() [2/3]

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::set_ptr ( const std::vector< size_t > &  shape,
const std::vector< std::vector< int >> &  rowptrs,
const std::vector< std::vector< int >> &  colinds,
const size_t  vsize,
const Float  value 
)

◆ set_ptr() [3/3]

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::set_ptr ( const std::vector< size_t > &  shape,
const std::vector< std::vector< int >> &  rowptrs,
const std::vector< std::vector< int >> &  colinds,
const std::vector< Float > &  value 
)

◆ set_shape()

template<typename Float >
void monolish::tensor::tensor_CRS< Float >::set_shape ( const std::vector< size_t > &  shape)
inline

Set shape.

Parameters
shapeshape of tensor
  • # of computation: 1
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 219 of file monolish_tensor_crs.hpp.

◆ type()

template<typename Float >
std::string monolish::tensor::tensor_CRS< Float >::type ( ) const
inline

get format name "tensor_CRS"

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

Definition at line 303 of file monolish_tensor_crs.hpp.

Member Data Documentation

◆ alloc_nnz

template<typename Float >
size_t monolish::tensor::tensor_CRS< Float >::alloc_nnz = 0

Definition at line 27 of file monolish_tensor_crs.hpp.

◆ col_inds

template<typename Float >
std::vector<std::vector<int> > monolish::tensor::tensor_CRS< Float >::col_inds

Definition at line 33 of file monolish_tensor_crs.hpp.

◆ first

template<typename Float >
size_t monolish::tensor::tensor_CRS< Float >::first = 0
private

Definition at line 20 of file monolish_tensor_crs.hpp.

◆ gpu_status

template<typename Float >
std::shared_ptr<bool> monolish::tensor::tensor_CRS< Float >::gpu_status = std::make_shared<bool>(false)
mutableprivate

Definition at line 16 of file monolish_tensor_crs.hpp.

◆ row_ptrs

template<typename Float >
std::vector<std::vector<int> > monolish::tensor::tensor_CRS< Float >::row_ptrs

Definition at line 31 of file monolish_tensor_crs.hpp.

◆ shape

template<typename Float >
std::vector<size_t> monolish::tensor::tensor_CRS< Float >::shape
private

Definition at line 14 of file monolish_tensor_crs.hpp.

◆ structure_hash

template<typename Float >
size_t monolish::tensor::tensor_CRS< Float >::structure_hash
private

Definition at line 18 of file monolish_tensor_crs.hpp.

◆ val

template<typename Float >
std::shared_ptr<Float> monolish::tensor::tensor_CRS< Float >::val

Definition at line 23 of file monolish_tensor_crs.hpp.

◆ val_create_flag

template<typename Float >
bool monolish::tensor::tensor_CRS< Float >::val_create_flag = false

Definition at line 29 of file monolish_tensor_crs.hpp.

◆ val_nnz

template<typename Float >
size_t monolish::tensor::tensor_CRS< Float >::val_nnz = 0

Definition at line 25 of file monolish_tensor_crs.hpp.


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