SparseLibrary  Version 1.6.0
Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value > Class Template Reference

Compressed Bi-directional Incremental Compressed Row Storage (BICRS) scheme. More...

#include <CBICRS.hpp>

Inheritance diagram for CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >:
Inheritance graph
[legend]
Collaboration diagram for CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >:
Collaboration graph
[legend]

Public Member Functions

virtual ~CBICRS ()
 Base deconstructor. More...
 
 CBICRS ()
 Base constructor. More...
 
 CBICRS (std::string file, _t_value zero=0)
 Base constructor. More...
 
 CBICRS (ULI *row, ULI *col, _t_value *val, ULI m, ULI n, ULI nz, _t_value zero)
 Base constructor. More...
 
 CBICRS (std::vector< Triplet< _t_value > > &input, ULI m, ULI n, _t_value zero=0)
 Base constructor. More...
 
virtual void load (std::vector< Triplet< _t_value > > &input, ULI m, ULI n, _t_value zero)
 This function will rewrite the std::vector< Triplet > structure to one suitable for the other load function. More...
 
void load (ULI *row, ULI *col, _t_value *val, ULI m, ULI n, ULI nz, _t_value zero)
 
virtual void getFirstIndexPair (ULI &row, ULI &col)
 Returns the first nonzero index, per reference. More...
 
virtual void zxa (const _t_value *__restrict__ x_p, _t_value *__restrict__ y_p)
 Calculates y=xA, but does not allocate y itself. More...
 
virtual void zax (const _t_value *__restrict__ x_p, _t_value *__restrict__ y_p)
 Calculates y=Ax, but does not allocate y itself. More...
 
virtual size_t bytesUsed ()
 Function to query the amount of storage required by this sparse matrix. More...
 
- Public Member Functions inherited from SparseMatrix< _t_value, ULI >
 SparseMatrix ()
 Base constructor. More...
 
 SparseMatrix (const ULInzs, const ULInr, const ULInc, const _t_valuezero)
 Base constructor. More...
 
virtual ~SparseMatrix ()
 Base deconstructor. More...
 
void loadFromFile (const std::string file, const _t_valuezero=0)
 Function which loads a matrix from a matrix market file. More...
 
virtual unsigned long int m ()
 Queries the number of rows this matrix contains. More...
 
virtual unsigned long int n ()
 Queries the number of columns this matrix contains. More...
 
virtual unsigned long int nzs ()
 Queries the number of nonzeroes stored in this matrix. More...
 
virtual _t_value * mv (const _t_value *x)
 Calculates and returns z=Ax. More...
 
- Public Member Functions inherited from Matrix< _t_value >
 Matrix ()
 Base constructor. More...
 
virtual ~Matrix ()
 Base deconstructor. More...
 
virtual void zax (const _t_value *__restrict__ x, _t_value *__restrict__ z, const size_t k, const clockid_t clock_id=0, double *elapsed_time=NULL)
 Wrapper function to call the zax kernel multiple times successively, while timing the duration of the operation. More...
 
void ZaX (const _t_value *__restrict__ const *__restrict__ const X, _t_value *__restrict__ const *__restrict__ const Z)
 In-place Z=AX function, where A is m x n, Z = m x k, and X is n x k. More...
 
virtual void zxa (const _t_value *__restrict__ x, _t_value *__restrict__ z, const unsigned long int repeat, const clockid_t clock_id=0, double *elapsed_time=NULL)
 Wrapper function to call the zxa kernel multiple times successively, while timing the operation duration. More...
 
void ZXa (const _t_value *__restrict__ const *__restrict__ const X, _t_value *__restrict__ const *__restrict__ const Z)
 In-place Z=XA function, where A is m x n, Z = k x n, and X is k x m. More...
 

Static Public Member Functions

static unsigned long int getMemoryUsage (ULI *row, ULI *col, const ULI nz, const ULI m, const ULI n)
 Calculates and returns the number of bytes used when employing this data structure. More...
 
static unsigned long int getMemoryUsage (std::vector< Triplet< _t_value > > &input, const ULI m, const ULI n)
 Calculates and returns the number of bytes used when employing this data structure. More...
 

Static Protected Member Functions

static void getNumberOfOverflows (const ULI nnz, ULI *const row, ULI *const col, const ULI ntt, ULI &row_overflows, ULI &col_overflows, ULI &sim_overflows, ULI &jumps)
 Calculates the number of overflows given a triplet-form input. More...
 
static unsigned long int memoryUsage (const ULI nnz, const ULI jumps, const ULI row_o, const ULI col_o, const ULI sim_o)
 Estimates the number of bytes required by this data structure. More...
 

Protected Attributes

_master_i_value * r_start
 Stores the row chunk start increments; size is the number of nonzeros plus one. More...
 
_master_i_value * c_start
 Stores the column chunk start increments; size is the number of nonzeros plus one. More...
 
_i_value * r_inc
 Stores the row jumps; size is the number of nonzeros plus 2. More...
 
_i_value * c_inc
 Stores the column jumps; size is exactly the number of nonzeros. More...
 
unsigned char * mask1
 Bitmask used for switching between c_start and c_ind. More...
 
unsigned char * mask2
 Bitmask used for switching between r_start and r_ind. More...
 
_t_value * vals
 Stores the values of the individual nonzeros. More...
 
size_t bytes
 Stores the number of bytes used for storage. More...
 
_master_j_value ntt
 Caches n times two. More...
 
- Protected Attributes inherited from SparseMatrix< _t_value, ULI >
ULI nor
 Number of rows. More...
 
ULI noc
 Number of columns.
 
ULI nnz
 Number of non-zeros. More...
 

Additional Inherited Members

- Public Attributes inherited from SparseMatrix< _t_value, ULI >
_t_value zero_element
 The element considered to be zero. More...
 

Detailed Description

template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
class CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >

Compressed Bi-directional Incremental Compressed Row Storage (BICRS) scheme.

Compression is done by using less large data types for storing increments; e.g., 8-bit signed chars instead of 64-bit signed long ints. The exact data type used are input parameters.

Refer to CBICRS_factory for an auto-tuned selection.

Parameters
_t_valueThe type of the nonzeros in the matrix.

Warning: this class uses assertions! For optimal performance, define the NDEBUG flag (e.g., pass -DNDEBUG as a compiler flag).

Constructor & Destructor Documentation

template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
virtual CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::~CBICRS ( )
inlinevirtual
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::CBICRS ( )
inline
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::CBICRS ( std::string  file,
_t_value  zero = 0 
)
inline

Base constructor.

Will read in from Matrix Market file.

See also
SparseMatrix::SparseMatrix( file, zero )

References SparseMatrix< _t_value, ULI >::loadFromFile().

template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::CBICRS ( ULI *  row,
ULI *  col,
_t_value *  val,
ULI  m,
ULI  n,
ULI  nz,
_t_value  zero 
)
inline

Base constructor.

Stores triplets in exactly the same order as passed to this constructor.

Parameters
rowThe row numbers of the individual nonzeros.
colThe column numbers of the individual nonzeros.
valThe values of the nonzeros.
mNumber of matrix rows.
nNumber of matrix columns.
nzNumber of nonzeros.
zeroWhich value is to be regarded zero here.

References CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::load().

template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::CBICRS ( std::vector< Triplet< _t_value > > &  input,
ULI  m,
ULI  n,
_t_value  zero = 0 
)
inline

Base constructor.

See also
SparseMatrix::SparseMatrix( input, m, n, zero )

References CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::load().

Member Function Documentation

template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
virtual size_t CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::bytesUsed ( )
inlinevirtual

Function to query the amount of storage required by this sparse matrix.

Returns
The size of the sparse matrix in bytes.

Implements Matrix< _t_value >.

References CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::bytes.

template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
virtual void CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::getFirstIndexPair ( ULI &  row,
ULI &  col 
)
inlinevirtual
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
static unsigned long int CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::getMemoryUsage ( ULI *  row,
ULI *  col,
const ULI  nz,
const ULI  m,
const ULI  n 
)
inlinestatic
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
static unsigned long int CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::getMemoryUsage ( std::vector< Triplet< _t_value > > &  input,
const ULI  m,
const ULI  n 
)
inlinestatic

Calculates and returns the number of bytes used when employing this data structure.

References CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::getMemoryUsage().

template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
static void CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::getNumberOfOverflows ( const ULI  nnz,
ULI *const  row,
ULI *const  col,
const ULI  ntt,
ULI &  row_overflows,
ULI &  col_overflows,
ULI &  sim_overflows,
ULI &  jumps 
)
inlinestaticprotected

Calculates the number of overflows given a triplet-form input.

Parameters
nnzThe number of nonzeroes in the COO input.
rowThe COO row indices array.
colThe COO column indices array.
nttShould equal the number of columns times two (n times two)
row_overflowsWhere to store the number of row overflows.
col_overflowsWhere to store the number of column overflows.
sim_overflowsWhere to store the number of simultaneous row and column overflows.
jumpsWhere to store the number of row jumps;

References SparseMatrix< _t_value, ULI >::nnz.

Referenced by CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::getMemoryUsage(), and CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::load().

template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
virtual void CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::load ( std::vector< Triplet< _t_value > > &  input,
ULI  m,
ULI  n,
_t_value  zero 
)
inlinevirtual

This function will rewrite the std::vector< Triplet > structure to one suitable for the other load function.

See also
load( row, col, val, m, n, nz )
SparseMatrix::load

Implements SparseMatrix< _t_value, ULI >.

Referenced by CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::CBICRS().

template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
void CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::load ( ULI *  row,
ULI *  col,
_t_value *  val,
ULI  m,
ULI  n,
ULI  nz,
_t_value  zero 
)
inline
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
static unsigned long int CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::memoryUsage ( const ULI  nnz,
const ULI  jumps,
const ULI  row_o,
const ULI  col_o,
const ULI  sim_o 
)
inlinestaticprotected
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
virtual void CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::zax ( const _t_value *__restrict__  x_p,
_t_value *__restrict__  y_p 
)
inlinevirtual
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
virtual void CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::zxa ( const _t_value *__restrict__  x_p,
_t_value *__restrict__  y_p 
)
inlinevirtual

Member Data Documentation

template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
size_t CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::bytes
protected
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
_i_value* CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::c_inc
protected
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
_master_i_value* CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::c_start
protected
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
unsigned char* CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::mask1
protected
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
unsigned char* CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::mask2
protected
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
_master_j_value CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::ntt
protected
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
_i_value* CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::r_inc
protected
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
_master_i_value* CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::r_start
protected
template<typename _t_value, typename _master_i_value = signed long int, typename _master_j_value = signed long int, typename _i_value = LI, typename _j_value = LI>
_t_value* CBICRS< _t_value, _master_i_value, _master_j_value, _i_value, _j_value >::vals
protected

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