1 #ifndef VIENNACL_LINALG_OPENCL_SPARSE_MATRIX_OPERATIONS_HPP_
2 #define VIENNACL_LINALG_OPENCL_SPARSE_MATRIX_OPERATIONS_HPP_
53 template<
typename NumericT,
unsigned int AlignmentV>
63 viennacl::traits::opencl_handle(x),
65 cl_uint(info_selector)
79 template<
typename NumericT,
unsigned int AlignmentV>
88 unsigned int alignment = AlignmentV;
123 template<
typename NumericT,
unsigned int AlignmentV>
134 viennacl::traits::opencl_handle(d_A),
139 viennacl::traits::opencl_handle(y),
155 template<
typename NumericT,
unsigned int AlignmentV>
168 viennacl::traits::opencl_handle(d_A.lhs()),
173 viennacl::traits::opencl_handle(y),
189 template<
typename NumericT,
unsigned int MAT_AlignmentV>
201 viennacl::traits::opencl_handle(x),
212 template<
typename NumericT,
unsigned int AlignmentV>
225 viennacl::traits::opencl_handle(x),
237 template<
typename NumericT,
unsigned int AlignmentV>
249 viennacl::traits::opencl_handle(x),
260 template<
typename NumericT,
unsigned int AlignmentV>
273 viennacl::traits::opencl_handle(x),
290 template<
typename NumericT,
unsigned int AlignmentV>
305 L.lhs().handle2().opencl_handle(),
306 L.lhs().handle().opencl_handle(),
307 block_indices.opencl_handle(),
309 static_cast<cl_uint
>(x.
size())));
313 template<
typename NumericT,
unsigned int AlignmentV>
328 U.lhs().handle2().opencl_handle(),
329 U.lhs().handle().opencl_handle(),
331 block_indices.opencl_handle(),
333 static_cast<cl_uint
>(x.
size())));
345 template<
typename NumericT,
unsigned int AlignmentV>
358 viennacl::ocl::enqueue(k(proxy_L.lhs().handle1().opencl_handle(), proxy_L.lhs().handle2().opencl_handle(), proxy_L.lhs().handle().opencl_handle(),
359 viennacl::traits::opencl_handle(x),
360 cl_uint(proxy_L.lhs().size1())
371 template<
typename NumericT,
unsigned int AlignmentV>
386 k.local_work_size(0, 128);
387 k.global_work_size(0, k.local_work_size());
388 viennacl::ocl::enqueue(k(proxy_L.lhs().handle1().opencl_handle(), proxy_L.lhs().handle2().opencl_handle(), proxy_L.lhs().handle().opencl_handle(),
389 viennacl::traits::opencl_handle(diagonal),
390 viennacl::traits::opencl_handle(x),
391 cl_uint(proxy_L.lhs().size1())
401 template<
typename NumericT,
unsigned int AlignmentV>
414 viennacl::ocl::enqueue(k(proxy_U.lhs().handle1().opencl_handle(), proxy_U.lhs().handle2().opencl_handle(), proxy_U.lhs().handle().opencl_handle(),
415 viennacl::traits::opencl_handle(x),
416 cl_uint(proxy_U.lhs().size1())
427 template<
typename NumericT,
unsigned int AlignmentV>
442 k.local_work_size(0, 128);
443 k.global_work_size(0, k.local_work_size());
444 viennacl::ocl::enqueue(k(proxy_U.lhs().handle1().opencl_handle(), proxy_U.lhs().handle2().opencl_handle(), proxy_U.lhs().handle().opencl_handle(),
445 viennacl::traits::opencl_handle(diagonal),
446 viennacl::traits::opencl_handle(x),
447 cl_uint(proxy_U.lhs().size1())
465 template<
typename NumericT>
501 template<
typename NumericT,
unsigned int AlignmentV>
509 unsigned int thread_num = 256;
515 viennacl::traits::opencl_handle(x),
516 cl_uint(info_selector),
530 template<
typename NumericT,
unsigned int AlignmentV>
555 unsigned int thread_num = 256;
562 viennacl::traits::opencl_handle(x),
564 viennacl::traits::opencl_handle(y),
580 template<
typename NumericT,
unsigned int AlignmentV>
593 unsigned int thread_num = 256;
598 viennacl::traits::opencl_handle(d_A),
603 viennacl::traits::opencl_handle(y),
621 template<
typename NumericT,
unsigned int AlignmentV>
636 unsigned int thread_num = 256;
641 viennacl::traits::opencl_handle(d_A),
646 viennacl::traits::opencl_handle(y),
661 template<
typename NumericT,
unsigned int AlignmentV>
685 std::stringstream ss;
686 ss <<
"vec_mul_" << 1;
689 unsigned int thread_num = 128;
690 unsigned int group_num = 256;
696 A.
handle().opencl_handle(),
697 viennacl::traits::opencl_handle(x),
699 viennacl::traits::opencl_handle(y),
721 template<
typename NumericT,
unsigned int AlignmentV>
738 cl_uint(sp_A.
size1()),
739 cl_uint(sp_A.
size2()),
743 viennacl::traits::opencl_handle(d_A),
748 viennacl::traits::opencl_handle(y),
766 template<
typename NumericT,
unsigned int AlignmentV>
785 cl_uint(sp_A.
size1()),
786 cl_uint(sp_A.
size2()),
790 viennacl::traits::opencl_handle(d_A.lhs()),
795 viennacl::traits::opencl_handle(y),
808 template<
typename ScalarT,
typename IndexT>
832 std::stringstream ss;
833 ss <<
"vec_mul_" << 1;
837 unsigned int group_num = 256;
845 A.
handle().opencl_handle(),
846 viennacl::traits::opencl_handle(x),
848 viennacl::traits::opencl_handle(y),
858 template<
typename NumericT,
unsigned int AlignmentV>
883 unsigned int thread_num = 256;
884 unsigned int group_num = 32;
890 A.
handle().opencl_handle(),
894 viennacl::traits::opencl_handle(x),
896 viennacl::traits::opencl_handle(y),
906 template<
typename NumericT,
unsigned int AlignmentV>
916 unsigned int thread_num = 256;
917 unsigned int group_num = 32;
923 A.
handle().opencl_handle(),
931 viennacl::traits::opencl_handle(d_A),
936 viennacl::traits::opencl_handle(y),
945 template<
typename NumericT,
unsigned int AlignmentV>
957 unsigned int thread_num = 256;
958 unsigned int group_num = 32;
964 A.
handle().opencl_handle(),
972 viennacl::traits::opencl_handle(d_A.lhs()),
977 viennacl::traits::opencl_handle(y),
vcl_size_t internal_ellnnz() const
Sparse matrix class using a hybrid format composed of the ELL and CSR format for storing the nonzeros...
cl_uint stride
Increment between integers.
static void init(viennacl::ocl::context &ctx)
Helper class for packing four cl_uint numbers into a uint4 type for access inside an OpenCL kernel...
Represents an OpenCL device within ViennaCL.
result_of::size_type< matrix_base< NumericT > >::type stride1(matrix_base< NumericT > const &s)
const handle_type & handle3() const
const vcl_size_t & size1() const
Returns the number of rows.
const handle_type & handle2() const
Returns the OpenCL handle to the column index array.
Represents an OpenCL kernel within ViennaCL.
cl_uint start
Starting value of the integer stride.
const handle_type & handle1() const
Returns the OpenCL handle to the row index array.
const handle_type & handle() const
vcl_size_t internal_size1(matrix_base< NumericT > const &mat)
Helper routine for obtaining the internal number of entries per row of a ViennaCL matrix...
size_type local_work_size(int index=0) const
Returns the local work size at the respective dimension.
const handle_type & handle12() const
Returns the OpenCL handle to the (row, column) index array.
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
std::string sparse_dense_matmult_kernel_name(bool B_transposed, bool B_row_major, bool C_row_major)
Returns the OpenCL kernel string for the operation C = A * B with A sparse, B, C dense matrices...
A tag class representing a lower triangular matrix.
Manages an OpenCL context and provides the respective convenience functions for creating buffers...
Main kernel class for generating OpenCL kernels for coordinate_matrix.
vcl_size_t internal_size1() const
vcl_size_t internal_size2(matrix_base< NumericT > const &mat)
Helper routine for obtaining the internal number of entries per column of a ViennaCL matrix...
Expression template class for representing a tree of expressions which ultimately result in a matrix...
result_of::size_type< viennacl::vector_base< T > >::type stride(viennacl::vector_base< T > const &s)
This file provides the forward declarations for the main types used within ViennaCL.
result_of::size_type< T >::type start1(T const &obj)
const handle_type & handle4() const
vcl_size_t internal_size(vector_base< NumericT > const &vec)
Helper routine for obtaining the buffer length of a ViennaCL vector.
vcl_size_t rows_per_block() const
result_of::size_type< MatrixType >::type size2(MatrixType const &mat)
Generic routine for obtaining the number of columns of a matrix (ViennaCL, uBLAS, etc...
const handle_type & handle() const
Returns the OpenCL handle to the matrix entry array.
const handle_type & handle1() const
Returns the OpenCL handle to the row index array.
cl_uint internal_size
Internal length of the buffer. Might be larger than 'size' due to padding.
vcl_size_t internal_size1() const
Common implementations shared by OpenCL-based operations.
Main kernel class for generating OpenCL kernels for ell_matrix.
const handle_type & handle2() const
const handle_type & handle() const
Returns the OpenCL handle to the matrix entry array.
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
result_of::size_type< T >::type start2(T const &obj)
A class representing local (shared) OpenCL memory. Typically used as kernel argument.
Main kernel class for generating OpenCL kernels for compressed_matrix.
Sparse matrix class using the ELLPACK format for storing the nonzeros.
viennacl::ocl::kernel & get_kernel(std::string const &program_name, std::string const &kernel_name)
Convenience function for retrieving the kernel of a program directly from the context.
static void init(viennacl::ocl::context &ctx)
OpenCL kernel file for compressed_matrix operations.
A tag class representing an upper triangular matrix.
void inplace_solve(const matrix_base< NumericT > &A, bool A_trans, matrix_base< NumericT > &B, bool B_trans, SolverTagT)
Direct inplace solver for dense triangular systems. Matlab notation: A \ B.
OpenCL kernel file for ell_matrix operations.
Sparse matrix class using the sliced ELLPACK with parameters C, .
void clear()
Resets all entries to zero.
const handle_type & handle3() const
Returns the OpenCL handle to the row index array.
Implementation of a smart-pointer-like class for handling OpenCL handles.
result_of::size_type< T >::type start(T const &obj)
A sparse square matrix in compressed sparse rows format optimized for the case that only a few rows c...
const handle_type & handle2() const
Returns the OpenCL handle to the column index array.
Main kernel class for generating OpenCL kernels for ell_matrix.
OpenCL kernel file for sliced_ell_matrix operations.
vcl_size_t maxnnz() const
result_of::size_type< matrix_base< NumericT > >::type stride2(matrix_base< NumericT > const &s)
const handle_type & handle3() const
Returns the OpenCL handle to the group start index array.
OpenCL kernel file for hyb_matrix operations.
void clear()
Resets all entries to zero. Does not change the size of the vector.
viennacl::context context(T const &t)
Returns an ID for the currently active memory domain of an object.
const handle_type & handle() const
Returns the OpenCL handle to the matrix entry array.
void enqueue(KernelType &k, viennacl::ocl::command_queue const &queue)
Enqueues a kernel in the provided queue.
Representation of an OpenCL kernel in ViennaCL.
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
static void init(viennacl::ocl::context &ctx)
OpenCL kernel file for vector operations.
size_type size() const
Returns the length of the vector (cf. std::vector)
const vcl_size_t & nnz1() const
Returns the number of nonzero entries.
vcl_size_t ell_nnz() const
A tag class representing a lower triangular matrix with unit diagonal.
size_type global_work_size(int index=0) const
Returns the global work size at the respective dimension.
OpenCL kernel file for coordinate_matrix operations.
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
A tag class representing transposed matrices.
A sparse square matrix in compressed sparse rows format.
const handle_type & handle5() const
void block_inplace_solve(const matrix_expression< const compressed_matrix< NumericT, AlignmentV >, const compressed_matrix< NumericT, AlignmentV >, op_trans > &L, viennacl::backend::mem_handle const &block_indices, vcl_size_t num_blocks, vector_base< NumericT > const &, vector_base< NumericT > &x, viennacl::linalg::unit_lower_tag)
static void init(viennacl::ocl::context &ctx)
vcl_size_t internal_maxnnz() const
Implementation of the ViennaCL scalar class.
static void init(viennacl::ocl::context &ctx)
void prod_impl(const matrix_base< NumericT > &A, bool trans_A, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
A tag class representing an upper triangular matrix with unit diagonal.
Main kernel class for generating OpenCL kernels for compressed_compressed_matrix. ...
cl_uint size
Number of values in the stride.
Main kernel class for generating OpenCL kernels for hyb_matrix.
A sparse square matrix, where entries are stored as triplets (i,j, val), where i and j are the row an...
void row_info(compressed_matrix< NumericT, AlignmentV > const &A, vector_base< NumericT > &x, viennacl::linalg::detail::row_info_types info_selector)