xref: /petsc/src/mat/impls/aij/seq/seqcusparse/cusparsematimpl.h (revision 519f805a543c2a7f195bcba21173bb2cdfadb956)
1*519f805aSKarl 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 */
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 */
349ae82921SPaul Mullowney };
359ae82921SPaul Mullowney 
369ae82921SPaul Mullowney extern PetscErrorCode MatCUSPARSECopyToGPU(Mat);
3757eb53cdSKarl Rupp /* extern PetscErrorCode MatGetFactor_seqaij_cusparse(Mat,MatFactorType,Mat*); */
3857eb53cdSKarl Rupp /* extern PetscErrorCode MatFactorGetSolverPackage_seqaij_cusparse(Mat,const MatSolverPackage *); */
3957eb53cdSKarl Rupp /* extern PetscErrorCode MatCUSPARSECopyFromGPU(Mat, CUSPMATRIX *); */
409ae82921SPaul Mullowney #endif
41