SparseLibrary
Version 1.6.0
|
The compressed row storage sparse matrix data structure. More...
#include <MKLCRS.hpp>
Public Member Functions | |
MKLCRS () | |
Base constructor. More... | |
MKLCRS (std::string file, T zero=0) | |
Base constructor. More... | |
MKLCRS (const ULI number_of_nonzeros, const ULI number_of_rows, const ULI number_of_cols, T zero) | |
Base constructor which only initialises the internal arrays. More... | |
MKLCRS (CRS< T > &toCopy) | |
Copy constructor. More... | |
MKLCRS (std::vector< Triplet< T > > input, ULI m, ULI n, T zero) | |
Constructor which transforms a collection of input triplets to CRS format. More... | |
virtual T * | mv (const T *x) |
Overloaded mv call; allocates output vector using numa_interleaved. More... | |
virtual void | zxa (const T *__restrict__ x, T *__restrict__ z) |
In-place z=xA function. | |
virtual void | zax (const T *__restrict__ x, T *__restrict__ z) |
In-place z=Ax function. More... | |
virtual | ~MKLCRS () |
Base deconstructor. More... | |
Public Member Functions inherited from CRS< T > | |
CRS () | |
Base constructor. More... | |
CRS (std::string file, T zero=0) | |
Base constructor. More... | |
CRS (const ULI number_of_nonzeros, const ULI number_of_rows, const ULI number_of_cols, T zero) | |
Base constructor which only initialises the internal arrays. More... | |
CRS (CRS< T > &toCopy) | |
Copy constructor. More... | |
CRS (std::vector< Triplet< T > > input, ULI m, ULI n, T zero) | |
Constructor which transforms a collection of input triplets to CRS format. More... | |
virtual void | load (std::vector< Triplet< T > > &input, ULI m, ULI n, T zero) |
T & | random_access (ULI i, ULI j) |
Method which provides random matrix access to the stored sparse matrix. More... | |
virtual void | getFirstIndexPair (ULI &row, ULI &col) |
Returns the first nonzero index, per reference. More... | |
template<size_t k> | |
void | ZaX (const T *__restrict__ const *__restrict__ const X, T *__restrict__ const *__restrict__ const Z) |
template<size_t k> | |
void | ZXa (const T *__restrict__ const *__restrict__ const X, T *__restrict__ const *__restrict__ const Z) |
ULI * | rowJump () |
Returns pointer to the row_start vector. More... | |
ULI * | columnIndices () |
Returns pointer to the column index vector. More... | |
T * | values () |
Returns pointer to the matrix nonzeros vector. More... | |
virtual | ~CRS () |
Base deconstructor. More... | |
virtual size_t | bytesUsed () |
Public Member Functions inherited from SparseMatrix< T, ULI > | |
SparseMatrix () | |
Base constructor. More... | |
SparseMatrix (const ULInzs, const ULInr, const ULInc, const T zero) | |
Base constructor. More... | |
virtual | ~SparseMatrix () |
Base deconstructor. More... | |
void | loadFromFile (const std::string file, const T zero=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... | |
Public Member Functions inherited from Matrix< T > | |
Matrix () | |
Base constructor. More... | |
virtual | ~Matrix () |
Base deconstructor. More... | |
virtual void | zax (const T *__restrict__ x, T *__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... | |
template<size_t k> | |
void | ZaX (const T *__restrict__ const *__restrict__ const X, T *__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... | |
template<size_t k> | |
void | ZXa (const T *__restrict__ const *__restrict__ const X, T *__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... | |
virtual void | zxa (const T *__restrict__ x, T *__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... | |
Protected Member Functions | |
void | prepare () |
Does the required post-processing of Sparse Library's CRS representation to one compatible with Intel MKL. | |
Protected Member Functions inherited from CRS< T > | |
bool | find (const ULI col_index, const ULI search_start, const ULI search_end, ULI &ret) |
Helper function which finds a value with a given column index on a given subrange of indices. More... | |
Protected Attributes | |
double | _one |
Required for call to MKL; a factor alpha=beta of 1. More... | |
char | trans |
Required for call to MKL; (no) transposition. More... | |
char * | descr |
Required for call to MKL; matrix descriptor. More... | |
int | _m |
Required for call to MKL; matrix row-size. More... | |
int | _n |
Required for call to MKL; matrix column-size. More... | |
int * | _col_ind |
Required for call to MKL; a plain-int version of col_ind. More... | |
int * | _row_start |
Required for call to MKL; a plain-int version of row_start. More... | |
Protected Attributes inherited from CRS< T > | |
ULI * | row_start |
Array keeping track of individual row starting indices. More... | |
T * | ds |
Array containing the actual nnz non-zeros. More... | |
ULI * | col_ind |
Array containing the column indeces corresponding to the elements in ds. More... | |
Protected Attributes inherited from SparseMatrix< T, 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, ULI > | |
T | zero_element |
The element considered to be zero. More... | |
Static Protected Member Functions inherited from CRS< T > | |
static int | compareTriplets (const void *left, const void *right) |
Sorts 1D columnwise. | |
The compressed row storage sparse matrix data structure.
Base constructor.
Will read in from Matrix Market file.
References SparseMatrix< T, ULI >::loadFromFile(), and MKLCRS< T >::prepare().
|
inline |
Base constructor which only initialises the internal arrays.
Note that to gain a valid CRS structure, these arrays have to be filled by some external mechanism (i.e., after calling this constructor, the internal arrays contain garbage, resuling in invalid datastructure).
number_of_nonzeros | The number of non-zeros to be stored. |
number_of_rows | The number of rows to be stored. |
number_of_cols | The number of columns of the matrix. |
zero | The element considered to be zero. |
References CRS< T >::col_ind, CRS< T >::ds, SparseMatrix< T, ULI >::nnz, SparseMatrix< T, ULI >::noc, SparseMatrix< T, ULI >::nor, MKLCRS< T >::prepare(), CRS< T >::row_start, and SparseMatrix< T, ULI >::zero_element.
Copy constructor.
toCopy | reference to the CRS datastructure to copy. |
References CRS< T >::col_ind, CRS< T >::ds, SparseMatrix< T, ULI >::nnz, SparseMatrix< T, ULI >::nor, MKLCRS< T >::prepare(), CRS< T >::row_start, and SparseMatrix< T, ULI >::zero_element.
|
inline |
Constructor which transforms a collection of input triplets to CRS format.
The input collection is considered to have at most one triplet with unique pairs of indeces. Unspecified behaviour occurs when this assumption is not met.
input | The input collection. |
m | Total number of rows. |
n | Total number of columns. |
zero | The element considered to be zero. |
References CRS< T >::load(), and MKLCRS< T >::prepare().
Base deconstructor.
References MKLCRS< T >::_col_ind, MKLCRS< T >::_row_start, and MKLCRS< T >::descr.
|
inlinevirtual |
Overloaded mv call; allocates output vector using numa_interleaved.
Reimplemented from SparseMatrix< T, ULI >.
References SparseMatrix< T, ULI >::nor, MKLCRS< T >::zax(), and SparseMatrix< T, ULI >::zero_element.
|
inlinevirtual |
In-place z=Ax function.
x | The x vector to multiply current matrix with. |
z | The result vector. Must be pre-allocated and its elements should be initialised to zero. |
Reimplemented from CRS< T >.
References MKLCRS< T >::_col_ind, MKLCRS< T >::_m, MKLCRS< T >::_n, MKLCRS< T >::_one, MKLCRS< T >::_row_start, MKLCRS< T >::descr, CRS< T >::ds, and MKLCRS< T >::trans.
Referenced by MKLCRS< T >::mv().
|
protected |
Required for call to MKL; a plain-int version of col_ind.
Referenced by MKLCRS< T >::prepare(), MKLCRS< T >::zax(), and MKLCRS< T >::~MKLCRS().
|
protected |
Required for call to MKL; matrix row-size.
Referenced by MKLCRS< T >::prepare(), and MKLCRS< T >::zax().
|
protected |
Required for call to MKL; matrix column-size.
Referenced by MKLCRS< T >::prepare(), and MKLCRS< T >::zax().
|
protected |
Required for call to MKL; a factor alpha=beta of 1.
Referenced by MKLCRS< T >::prepare(), and MKLCRS< T >::zax().
|
protected |
Required for call to MKL; a plain-int version of row_start.
Referenced by MKLCRS< T >::prepare(), MKLCRS< T >::zax(), and MKLCRS< T >::~MKLCRS().
|
protected |
Required for call to MKL; matrix descriptor.
Referenced by MKLCRS< T >::prepare(), MKLCRS< T >::zax(), and MKLCRS< T >::~MKLCRS().
|
protected |
Required for call to MKL; (no) transposition.
Referenced by MKLCRS< T >::prepare(), and MKLCRS< T >::zax().