PARALUTION  1.0.0
PARALUTION
ocl_matrix_csr.hpp
Go to the documentation of this file.
1 #ifndef PARALUTION_OCL_MATRIX_CSR_HPP_
2 #define PARALUTION_OCL_MATRIX_CSR_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 OCLAcceleratorMatrixCSR : public OCLAcceleratorMatrix<ValueType> {
17 
18 public:
19 
21  OCLAcceleratorMatrixCSR(const Paralution_Backend_Descriptor local_backend);
22  virtual ~OCLAcceleratorMatrixCSR();
23 
24  virtual void info(void) const;
25  virtual unsigned int get_mat_format(void) const { return CSR; }
26 
27  virtual void Clear(void);
28  virtual bool Zeros(void);
29 
30  virtual void AllocateCSR(const int nnz, const int nrow, const int ncol);
31 
32  virtual bool ConvertFrom(const BaseMatrix<ValueType> &mat);
33 
34  virtual void CopyFrom(const BaseMatrix<ValueType> &mat);
35  virtual void CopyTo(BaseMatrix<ValueType> *mat) const;
36 
37  virtual void CopyFromHost(const HostMatrix<ValueType> &src);
38  virtual void CopyToHost(HostMatrix<ValueType> *dst) const;
39 
40  virtual bool Permute(const BaseVector<int> &permutation);
41 
42  virtual bool Scale(const ValueType alpha);
43  virtual bool ScaleDiagonal(const ValueType alpha);
44  virtual bool ScaleOffDiagonal(const ValueType alpha);
45  virtual bool AddScalar(const ValueType alpha);
46  virtual bool AddScalarDiagonal(const ValueType alpha);
47  virtual bool AddScalarOffDiagonal(const ValueType alpha);
48 
49  virtual bool ExtractSubMatrix(const int row_offset,
50  const int col_offset,
51  const int row_size,
52  const int col_size,
53  BaseMatrix<ValueType> *mat) const;
54 
55  virtual bool ExtractDiagonal(BaseVector<ValueType> *vec_diag) const;
56  virtual bool ExtractInverseDiagonal(BaseVector<ValueType> *vec_inv_diag) const;
57  virtual bool ExtractL(BaseMatrix<ValueType> *L) const;
58  virtual bool ExtractLDiagonal(BaseMatrix<ValueType> *L) const;
59 
60  virtual bool ExtractU(BaseMatrix<ValueType> *U) const;
61  virtual bool ExtractUDiagonal(BaseMatrix<ValueType> *U) const;
62 
63  virtual bool MaximalIndependentSet(int &size,
64  BaseVector<int> *permutation) const;
65  virtual bool MultiColoring(int &num_colors,
66  int **size_colors,
67  BaseVector<int> *permutation) const;
68 
69  virtual bool DiagonalMatrixMultR(const BaseVector<ValueType> &diag);
70  virtual bool DiagonalMatrixMultL(const BaseVector<ValueType> &diag);
71 
72  virtual bool MatrixAdd(const BaseMatrix<ValueType> &mat, const ValueType alpha,
73  const ValueType beta, const bool structure);
74 
75  virtual void LUAnalyse(void);
76  virtual void LUAnalyseClear(void);
77 
78  virtual void LLAnalyse(void);
79  virtual void LLAnalyseClear(void);
80 
81  virtual void LAnalyse(const bool diag_unit=false);
82  virtual void LAnalyseClear(void);
83 
84  virtual void UAnalyse(const bool diag_unit=false);
85  virtual void UAnalyseClear(void);
86 
87  virtual void Apply(const BaseVector<ValueType> &in, BaseVector<ValueType> *out) const;
88  virtual void ApplyAdd(const BaseVector<ValueType> &in, const ValueType scalar,
89  BaseVector<ValueType> *out) const;
90 
91  virtual bool Compress(const double drop_off);
92 
93  virtual bool ReplaceColumnVector(const int idx, const BaseVector<ValueType> &vec);
94  virtual bool ExtractColumnVector(const int idx, BaseVector<ValueType> *vec) const;
95 
96 private:
97 
99 
100  friend class OCLAcceleratorMatrixDIA<ValueType>;
101  friend class OCLAcceleratorMatrixELL<ValueType>;
102  friend class OCLAcceleratorMatrixHYB<ValueType>;
103 
104  friend class BaseVector<ValueType>;
105  friend class AcceleratorVector<ValueType>;
106  friend class OCLAcceleratorVector<ValueType>;
107 
109 
110 };
111 
112 
113 }
114 
115 #endif // PARALUTION_OCL_MATRIX_CSR_HPP_
virtual bool DiagonalMatrixMultR(const BaseVector< ValueType > &diag)
Multiply the matrix with diagonal matrix (stored in LocalVector), this=this*diag (right multiplicatio...
Definition: ocl_matrix_csr.cpp:2115
virtual bool MaximalIndependentSet(int &size, BaseVector< int > *permutation) const
Perform maximal independent set decomposition of the matrix; Returns the size of the maximal independ...
Definition: ocl_matrix_csr.cpp:1639
virtual void LUAnalyse(void)
Analyse the structure (level-scheduling)
Definition: ocl_matrix_csr.cpp:851
virtual bool AddScalarDiagonal(const ValueType alpha)
Add alpha to the diagonal entries of the matrix.
Definition: ocl_matrix_csr.cpp:1962
Definition: base_matrix.hpp:67
virtual bool ScaleDiagonal(const ValueType alpha)
Scale the diagonal entries of the matrix with alpha.
Definition: ocl_matrix_csr.cpp:1858
virtual void CopyToHost(HostMatrix< ValueType > *dst) const
Copy (accelerator matrix) to host matrix.
Definition: ocl_matrix_csr.cpp:227
const IndexType idx
Definition: cuda_kernels_coo.hpp:115
virtual bool ExtractUDiagonal(BaseMatrix< ValueType > *U) const
Extract the upper triangular matrix including diagonal.
Definition: ocl_matrix_csr.cpp:1515
Definition: base_matrix.hpp:65
virtual ~OCLAcceleratorMatrixCSR()
Definition: ocl_matrix_csr.cpp:51
virtual bool AddScalarOffDiagonal(const ValueType alpha)
Add alpha to the off-diagonal entries of the matrix.
Definition: ocl_matrix_csr.cpp:2014
Definition: backend_manager.hpp:10
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_csr.cpp:784
nnz
Definition: pcg_example.m:8
virtual void LLAnalyseClear(void)
Delete the analysed data (see LLAnalyse)
Definition: ocl_matrix_csr.cpp:863
virtual bool ConvertFrom(const BaseMatrix< ValueType > &mat)
Convert the matrix from another matrix (with different structure)
Definition: ocl_matrix_csr.cpp:406
virtual void LUAnalyseClear(void)
Delete the analysed data (see LUAnalyse)
Definition: ocl_matrix_csr.cpp:855
OCLAcceleratorVector< ValueType > * tmp_vec_
Definition: ocl_matrix_csr.hpp:108
const IndexType const IndexType const IndexType const ValueType const ValueType scalar
Definition: cuda_kernels_coo.hpp:91
virtual void LLAnalyse(void)
Analyse the structure (level-scheduling)
Definition: ocl_matrix_csr.cpp:859
virtual void UAnalyseClear(void)
Delete the analysed data (see UAnalyse) U-party.
Definition: ocl_matrix_csr.cpp:879
virtual bool Scale(const ValueType alpha)
Scale all values.
Definition: ocl_matrix_csr.cpp:1809
virtual void Apply(const BaseVector< ValueType > &in, BaseVector< ValueType > *out) const
Apply the matrix to vector, out = this*in;.
Definition: ocl_matrix_csr.cpp:719
virtual bool ExtractL(BaseMatrix< ValueType > *L) const
Extract the lower triangular matrix.
Definition: ocl_matrix_csr.cpp:1143
virtual bool Compress(const double drop_off)
Delete all entries abs(a_ij) <= drop_off; the diagonal elements are never deleted.
Definition: ocl_matrix_csr.cpp:2301
virtual void UAnalyse(const bool diag_unit=false)
Analyse the structure (level-scheduling) U-part; diag_unit == true the diag is 1; diag_unit == false ...
Definition: ocl_matrix_csr.cpp:871
OCLAcceleratorMatrixCSR()
Definition: ocl_matrix_csr.cpp:27
virtual void AllocateCSR(const int nnz, const int nrow, const int ncol)
Allocate CSR Matrix.
Definition: ocl_matrix_csr.cpp:68
virtual bool ReplaceColumnVector(const int idx, const BaseVector< ValueType > &vec)
Replace a column vector of a matrix.
Definition: ocl_matrix_csr.cpp:2431
virtual bool DiagonalMatrixMultL(const BaseVector< ValueType > &diag)
Multiply the matrix with diagonal matrix (stored in LocalVector), this=diag*this (left multiplication...
Definition: ocl_matrix_csr.cpp:2172
virtual void CopyTo(BaseMatrix< ValueType > *mat) const
Copy to another matrix.
Definition: ocl_matrix_csr.cpp:343
virtual bool ExtractDiagonal(BaseVector< ValueType > *vec_diag) const
Extract the diagonal values of the matrix into a LocalVector.
Definition: ocl_matrix_csr.cpp:883
virtual bool ExtractSubMatrix(const int row_offset, const int col_offset, const int row_size, const int col_size, BaseMatrix< ValueType > *mat) const
Extrat a sub-matrix with row/col_offset and row/col_size.
Definition: ocl_matrix_csr.cpp:997
Base class for all host/accelerator matrices.
Definition: base_matrix.hpp:92
virtual bool ScaleOffDiagonal(const ValueType alpha)
Scale the off-diagonal entries of the matrix with alpha.
Definition: ocl_matrix_csr.cpp:1910
virtual unsigned int get_mat_format(void) const
Return the matrix format id (see matrix_formats.hpp)
Definition: ocl_matrix_csr.hpp:25
Definition: backend_manager.cpp:43
virtual bool AddScalar(const ValueType alpha)
Add alpha to all values.
Definition: ocl_matrix_csr.cpp:2066
MatrixCSR< cl_mem, cl_mem > mat_
Definition: ocl_matrix_csr.hpp:98
virtual void info(void) const
Shows simple info about the object.
Definition: ocl_matrix_csr.cpp:61
virtual bool MatrixAdd(const BaseMatrix< ValueType > &mat, const ValueType alpha, const ValueType beta, const bool structure)
Perform matrix addition, this = alpha*this + beta*mat; if structure==false the structure of the matri...
Definition: ocl_matrix_csr.cpp:2228
Definition: base_matrix.hpp:63
Definition: backend_manager.hpp:14
virtual void LAnalyse(const bool diag_unit=false)
Analyse the structure (level-scheduling) L-part diag_unit == true the diag is 1; diag_unit == false t...
Definition: ocl_matrix_csr.cpp:867
Definition: matrix_formats.hpp:21
virtual void LAnalyseClear(void)
Delete the analysed data (see LAnalyse) L-party.
Definition: ocl_matrix_csr.cpp:875
virtual void CopyFrom(const BaseMatrix< ValueType > &mat)
Copy from another matrix.
Definition: ocl_matrix_csr.cpp:282
virtual void CopyFromHost(const HostMatrix< ValueType > &src)
Copy (accelerator matrix) from host matrix.
Definition: ocl_matrix_csr.cpp:175
Definition: base_vector.hpp:19
virtual bool MultiColoring(int &num_colors, int **size_colors, BaseVector< int > *permutation) const
Perform multi-coloring decomposition of the matrix; Returns number of colors, the corresponding sizes...
Definition: ocl_matrix_csr.cpp:1720
virtual bool Zeros(void)
Set all the values to zero.
Definition: ocl_matrix_csr.cpp:147
virtual bool ExtractColumnVector(const int idx, BaseVector< ValueType > *vec) const
Extract values from a column of a matrix to a vector.
Definition: ocl_matrix_csr.cpp:2552
virtual void Clear(void)
Clear (free) the matrix.
Definition: ocl_matrix_csr.cpp:130
virtual bool ExtractU(BaseMatrix< ValueType > *U) const
Extract the upper triangular matrix.
Definition: ocl_matrix_csr.cpp:1391
virtual bool Permute(const BaseVector< int > &permutation)
Perform (forward) permutation of the matrix.
Definition: ocl_matrix_csr.cpp:419
virtual bool ExtractInverseDiagonal(BaseVector< ValueType > *vec_inv_diag) const
Extract the inverse (reciprocal) diagonal values of the matrix into a LocalVector.
Definition: ocl_matrix_csr.cpp:940
virtual bool ExtractLDiagonal(BaseMatrix< ValueType > *L) const
Extract the lower triangular matrix including diagonal.
Definition: ocl_matrix_csr.cpp:1267