37 #include <mkl_service.h>
38 #include <mkl_spblas.h>
49 template<
typename T >
82 _m =
static_cast< int >( this->
nor );
83 _n =
static_cast< int >( this->
noc );
87 for( ULI i=0; i<this->
nnz; ++i )
91 for(
int i=0; i<=
_m; ++i )
126 MKLCRS(
const ULI number_of_nonzeros,
const ULI number_of_rows,
const ULI number_of_cols, T zero ) {
127 this->
nnz = number_of_nonzeros;
128 this->
nor = number_of_rows;
129 this->
noc = number_of_cols;
132 this->
ds =
new T[ this->
nnz ];
146 this->
ds =
new T[ this->
nnz ];
148 for( ULI i=0; i<this->
nnz; i++ ) {
149 this->
ds[ i ] = toCopy.
ds[ i ];
152 for( ULI i=0; i<this->
nor; i++ )
169 load( input, m, n, zero );
176 virtual T*
mv(
const T* x ) {
177 T* ret = (T*) numa_alloc_interleaved( this->
nor *
sizeof( T ) );
178 for( ULI i=0; i<this->
nor; i++ )
188 virtual void zxa(
const T*__restrict__ x, T*__restrict__ z ) {
189 std::cerr <<
"MKLCRS does not implement the zxa, sorry!" << std::endl;
190 exit( EXIT_FAILURE );
199 virtual void zax(
const T*__restrict__ x, T*__restrict__ z ) {
201 mkl_dcsrmv( &
trans, &
_m, &
_n, &
_one,
descr, this->
ds,
_col_ind,
_row_start, &(
_row_start[ 1 ] ), (T*__restrict__)x, &
_one, z );
ULI nnz
Number of non-zeros.
Definition: SparseMatrix.hpp:58
void prepare()
Does the required post-processing of Sparse Library's CRS representation to one compatible with Intel...
Definition: MKLCRS.hpp:81
ULI * row_start
Array keeping track of individual row starting indices.
Definition: CRS.hpp:59
virtual void load(std::vector< Triplet< T > > &input, ULI m, ULI n, T zero)
Definition: CRS.hpp:160
MKLCRS()
Base constructor.
Definition: MKLCRS.hpp:105
ULI * col_ind
Array containing the column indeces corresponding to the elements in ds.
Definition: CRS.hpp:65
MKLCRS(std::vector< Triplet< T > > input, ULI m, ULI n, T zero)
Constructor which transforms a collection of input triplets to CRS format.
Definition: MKLCRS.hpp:168
virtual unsigned long int m()
Queries the number of rows this matrix contains.
Definition: SparseMatrix.hpp:107
int _m
Required for call to MKL; matrix row-size.
Definition: MKLCRS.hpp:66
virtual void zxa(const T *__restrict__ x, T *__restrict__ z)
In-place z=xA function.
Definition: MKLCRS.hpp:188
The compressed row storage sparse matrix data structure.
Definition: CRS.hpp:52
MKLCRS(std::string file, T zero=0)
Base constructor.
Definition: MKLCRS.hpp:111
int * _col_ind
Required for call to MKL; a plain-int version of col_ind.
Definition: MKLCRS.hpp:72
virtual ~MKLCRS()
Base deconstructor.
Definition: MKLCRS.hpp:205
double _one
Required for call to MKL; a factor alpha=beta of 1.
Definition: MKLCRS.hpp:57
void loadFromFile(const std::string file, const T zero=0)
Function which loads a matrix from a matrix market file.
Definition: SparseMatrix.hpp:89
char trans
Required for call to MKL; (no) transposition.
Definition: MKLCRS.hpp:60
ULI noc
Number of columns.
Definition: SparseMatrix.hpp:55
MKLCRS(CRS< T > &toCopy)
Copy constructor.
Definition: MKLCRS.hpp:141
int * _row_start
Required for call to MKL; a plain-int version of row_start.
Definition: MKLCRS.hpp:75
int _n
Required for call to MKL; matrix column-size.
Definition: MKLCRS.hpp:69
ULI nor
Number of rows.
Definition: SparseMatrix.hpp:52
T zero_element
The element considered to be zero.
Definition: SparseMatrix.hpp:63
virtual void zax(const T *__restrict__ x, T *__restrict__ z)
In-place z=Ax function.
Definition: MKLCRS.hpp:199
T * ds
Array containing the actual nnz non-zeros.
Definition: CRS.hpp:62
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.
Definition: MKLCRS.hpp:126
virtual unsigned long int n()
Queries the number of columns this matrix contains.
Definition: SparseMatrix.hpp:115
A single triplet value.
Definition: Triplet.hpp:52
The compressed row storage sparse matrix data structure.
Definition: MKLCRS.hpp:50
char * descr
Required for call to MKL; matrix descriptor.
Definition: MKLCRS.hpp:63
virtual T * mv(const T *x)
Overloaded mv call; allocates output vector using numa_interleaved.
Definition: MKLCRS.hpp:176