PARALUTION  1.0.0
PARALUTION
ocl_matrix_hyb.hpp
Go to the documentation of this file.
1 #ifndef PARALUTION_OCL_MATRIX_HYB_HPP_
2 #define PARALUTION_OCL_MATRIX_HYB_HPP_
3 
4 #include "../base_matrix.hpp"
5 #include "../base_vector.hpp"
6 
7 #if defined(__APPLE__) && defined(__MACH__)
8 #include <OpenCL/cl.h>
9 #else
10 #include <CL/cl.h>
11 #endif
12 
13 namespace paralution {
14 
15 template <class ValueType>
16 class OCLAcceleratorMatrixHYB : public OCLAcceleratorMatrix<ValueType> {
17 
18 public:
19 
21  OCLAcceleratorMatrixHYB(const Paralution_Backend_Descriptor local_backend);
22  virtual ~OCLAcceleratorMatrixHYB();
23 
24  inline int get_ell_max_row(void) const { return this->mat_.ELL.max_row; }
25  inline int get_ell_nnz(void) const { return this->ell_nnz_; }
26  inline int get_coo_nnz(void) const { return this->coo_nnz_; }
27 
28  virtual void info(void) const;
29  virtual unsigned int get_mat_format(void) const{ return HYB; }
30 
31  virtual void Clear(void);
32  virtual void AllocateHYB(const int ell_nnz, const int coo_nnz, const int ell_max_row,
33  const int nrow, const int ncol);
34 
35 
36  virtual bool ConvertFrom(const BaseMatrix<ValueType> &mat);
37 
38  virtual void CopyFrom(const BaseMatrix<ValueType> &mat);
39  virtual void CopyTo(BaseMatrix<ValueType> *mat) const;
40 
41  virtual void CopyFromHost(const HostMatrix<ValueType> &src);
42  virtual void CopyToHost(HostMatrix<ValueType> *dst) const;
43 
44  virtual void Apply(const BaseVector<ValueType> &in, BaseVector<ValueType> *out) const;
45  virtual void ApplyAdd(const BaseVector<ValueType> &in, const ValueType scalar,
46  BaseVector<ValueType> *out) const;
47 
48 private:
49 
51  int ell_nnz_;
52  int coo_nnz_;
53 
54  friend class BaseVector<ValueType>;
55  friend class AcceleratorVector<ValueType>;
56  friend class OCLAcceleratorVector<ValueType>;
57 
58 };
59 
60 
61 }
62 
63 #endif // PARALUTION_OCL_MATRIX_HYB_HPP_
virtual void CopyToHost(HostMatrix< ValueType > *dst) const
Copy (accelerator matrix) to host matrix.
Definition: ocl_matrix_hyb.cpp:244
virtual void info(void) const
Shows simple info about the object.
Definition: ocl_matrix_hyb.cpp:61
int get_ell_nnz(void) const
Definition: ocl_matrix_hyb.hpp:25
MatrixHYB< cl_mem, cl_mem, int > mat_
Definition: ocl_matrix_hyb.hpp:50
Definition: matrix_formats.hpp:27
virtual void ApplyAdd(const BaseVector< ValueType > &in, const ValueType scalar, BaseVector< ValueType > *out) const
Apply and add the matrix to vector, out = out + scalar*this*in;.
Definition: ocl_matrix_hyb.cpp:931
int get_ell_max_row(void) const
Definition: ocl_matrix_hyb.hpp:24
int ell_nnz_
Definition: ocl_matrix_hyb.hpp:51
Index max_row
Maximal elements per row.
Definition: matrix_formats.hpp:98
int coo_nnz_
Definition: ocl_matrix_hyb.hpp:52
Definition: backend_manager.hpp:10
const IndexType const IndexType const IndexType const ValueType const ValueType scalar
Definition: cuda_kernels_coo.hpp:91
virtual void CopyTo(BaseMatrix< ValueType > *mat) const
Copy to another matrix.
Definition: ocl_matrix_hyb.cpp:388
virtual void Clear(void)
Clear (free) the matrix.
Definition: ocl_matrix_hyb.cpp:155
int get_coo_nnz(void) const
Definition: ocl_matrix_hyb.hpp:26
virtual bool ConvertFrom(const BaseMatrix< ValueType > &mat)
Convert the matrix from another matrix (with different structure)
Definition: ocl_matrix_hyb.cpp:467
virtual unsigned int get_mat_format(void) const
Return the matrix format id (see matrix_formats.hpp)
Definition: ocl_matrix_hyb.hpp:29
virtual ~OCLAcceleratorMatrixHYB()
Definition: ocl_matrix_hyb.cpp:51
virtual void CopyFromHost(const HostMatrix< ValueType > &src)
Copy (accelerator matrix) from host matrix.
Definition: ocl_matrix_hyb.cpp:179
OCLAcceleratorMatrixHYB()
Definition: ocl_matrix_hyb.cpp:21
Base class for all host/accelerator matrices.
Definition: base_matrix.hpp:92
virtual void Apply(const BaseVector< ValueType > &in, BaseVector< ValueType > *out) const
Apply the matrix to vector, out = this*in;.
Definition: ocl_matrix_hyb.cpp:709
Definition: backend_manager.cpp:43
Definition: backend_manager.hpp:14
Definition: base_vector.hpp:19
Base class for all host/accelerator vectors.
Definition: base_vector.hpp:26
virtual void CopyFrom(const BaseMatrix< ValueType > &mat)
Copy from another matrix.
Definition: ocl_matrix_hyb.cpp:311
MatrixELL< ValueType, IndexType, Index > ELL
Definition: matrix_formats.hpp:111
virtual void AllocateHYB(const int ell_nnz, const int coo_nnz, const int ell_max_row, const int nrow, const int ncol)
Allocate HYB Matrix.
Definition: ocl_matrix_hyb.cpp:68