xref: /petsc/src/mat/impls/aij/seq/seqcusparse/cusparsematimpl.h (revision 5a5764247e8e42b2972d2371d5c619b20bcb2a28)
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 <thrust/sort.h>
149ae82921SPaul Mullowney #include <thrust/fill.h>
159ae82921SPaul Mullowney 
1657eb53cdSKarl Rupp /* Single instance of the cusparse handle for the class. */
179ae82921SPaul Mullowney cusparseHandle_t MAT_cusparseHandle=0;
189ae82921SPaul Mullowney 
19e057df02SPaul Mullowney MatCUSPARSEStorageFormat cusparseMatSolveStorageFormat=MAT_CUSPARSE_CSR;
20e057df02SPaul Mullowney 
219ae82921SPaul Mullowney struct Mat_SeqAIJCUSPARSETriFactors {
229ae82921SPaul Mullowney   GPU_Matrix_Ifc           *loTriFactorPtr; /* pointer for lower triangular (factored matrix) on GPU */
239ae82921SPaul Mullowney   GPU_Matrix_Ifc           *upTriFactorPtr; /* pointer for upper triangular (factored matrix) on GPU */
249ae82921SPaul Mullowney   CUSPARRAY                *tempvec;
25e057df02SPaul Mullowney   MatCUSPARSEStorageFormat format;   /* the storage format for the matrix on the device */
26bda325fcSPaul Mullowney   PetscBool hasTranspose; /* boolean describing whether a transpose has been built or not */
279ae82921SPaul Mullowney };
289ae82921SPaul Mullowney 
299ae82921SPaul Mullowney struct Mat_SeqAIJCUSPARSE {
309ae82921SPaul Mullowney   GPU_Matrix_Ifc           *mat; /* pointer to the matrix on the GPU */
319ae82921SPaul Mullowney   CUSPARRAY                *tempvec; /*pointer to a workvector to which we can copy the relevant indices of a vector we want to multiply */
329ae82921SPaul Mullowney   PetscInt                 nonzerorow; /* number of nonzero rows ... used in the flop calculations */
33e057df02SPaul Mullowney   MatCUSPARSEStorageFormat format;   /* the storage format for the matrix on the device */
34bda325fcSPaul Mullowney   PetscBool hasTranspose; /* boolean describing whether a transpose has been built or not */
359ae82921SPaul Mullowney };
369ae82921SPaul Mullowney 
37*5a576424SJed Brown PETSC_INTERN PetscErrorCode MatCUSPARSECopyToGPU(Mat);
38*5a576424SJed Brown /* PETSC_INTERN PetscErrorCode MatGetFactor_seqaij_cusparse(Mat,MatFactorType,Mat*); */
39*5a576424SJed Brown /* PETSC_INTERN PetscErrorCode MatFactorGetSolverPackage_seqaij_cusparse(Mat,const MatSolverPackage *); */
40*5a576424SJed Brown /* PETSC_INTERN PetscErrorCode MatCUSPARSECopyFromGPU(Mat, CUSPMATRIX *); */
419ae82921SPaul Mullowney #endif
42