xref: /petsc/src/mat/impls/aij/seq/seqcusparse/cusparsematimpl.h (revision bda325fc0240382711f851b474bdfd563aac9e05)
1519f805aSKarl Rupp #if !defined(__CUSPARSEMATIMPL)
29ae82921SPaul Mullowney #define __CUSPARSEMATIMPL
39ae82921SPaul Mullowney 
49ae82921SPaul Mullowney #include <../src/vec/vec/impls/seq/seqcusp/cuspvecimpl.h>
59ae82921SPaul Mullowney 
69ae82921SPaul Mullowney #include <cusparse_v2.h>
79ae82921SPaul Mullowney 
89ae82921SPaul Mullowney /* New Way */
99ae82921SPaul Mullowney #include "tx_sparse_interface.h"
109ae82921SPaul Mullowney 
119ae82921SPaul Mullowney #include <algorithm>
129ae82921SPaul Mullowney #include <vector>
139ae82921SPaul Mullowney #include <string>
149ae82921SPaul Mullowney #include <thrust/sort.h>
159ae82921SPaul Mullowney #include <thrust/fill.h>
169ae82921SPaul Mullowney 
1757eb53cdSKarl Rupp /* Single instance of the cusparse handle for the class. */
189ae82921SPaul Mullowney cusparseHandle_t MAT_cusparseHandle=0;
199ae82921SPaul Mullowney 
20e057df02SPaul Mullowney MatCUSPARSEStorageFormat cusparseMatSolveStorageFormat=MAT_CUSPARSE_CSR;
21e057df02SPaul Mullowney 
229ae82921SPaul Mullowney struct Mat_SeqAIJCUSPARSETriFactors {
239ae82921SPaul Mullowney   GPU_Matrix_Ifc           *loTriFactorPtr; /* pointer for lower triangular (factored matrix) on GPU */
249ae82921SPaul Mullowney   GPU_Matrix_Ifc           *upTriFactorPtr; /* pointer for upper triangular (factored matrix) on GPU */
259ae82921SPaul Mullowney   CUSPARRAY                *tempvec;
26e057df02SPaul Mullowney   MatCUSPARSEStorageFormat format;   /* the storage format for the matrix on the device */
27*bda325fcSPaul Mullowney   PetscBool hasTranspose; /* boolean describing whether a transpose has been built or not */
289ae82921SPaul Mullowney };
299ae82921SPaul Mullowney 
309ae82921SPaul Mullowney struct Mat_SeqAIJCUSPARSE {
319ae82921SPaul Mullowney   GPU_Matrix_Ifc           *mat; /* pointer to the matrix on the GPU */
329ae82921SPaul Mullowney   CUSPARRAY                *tempvec; /*pointer to a workvector to which we can copy the relevant indices of a vector we want to multiply */
339ae82921SPaul Mullowney   PetscInt                 nonzerorow; /* number of nonzero rows ... used in the flop calculations */
34e057df02SPaul Mullowney   MatCUSPARSEStorageFormat format;   /* the storage format for the matrix on the device */
35*bda325fcSPaul Mullowney   PetscBool hasTranspose; /* boolean describing whether a transpose has been built or not */
369ae82921SPaul Mullowney };
379ae82921SPaul Mullowney 
389ae82921SPaul Mullowney extern PetscErrorCode MatCUSPARSECopyToGPU(Mat);
3957eb53cdSKarl Rupp /* extern PetscErrorCode MatGetFactor_seqaij_cusparse(Mat,MatFactorType,Mat*); */
4057eb53cdSKarl Rupp /* extern PetscErrorCode MatFactorGetSolverPackage_seqaij_cusparse(Mat,const MatSolverPackage *); */
4157eb53cdSKarl Rupp /* extern PetscErrorCode MatCUSPARSECopyFromGPU(Mat, CUSPMATRIX *); */
429ae82921SPaul Mullowney #endif
43