SparseLibrary
Version 1.6.0
|
Wrapper class for the CuSparse HYB data structure for CUDA C. More...
#include <CuHyb.hpp>
Public Member Functions | |
CuHyb () | |
Base constructor. More... | |
CuHyb (std::string file, double zero=0) | |
Base constructor. More... | |
CuHyb (const ULI number_of_nonzeros, const ULI number_of_rows, const ULI number_of_cols, double zero) | |
Base constructor which only initialises the internal arrays. More... | |
CuHyb (std::vector< Triplet< double > > input, ULI m, ULI n, double zero) | |
Constructor which transforms a collection of input triplets to CRS format. More... | |
virtual | ~CuHyb () |
Base deconstructor. More... | |
virtual void | load (std::vector< Triplet< double > > &input, ULI m, ULI n, double zero) |
virtual void | zxa (const double *__restrict__ x, double *__restrict__ z) |
In-place z=xA function. | |
virtual void | zax (const double *__restrict__ x, double *__restrict__ z) |
In-place z=Ax function. More... | |
virtual void | zax (const double *__restrict__ x, double *__restrict__ z, const unsigned long int repeat, const clockid_t clock_id=0, double *elapsed_time=NULL) |
In-place z=Ax function that supports repition and timing. More... | |
virtual size_t | bytesUsed () |
virtual void | getFirstIndexPair (size_t &i, size_t &j) |
Public Member Functions inherited from SparseMatrix< double, size_t > | |
SparseMatrix () | |
Base constructor. More... | |
SparseMatrix (const size_tnzs, const size_tnr, const size_tnc, const doublezero) | |
Base constructor. More... | |
virtual | ~SparseMatrix () |
Base deconstructor. More... | |
virtual void | load (std::vector< Triplet< double > > &input, const size_tm, const size_tn, const doublezero)=0 |
Function reading in from std::vector< Triplet< T > > format. More... | |
void | loadFromFile (const std::string file, const doublezero=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 double * | mv (const double *x) |
Calculates and returns z=Ax. More... | |
Public Member Functions inherited from Matrix< double > | |
Matrix () | |
Base constructor. More... | |
virtual | ~Matrix () |
Base deconstructor. More... | |
virtual void | zax (const double *__restrict__ x, double *__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 double *__restrict__ const *__restrict__ const X, double *__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 double *__restrict__ x, double *__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 double *__restrict__ const *__restrict__ const X, double *__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 Protected Member Functions | |
static int | compareTriplets (const void *left, const void *right) |
Sorts 1D columnwise. | |
Protected Attributes | |
cusparseHandle_t | handle |
Handle to CuSparse. More... | |
cusparseMatDescr_t | descrA |
CuSparse matrix descriptor. More... | |
cusparseHybMat_t | hybA |
GPU-local matrix. More... | |
double * | GPUx |
GPU-local buffer to the input vector. More... | |
double * | GPUz |
GPU-local buffer to the output vector. More... | |
size_t | i |
Top-left row coordinate. More... | |
size_t | j |
Top-right column coordinate. More... | |
Protected Attributes inherited from SparseMatrix< double, size_t > | |
size_t | nor |
Number of rows. More... | |
size_t | noc |
Number of columns. | |
size_t | nnz |
Number of non-zeros. More... | |
Additional Inherited Members | |
Public Attributes inherited from SparseMatrix< double, size_t > | |
double | zero_element |
The element considered to be zero. More... | |
Wrapper class for the CuSparse HYB data structure for CUDA C.
CuHyb::CuHyb | ( | ) |
Base constructor.
CuHyb::CuHyb | ( | std::string | file, |
double | zero = 0 |
||
) |
Base constructor.
Will read in from Matrix Market file.
References SparseMatrix< double, size_t >::loadFromFile().
CuHyb::CuHyb | ( | const ULI | number_of_nonzeros, |
const ULI | number_of_rows, | ||
const ULI | number_of_cols, | ||
double | zero | ||
) |
Base constructor which only initialises the internal arrays.
Note that to gain a valid structure, these arrays have to be filled by some external mechanism, and this mechanism needs to call CUDA and CuSparse initialisation routines.
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 SparseMatrix< double, size_t >::nnz, SparseMatrix< double, size_t >::noc, SparseMatrix< double, size_t >::nor, and SparseMatrix< double, size_t >::zero_element.
CuHyb::CuHyb | ( | std::vector< Triplet< double > > | input, |
ULI | m, | ||
ULI | n, | ||
double | zero | ||
) |
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 load().
|
virtual |
Implements Matrix< double >.
|
virtual |
Implements SparseMatrix< double, size_t >.
|
virtual |
References compareTriplets(), descrA, GPUx, GPUz, handle, hybA, i, j, Triplet< T >::j(), SparseMatrix< double, size_t >::m(), SparseMatrix< double, size_t >::n(), SparseMatrix< double, size_t >::nnz, SparseMatrix< double, size_t >::noc, SparseMatrix< double, size_t >::nor, Triplet< T >::value, and SparseMatrix< double, size_t >::zero_element.
Referenced by CuHyb().
|
virtual |
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. |
Implements SparseMatrix< double, size_t >.
References descrA, GPUx, GPUz, handle, hybA, SparseMatrix< double, size_t >::noc, and SparseMatrix< double, size_t >::nor.
|
virtual |
In-place z=Ax function that supports repition and timing.
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. |
repeat | How many times to repeat the SpMV, essentially computing z=A^{repeat}x. |
clock_id | Which POSIX realtime clock to use for timing. |
elapsed_time | Where to add the elapsed time to. |
References descrA, GPUx, GPUz, handle, hybA, i, SparseMatrix< double, size_t >::noc, and SparseMatrix< double, size_t >::nor.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Top-left row coordinate.
Referenced by getFirstIndexPair(), load(), and zax().
|
protected |
Top-right column coordinate.
Referenced by getFirstIndexPair(), and load().