2 #ifndef PARALUTION_GPU_MATRIX_CSR_HPP_
3 #define PARALUTION_GPU_MATRIX_CSR_HPP_
5 #include "../base_matrix.hpp"
6 #include "../base_vector.hpp"
7 #include "../matrix_formats.hpp"
10 #include <cusparse_v2.h>
14 template <
typename ValueType>
15 class GPUAcceleratorMatrixCSR :
public GPUAcceleratorMatrix<ValueType> {
23 virtual void info(
void)
const;
26 virtual void Clear(
void);
27 virtual bool Zeros(
void);
29 virtual void AllocateCSR(
const int nnz,
const int nrow,
const int ncol);
30 virtual void SetDataPtrCSR(
int **row_offset,
int **col, ValueType **val,
31 const int nnz,
const int nrow,
const int ncol);
32 virtual void LeaveDataPtrCSR(
int **row_offset,
int **col, ValueType **val);
46 virtual void CopyFromCSR(
const int *row_offsets,
const int *col,
const ValueType *val);
47 virtual void CopyToCSR(
int *row_offsets,
int *col, ValueType *val)
const;
51 virtual bool Scale(
const ValueType alpha);
54 virtual bool AddScalar(
const ValueType alpha);
84 const ValueType beta,
const bool structure);
101 virtual void LAnalyse(
const bool diag_unit=
false);
105 virtual void UAnalyse(
const bool diag_unit=
false);
110 virtual bool Gershgorin(ValueType &lambda_min,
111 ValueType &lambda_max)
const;
117 virtual bool Compress(
const double drop_off);
150 #endif // PARALUTION_GPU_MATRIX_CSR_HPP_
A
Definition: pcg_example.m:10
virtual void CopyFromHostAsync(const HostMatrix< ValueType > &src)
Async copy (accelerator matrix) from host matrix.
virtual void info(void) const
Shows simple info about the object.
virtual bool LUSolve(const BaseVector< ValueType > &in, BaseVector< ValueType > *out) const
Solve LU out = in; if level-scheduling algorithm is provided then the graph traversing is performed i...
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...
virtual void CopyToHost(HostMatrix< ValueType > *dst) const
Copy (accelerator matrix) to host matrix.
virtual bool Transpose(void)
Transpose the matrix.
Definition: base_matrix.hpp:44
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;.
virtual bool Zeros(void)
Set all the values to zero.
const IndexType idx
Definition: cuda_kernels_coo.hpp:115
virtual void LLAnalyseClear(void)
Delete the analysed data (see LLAnalyse)
virtual bool DiagonalMatrixMultR(const BaseVector< ValueType > &diag)
Multiply the matrix with diagonal matrix (stored in LocalVector), this=this*diag (right multiplicatio...
virtual void SetDataPtrCSR(int **row_offset, int **col, ValueType **val, const int nnz, const int nrow, const int ncol)
Initialize a CSR matrix on the Host with externally allocated data.
virtual void LeaveDataPtrCSR(int **row_offset, int **col, ValueType **val)
Leave a CSR matrix to Host pointers.
virtual bool AddScalarOffDiagonal(const ValueType alpha)
Add alpha to the off-diagonal entries of the matrix.
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: backend_manager.hpp:10
cusparseMatDescr_t L_mat_descr_
Definition: gpu_matrix_csr.hpp:139
virtual bool MatMatMult(const BaseMatrix< ValueType > &A, const BaseMatrix< ValueType > &B)
Multiply two matrices, this = A * B.
Definition: base_vector.hpp:16
nnz
Definition: pcg_example.m:8
cusparseMatDescr_t U_mat_descr_
Definition: gpu_matrix_csr.hpp:140
MatrixCSR< ValueType, int > mat_
Definition: gpu_matrix_csr.hpp:127
const IndexType const IndexType const IndexType const ValueType const ValueType scalar
Definition: cuda_kernels_coo.hpp:91
virtual bool ScaleOffDiagonal(const ValueType alpha)
Scale the off-diagonal entries of the matrix with alpha.
virtual void Apply(const BaseVector< ValueType > &in, BaseVector< ValueType > *out) const
Apply the matrix to vector, out = this*in;.
virtual bool DiagonalMatrixMultL(const BaseVector< ValueType > &diag)
Multiply the matrix with diagonal matrix (stored in LocalVector), this=diag*this (left multiplication...
virtual void LUAnalyse(void)
Analyse the structure (level-scheduling)
virtual bool ExtractL(BaseMatrix< ValueType > *L) const
Extract the lower triangular matrix.
virtual bool ScaleDiagonal(const ValueType alpha)
Scale the diagonal entries of the matrix with alpha.
virtual bool Gershgorin(ValueType &lambda_min, ValueType &lambda_max) const
Compute the spectrum approximation with Gershgorin circles theorem.
virtual bool ICFactorize(BaseVector< ValueType > *inv_diag=NULL)
Perform IC(0) factorization.
virtual void LLAnalyse(void)
Analyse the structure (level-scheduling)
virtual bool ExtractUDiagonal(BaseMatrix< ValueType > *U) const
Extract the upper triangular matrix including diagonal.
virtual void CopyFrom(const BaseMatrix< ValueType > &mat)
Copy from another matrix.
virtual void UAnalyseClear(void)
Delete the analysed data (see UAnalyse) U-party.
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 ...
virtual void Clear(void)
Clear (free) the matrix.
virtual void CopyToHostAsync(HostMatrix< ValueType > *dst) const
Async opy (accelerator matrix) to host matrix.
virtual void CopyFromCSR(const int *row_offsets, const int *col, const ValueType *val)
Copy from CSR array (the matrix has to be allocated)
virtual bool Compress(const double drop_off)
Delete all entries abs(a_ij) <= drop_off; the diagonal elements are never deleted.
virtual unsigned int get_mat_format(void) const
Return the matrix format id (see matrix_formats.hpp)
Definition: gpu_matrix_csr.hpp:24
virtual bool ExtractLDiagonal(BaseMatrix< ValueType > *L) const
Extract the lower triangular matrix including diagonal.
virtual bool Permute(const BaseVector< int > &permutation)
Perform (forward) permutation of the matrix.
virtual bool ConvertFrom(const BaseMatrix< ValueType > &mat)
Convert the matrix from another matrix (with different structure)
virtual bool MaximalIndependentSet(int &size, BaseVector< int > *permutation) const
Perform maximal independent set decomposition of the matrix; Returns the size of the maximal independ...
Base class for all host/accelerator matrices.
Definition: base_matrix.hpp:92
cusparseSolveAnalysisInfo_t L_mat_info_
Definition: gpu_matrix_csr.hpp:137
virtual void CopyToCSR(int *row_offsets, int *col, ValueType *val) const
Copy to CSR array (the arrays have to be allocated)
virtual bool Scale(const ValueType alpha)
Scale all values.
cusparseMatDescr_t mat_descr_
Definition: gpu_matrix_csr.hpp:141
virtual bool LLSolve(const BaseVector< ValueType > &in, BaseVector< ValueType > *out) const
Solve LL^T out = in; if level-scheduling algorithm is provided then the graph.
GPUAcceleratorMatrixCSR()
Definition: backend_manager.cpp:43
GPUAcceleratorVector< ValueType > * tmp_vec_
Definition: gpu_matrix_csr.hpp:143
virtual void CopyTo(BaseMatrix< ValueType > *mat) const
Copy to another matrix.
virtual bool USolve(const BaseVector< ValueType > &in, BaseVector< ValueType > *out) const
Solve U out = in; if level-scheduling algorithm is provided then the graph traversing is performed in...
virtual bool AddScalarDiagonal(const ValueType alpha)
Add alpha to the diagonal entries of the matrix.
Definition: backend_manager.hpp:14
Definition: matrix_formats.hpp:21
virtual bool ILU0Factorize(void)
Perform ILU(0) factorization.
virtual void CopyFromAsync(const BaseMatrix< ValueType > &mat)
Async copy from another matrix.
virtual void AllocateCSR(const int nnz, const int nrow, const int ncol)
Allocate CSR Matrix.
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: base_matrix.hpp:46
virtual bool ExtractColumnVector(const int idx, BaseVector< ValueType > *vec) const
Extract values from a column of a matrix to a vector.
virtual bool ExtractInverseDiagonal(BaseVector< ValueType > *vec_inv_diag) const
Extract the inverse (reciprocal) diagonal values of the matrix into a LocalVector.
virtual bool ReplaceColumnVector(const int idx, const BaseVector< ValueType > &vec)
Replace a column vector of a matrix.
virtual ~GPUAcceleratorMatrixCSR()
virtual bool ExtractDiagonal(BaseVector< ValueType > *vec_diag) const
Extract the diagonal values of the matrix into a LocalVector.
virtual bool LSolve(const BaseVector< ValueType > &in, BaseVector< ValueType > *out) const
Solve L out = in; if level-scheduling algorithm is provided then the graph traversing is performed in...
virtual void LUAnalyseClear(void)
Delete the analysed data (see LUAnalyse)
virtual void LAnalyseClear(void)
Delete the analysed data (see LAnalyse) L-party.
virtual void CopyFromHost(const HostMatrix< ValueType > &src)
Copy (accelerator matrix) from host matrix.
Definition: base_matrix.hpp:48
virtual void CopyToAsync(BaseMatrix< ValueType > *mat) const
Copy to another matrix.
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.
virtual bool AddScalar(const ValueType alpha)
Add alpha to all values.
virtual bool ExtractRowVector(const int idx, BaseVector< ValueType > *vec) const
Extract values from a row of a matrix to a vector.
cusparseSolveAnalysisInfo_t U_mat_info_
Definition: gpu_matrix_csr.hpp:138
virtual bool ExtractU(BaseMatrix< ValueType > *U) const
Extract the upper triangular matrix.