1 #ifndef VIENNACL_LINALG_OPENCL_SPARSE_MATRIX_OPERATIONS_HPP_
2 #define VIENNACL_LINALG_OPENCL_SPARSE_MATRIX_OPERATIONS_HPP_
52 template<
typename SCALARTYPE,
unsigned int MAT_ALIGNMENT>
62 viennacl::traits::opencl_handle(vec),
64 cl_uint(info_selector)
78 template<
class TYPE,
unsigned int ALIGNMENT>
108 result, layout_result
121 template<
typename TYPE,
unsigned int ALIGNMENT,
typename F1,
typename F2>
132 viennacl::traits::opencl_handle(d_mat),
137 viennacl::traits::opencl_handle(result),
153 template<
typename TYPE,
unsigned int ALIGNMENT,
typename F1,
typename F2>
166 viennacl::traits::opencl_handle(d_mat.lhs()),
171 viennacl::traits::opencl_handle(result),
187 template<
typename SCALARTYPE,
unsigned int MAT_ALIGNMENT>
199 viennacl::traits::opencl_handle(vec),
210 template<
typename SCALARTYPE,
unsigned int MAT_ALIGNMENT>
223 viennacl::traits::opencl_handle(vec),
235 template<
typename SCALARTYPE,
unsigned int MAT_ALIGNMENT>
247 viennacl::traits::opencl_handle(vec),
258 template<
typename SCALARTYPE,
unsigned int MAT_ALIGNMENT>
271 viennacl::traits::opencl_handle(vec),
288 template<
typename ScalarType,
unsigned int MAT_ALIGNMENT>
303 L.lhs().handle2().opencl_handle(),
304 L.lhs().handle().opencl_handle(),
305 block_indices.opencl_handle(),
307 static_cast<cl_uint
>(vec.
size())));
311 template<
typename ScalarType,
unsigned int MAT_ALIGNMENT>
326 U.lhs().handle2().opencl_handle(),
327 U.lhs().handle().opencl_handle(),
329 block_indices.opencl_handle(),
331 static_cast<cl_uint
>(vec.
size())));
343 template<
typename SCALARTYPE,
unsigned int MAT_ALIGNMENT>
356 viennacl::ocl::enqueue(k(proxy_L.lhs().handle1().opencl_handle(), proxy_L.lhs().handle2().opencl_handle(), proxy_L.lhs().handle().opencl_handle(),
357 viennacl::traits::opencl_handle(vec),
358 cl_uint(proxy_L.lhs().size1())
369 template<
typename SCALARTYPE,
unsigned int MAT_ALIGNMENT>
384 k.local_work_size(0, 128);
385 k.global_work_size(0, k.local_work_size());
386 viennacl::ocl::enqueue(k(proxy_L.lhs().handle1().opencl_handle(), proxy_L.lhs().handle2().opencl_handle(), proxy_L.lhs().handle().opencl_handle(),
387 viennacl::traits::opencl_handle(diagonal),
388 viennacl::traits::opencl_handle(vec),
389 cl_uint(proxy_L.lhs().size1())
399 template<
typename SCALARTYPE,
unsigned int MAT_ALIGNMENT>
412 viennacl::ocl::enqueue(k(proxy_U.lhs().handle1().opencl_handle(), proxy_U.lhs().handle2().opencl_handle(), proxy_U.lhs().handle().opencl_handle(),
413 viennacl::traits::opencl_handle(vec),
414 cl_uint(proxy_U.lhs().size1())
425 template<
typename SCALARTYPE,
unsigned int MAT_ALIGNMENT>
440 k.local_work_size(0, 128);
441 k.global_work_size(0, k.local_work_size());
442 viennacl::ocl::enqueue(k(proxy_U.lhs().handle1().opencl_handle(), proxy_U.lhs().handle2().opencl_handle(), proxy_U.lhs().handle().opencl_handle(),
443 viennacl::traits::opencl_handle(diagonal),
444 viennacl::traits::opencl_handle(vec),
445 cl_uint(proxy_U.lhs().size1())
488 result, layout_result
499 template<
typename SCALARTYPE,
unsigned int MAT_ALIGNMENT>
507 unsigned int thread_num = 256;
513 viennacl::traits::opencl_handle(vec),
514 cl_uint(info_selector),
528 template<
class SCALARTYPE,
unsigned int ALIGNMENT>
553 unsigned int thread_num = 256;
560 viennacl::traits::opencl_handle(vec),
562 viennacl::traits::opencl_handle(result),
578 template<
typename NumericT,
unsigned int ALIGNMENT,
typename F1,
typename F2>
591 unsigned int thread_num = 256;
596 viennacl::traits::opencl_handle(d_mat),
601 viennacl::traits::opencl_handle(result),
619 template<
typename NumericT,
unsigned int ALIGNMENT,
typename F1,
typename F2>
634 unsigned int thread_num = 256;
639 viennacl::traits::opencl_handle(d_mat),
644 viennacl::traits::opencl_handle(result),
659 template<
class TYPE,
unsigned int ALIGNMENT>
683 std::stringstream ss;
684 ss <<
"vec_mul_" << 1;
687 unsigned int thread_num = 128;
688 unsigned int group_num = 256;
694 mat.
handle().opencl_handle(),
695 viennacl::traits::opencl_handle(vec),
697 viennacl::traits::opencl_handle(result),
699 cl_uint(mat.
size1()),
700 cl_uint(mat.
size2()),
719 template<
class ScalarType,
unsigned int ALIGNMENT,
class NumericT,
typename F1,
typename F2 >
736 cl_uint(sp_mat.
size1()),
737 cl_uint(sp_mat.
size2()),
741 viennacl::traits::opencl_handle(d_mat),
746 viennacl::traits::opencl_handle(result),
764 template<
class ScalarType,
unsigned int ALIGNMENT,
class NumericT,
typename F1,
typename F2>
783 cl_uint(sp_mat.
size1()),
784 cl_uint(sp_mat.
size2()),
788 viennacl::traits::opencl_handle(d_mat.lhs()),
793 viennacl::traits::opencl_handle(result),
806 template<
class TYPE,
unsigned int ALIGNMENT>
831 unsigned int thread_num = 256;
832 unsigned int group_num = 32;
838 mat.
handle().opencl_handle(),
842 viennacl::traits::opencl_handle(vec),
844 viennacl::traits::opencl_handle(result),
846 cl_uint(mat.
size1()),
854 template<
typename NumericT,
unsigned int ALIGNMENT,
typename F1,
typename F2>
864 unsigned int thread_num = 256;
865 unsigned int group_num = 32;
871 mat.
handle().opencl_handle(),
875 cl_uint(mat.
size1()),
879 viennacl::traits::opencl_handle(d_mat),
884 viennacl::traits::opencl_handle(result),
893 template<
typename NumericT,
unsigned int ALIGNMENT,
typename F1,
typename F2>
905 unsigned int thread_num = 256;
906 unsigned int group_num = 32;
912 mat.
handle().opencl_handle(),
916 cl_uint(mat.
size1()),
920 viennacl::traits::opencl_handle(d_mat.lhs()),
925 viennacl::traits::opencl_handle(result),
Sparse matrix class using a hybrid format composed of the ELL and CSR format for storing the nonzeros...
Definition: forwards.h:321
vcl_size_t size1() const
Definition: hyb_matrix.hpp:74
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.
Definition: context.hpp:470
const handle_type & handle2() const
Returns the OpenCL handle to the column index array.
Definition: compressed_compressed_matrix.hpp:452
std::size_t vcl_size_t
Definition: forwards.h:58
Helper class for packing four cl_uint numbers into a uint4 type for access inside an OpenCL kernel...
Definition: kernel.hpp:46
const handle_type & handle() const
Returns the OpenCL handle to the matrix entry array.
Definition: compressed_compressed_matrix.hpp:456
const handle_type & handle3() const
Definition: hyb_matrix.hpp:83
void clear()
Resets all entries to zero.
Definition: matrix.hpp:640
size_type size() const
Returns the length of the vector (cf. std::vector)
Definition: vector.hpp:837
result_of::size_type< matrix_base< NumericT, F > >::type stride2(matrix_base< NumericT, F > const &s)
Definition: stride.hpp:68
const handle_type & handle4() const
Definition: hyb_matrix.hpp:84
Represents an OpenCL device within ViennaCL.
Common implementations shared by OpenCL-based operations.
const handle_type & handle1() const
Returns the OpenCL handle to the row index array.
Definition: compressed_compressed_matrix.hpp:450
static void init(viennacl::ocl::context &ctx)
Definition: hyb_matrix.hpp:183
Helper class for checking whether a matrix has a row-major layout.
Definition: forwards.h:399
Represents an OpenCL kernel within ViennaCL.
Definition: kernel.hpp:59
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
Definition: size.hpp:216
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...
Definition: common.hpp:46
static void init(viennacl::ocl::context &ctx)
Definition: compressed_compressed_matrix.hpp:58
A tag class representing a lower triangular matrix.
Definition: forwards.h:703
vcl_size_t size1() const
Definition: ell_matrix.hpp:80
Manages an OpenCL context and provides the respective convenience functions for creating buffers...
Definition: context.hpp:51
vcl_size_t size2() const
Definition: ell_matrix.hpp:81
Main kernel class for generating OpenCL kernels for coordinate_matrix.
Definition: coordinate_matrix.hpp:343
vcl_size_t internal_ellnnz() const
Definition: hyb_matrix.hpp:77
A dense matrix class.
Definition: forwards.h:290
Expression template class for representing a tree of expressions which ultimately result in a matrix...
Definition: forwards.h:283
cl_uint start
Starting value of the integer stride.
Definition: kernel.hpp:49
result_of::size_type< viennacl::vector_base< T > >::type stride(viennacl::vector_base< T > const &s)
Definition: stride.hpp:46
This file provides the forward declarations for the main types used within ViennaCL.
result_of::size_type< T >::type start1(T const &obj)
Definition: start.hpp:64
vcl_size_t internal_maxnnz() const
Definition: ell_matrix.hpp:83
static void init(viennacl::ocl::context &ctx)
Definition: coordinate_matrix.hpp:350
const handle_type & handle2() const
Definition: hyb_matrix.hpp:82
vcl_size_t internal_size(vector_base< NumericT > const &vec)
Helper routine for obtaining the buffer length of a ViennaCL vector.
Definition: size.hpp:268
const handle_type & handle2() const
Returns the OpenCL handle to the column index array.
Definition: compressed_matrix.hpp:701
vcl_size_t internal_size1() const
Definition: hyb_matrix.hpp:71
result_of::size_type< MatrixType >::type size2(MatrixType const &mat)
Generic routine for obtaining the number of columns of a matrix (ViennaCL, uBLAS, etc...
Definition: size.hpp:245
Main kernel class for generating OpenCL kernels for ell_matrix.
Definition: ell_matrix.hpp:156
const handle_type & handle() const
Returns the OpenCL handle to the matrix entry array.
Definition: coordinate_matrix.hpp:354
const handle_type & handle() const
Definition: hyb_matrix.hpp:81
result_of::size_type< matrix_base< NumericT, F > >::type stride1(matrix_base< NumericT, F > const &s)
Definition: stride.hpp:57
const vcl_size_t & nnz1() const
Returns the number of nonzero entries.
Definition: compressed_compressed_matrix.hpp:445
void clear()
Resets all entries to zero. Does not change the size of the vector.
Definition: vector.hpp:863
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:144
result_of::size_type< T >::type start2(T const &obj)
Definition: start.hpp:83
const handle_type & handle3() const
Returns the OpenCL handle to the group start index array.
Definition: coordinate_matrix.hpp:356
void enqueue(KernelType &k, viennacl::ocl::command_queue const &queue)
Enqueues a kernel in the provided queue.
Definition: enqueue.hpp:48
A class representing local (shared) OpenCL memory. Typically used as kernel argument.
Definition: local_mem.hpp:33
Main kernel class for generating OpenCL kernels for compressed_matrix.
Definition: compressed_matrix.hpp:1039
Sparse matrix class using the ELLPACK format for storing the nonzeros.
Definition: ell_matrix.hpp:53
vcl_size_t ell_nnz() const
Definition: hyb_matrix.hpp:78
OpenCL kernel file for compressed_matrix operations.
A tag class representing an upper triangular matrix.
Definition: forwards.h:708
OpenCL kernel file for ell_matrix operations.
handle_type & handle()
Definition: ell_matrix.hpp:89
Implementation of a smart-pointer-like class for handling OpenCL handles.
result_of::size_type< T >::type start(T const &obj)
Definition: start.hpp:43
A sparse square matrix in compressed sparse rows format optimized for the case that only a few rows c...
Definition: compressed_compressed_matrix.hpp:263
const handle_type & handle3() const
Returns the OpenCL handle to the row index array.
Definition: compressed_compressed_matrix.hpp:454
static void init(viennacl::ocl::context &ctx)
Definition: ell_matrix.hpp:163
const handle_type & handle12() const
Returns the OpenCL handle to the (row, column) index array.
Definition: coordinate_matrix.hpp:352
vcl_size_t size2() const
Definition: hyb_matrix.hpp:75
static void init(viennacl::ocl::context &ctx)
Definition: compressed_matrix.hpp:1046
const vcl_size_t & size1() const
Returns the number of rows.
Definition: compressed_matrix.hpp:692
A vector class representing a linear memory sequence on the GPU. Inspired by boost::numeric::ublas::v...
Definition: forwards.h:208
vcl_size_t internal_size2(matrix_base< NumericT, F > const &mat)
Helper routine for obtaining the internal number of entries per column of a ViennaCL matrix...
Definition: size.hpp:287
void block_inplace_solve(const matrix_expression< const compressed_matrix< ScalarType, MAT_ALIGNMENT >, const compressed_matrix< ScalarType, MAT_ALIGNMENT >, op_trans > &L, viennacl::backend::mem_handle const &block_indices, vcl_size_t num_blocks, vector_base< ScalarType > const &, vector_base< ScalarType > &vec, viennacl::linalg::unit_lower_tag)
Definition: sparse_matrix_operations.hpp:289
OpenCL kernel file for hyb_matrix operations.
void inplace_solve(const matrix_base< NumericT, F1 > &A, matrix_base< NumericT, F2 > &B, SOLVERTAG)
Direct inplace solver for dense triangular systems. Matlab notation: A \ B.
Definition: direct_solve.hpp:75
viennacl::context context(T const &t)
Returns an ID for the currently active memory domain of an object.
Definition: context.hpp:41
row_info_types
Definition: forwards.h:691
vcl_size_t maxnnz() const
Definition: ell_matrix.hpp:84
Representation of an OpenCL kernel in ViennaCL.
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
OpenCL kernel file for vector operations.
handle_type & handle2()
Definition: ell_matrix.hpp:92
cl_uint stride
Increment between integers.
Definition: kernel.hpp:51
A tag class representing a lower triangular matrix with unit diagonal.
Definition: forwards.h:713
OpenCL kernel file for coordinate_matrix operations.
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
Definition: mem_handle.hpp:62
A tag class representing transposed matrices.
Definition: forwards.h:165
void prod_impl(const matrix_base< NumericT, F > &mat, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
Definition: matrix_operations.hpp:547
A sparse square matrix in compressed sparse rows format.
Definition: compressed_matrix.hpp:428
size_type global_work_size(int index=0) const
Returns the global work size at the respective dimension.
Definition: kernel.hpp:759
vcl_size_t internal_size1(matrix_base< NumericT, F > const &mat)
Helper routine for obtaining the internal number of entries per row of a ViennaCL matrix...
Definition: size.hpp:279
size_type local_work_size(int index=0) const
Returns the local work size at the respective dimension.
Definition: kernel.hpp:750
cl_uint size
Number of values in the stride.
Definition: kernel.hpp:53
const handle_type & handle5() const
Definition: hyb_matrix.hpp:85
void row_info(compressed_matrix< SCALARTYPE, MAT_ALIGNMENT > const &mat, vector_base< SCALARTYPE > &vec, viennacl::linalg::detail::row_info_types info_selector)
Definition: sparse_matrix_operations.hpp:53
Implementation of the ViennaCL scalar class.
vcl_size_t internal_size1() const
Definition: ell_matrix.hpp:77
A tag class representing an upper triangular matrix with unit diagonal.
Definition: forwards.h:718
Main kernel class for generating OpenCL kernels for compressed_compressed_matrix. ...
Definition: compressed_compressed_matrix.hpp:51
Main kernel class for generating OpenCL kernels for hyb_matrix.
Definition: hyb_matrix.hpp:176
A sparse square matrix, where entries are stored as triplets (i,j, val), where i and j are the row an...
Definition: coordinate_matrix.hpp:186
Definition: forwards.h:696
const handle_type & handle() const
Returns the OpenCL handle to the matrix entry array.
Definition: compressed_matrix.hpp:703
const handle_type & handle1() const
Returns the OpenCL handle to the row index array.
Definition: compressed_matrix.hpp:699
cl_uint internal_size
Internal length of the buffer. Might be larger than 'size' due to padding.
Definition: kernel.hpp:55