VexCL
Public Types | Public Member Functions | Static Public Member Functions | List of all members
vex::SpMat< val_t, col_t, idx_t > Class Template Reference

Sparse matrix in hybrid ELL-CSR format. More...

#include <spmat.hpp>

Public Types

typedef val_t value_type
 

Public Member Functions

 SpMat ()
 Empty constructor.
 
 SpMat (const std::vector< cl::CommandQueue > &queue, size_t n, size_t m, const idx_t *row, const col_t *col, const val_t *val)
 Constructor. More...
 
void mul (const vex::vector< val_t > &x, vex::vector< val_t > &y, val_t alpha=1, bool append=false) const
 Matrix-vector multiplication. More...
 
size_t rows () const
 Number of rows.
 
size_t cols () const
 Number of columns.
 
size_t nonzeros () const
 Number of non-zero entries.
 

Static Public Member Functions

static std::string inline_preamble (const cl::Device &device, int component, int position, kernel_generator_state &)
 
static std::string inline_expression (const cl::Device &device, int component, int position, kernel_generator_state &)
 
static std::string inline_parameters (const cl::Device &device, int component, int position, kernel_generator_state &)
 
static void inline_arguments (cl::Kernel &kernel, uint device, size_t, uint &position, const SpMat &A, const vector< val_t > &x, kernel_generator_state &)
 

Detailed Description

template<typename val_t, typename col_t = size_t, typename idx_t = size_t>
class vex::SpMat< val_t, col_t, idx_t >

Sparse matrix in hybrid ELL-CSR format.

Constructor & Destructor Documentation

template<typename val_t, typename col_t = size_t, typename idx_t = size_t>
vex::SpMat< val_t, col_t, idx_t >::SpMat ( const std::vector< cl::CommandQueue > &  queue,
size_t  n,
size_t  m,
const idx_t *  row,
const col_t *  col,
const val_t *  val 
)
inline

Constructor.

Constructs GPU representation of the matrix. Input matrix is in CSR format. GPU matrix utilizes ELL format and is split equally across all compute devices. When there are more than one device, secondary queue can be used to perform transfer of ghost values across GPU boundaries in parallel with computation kernel.

Parameters
queuevector of queues. Each queue represents one compute device.
nnumber of rows in the matrix.
mnumber of cols in the matrix.
rowrow index into col and val vectors.
colcolumn numbers of nonzero elements of the matrix.
valvalues of nonzero elements of the matrix.

References vex::is_cpu(), vex::qctx(), and vex::qdev().

Member Function Documentation

template<typename val_t, typename col_t = size_t, typename idx_t = size_t>
void vex::SpMat< val_t, col_t, idx_t >::mul ( const vex::vector< val_t > &  x,
vex::vector< val_t > &  y,
val_t  alpha = 1,
bool  append = false 
) const
inline

Matrix-vector multiplication.

Matrix vector multiplication ( $y = \alpha Ax$ or $y += \alpha Ax$) is performed in parallel on all registered compute devices. Ghost values of x are transfered across GPU boundaries as needed.

Parameters
xinput vector.
youtput vector.
alphacoefficient in front of matrix-vector product
appendif set, matrix-vector product is appended to y. Otherwise, y is replaced with matrix-vector product.

References vex::alignup(), vex::build_sources(), vex::bytes(), vex::kernel_workgroup_size(), vex::qctx(), and vex::qdev().

Referenced by vex::device_spmv_perf().


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