SparseLibrary  Version 1.6.0
Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
CuHyb Class Reference

Wrapper class for the CuSparse HYB data structure for CUDA C. More...

#include <CuHyb.hpp>

Inheritance diagram for CuHyb:
Inheritance graph
[legend]
Collaboration diagram for CuHyb:
Collaboration graph
[legend]

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...
 

Detailed Description

Wrapper class for the CuSparse HYB data structure for CUDA C.

Constructor & Destructor Documentation

CuHyb::CuHyb ( )

Base constructor.

CuHyb::CuHyb ( std::string  file,
double  zero = 0 
)

Base constructor.

Will read in from Matrix Market file.

See also
SparseMatrix::SparseMatrix( file, zero )

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.

Parameters
number_of_nonzerosThe number of non-zeros to be stored.
number_of_rowsThe number of rows to be stored.
number_of_colsThe number of columns of the matrix.
zeroThe 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.

Parameters
inputThe input collection.
mTotal number of rows.
nTotal number of columns.
zeroThe element considered to be zero.

References load().

CuHyb::~CuHyb ( )
virtual

Base deconstructor.

References descrA, GPUx, GPUz, handle, and hybA.

Member Function Documentation

size_t CuHyb::bytesUsed ( )
virtual
See also
Matrix::bytesUsed

Implements Matrix< double >.

void CuHyb::getFirstIndexPair ( size_t &  i,
size_t &  j 
)
virtual
See also
SparseMatrix::getFirstIndexPair

Implements SparseMatrix< double, size_t >.

References i, and j.

void CuHyb::load ( std::vector< Triplet< double > > &  input,
ULI  m,
ULI  n,
double  zero 
)
virtual
void CuHyb::zax ( const double *__restrict__  x,
double *__restrict__  z 
)
virtual

In-place z=Ax function.

Parameters
xThe x vector to multiply current matrix with.
zThe 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.

void CuHyb::zax ( const double *__restrict__  x,
double *__restrict__  z,
const unsigned long int  repeat,
const clockid_t  clock_id = 0,
double *  elapsed_time = NULL 
)
virtual

In-place z=Ax function that supports repition and timing.

Parameters
xThe x vector to multiply current matrix with.
zThe result vector. Must be pre-allocated and its elements should be initialised to zero.
repeatHow many times to repeat the SpMV, essentially computing z=A^{repeat}x.
clock_idWhich POSIX realtime clock to use for timing.
elapsed_timeWhere to add the elapsed time to.

References descrA, GPUx, GPUz, handle, hybA, i, SparseMatrix< double, size_t >::noc, and SparseMatrix< double, size_t >::nor.

Member Data Documentation

cusparseMatDescr_t CuHyb::descrA
protected

CuSparse matrix descriptor.

Referenced by load(), zax(), and ~CuHyb().

double* CuHyb::GPUx
protected

GPU-local buffer to the input vector.

Referenced by load(), zax(), and ~CuHyb().

double* CuHyb::GPUz
protected

GPU-local buffer to the output vector.

Referenced by load(), zax(), and ~CuHyb().

cusparseHandle_t CuHyb::handle
protected

Handle to CuSparse.

Referenced by load(), zax(), and ~CuHyb().

cusparseHybMat_t CuHyb::hybA
protected

GPU-local matrix.

Referenced by load(), zax(), and ~CuHyb().

size_t CuHyb::i
protected

Top-left row coordinate.

Referenced by getFirstIndexPair(), load(), and zax().

size_t CuHyb::j
protected

Top-right column coordinate.

Referenced by getFirstIndexPair(), and load().


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