18a729477SBarry Smith 23369ce9aSBarry Smith #if !defined(__MPIAIJ_H) 33369ce9aSBarry Smith #define __MPIAIJ_H 43369ce9aSBarry Smith 5c6db04a5SJed Brown #include <../src/mat/impls/aij/seq/aij.h> 68a729477SBarry Smith 790431a8fSHong Zhang typedef struct { /* used by MatCreateMPIAIJSumSeqAIJ for reusing the merged matrix */ 826283091SBarry Smith PetscLayout rowmap; 9de0260b3SHong Zhang PetscInt **buf_ri,**buf_rj; 100febcb4bSHong Zhang PetscMPIInt *len_s,*len_r,*id_r; /* array of length of comm->size, store send/recv matrix values */ 110febcb4bSHong Zhang PetscMPIInt nsend,nrecv; 12fc08c53fSHong Zhang PetscInt *bi,*bj; /* i and j array of the local portion of mpi C (matrix product) - rename to ci, cj! */ 13de0260b3SHong Zhang PetscInt *owners_co,*coi,*coj; /* i and j array of (p->B)^T*A*P - used in the communication */ 14dce485f0SBarry Smith PetscErrorCode (*destroy)(Mat); 15dce485f0SBarry Smith PetscErrorCode (*duplicate)(Mat,MatDuplicateOption,Mat*); 16b90dcfe3SHong Zhang } Mat_Merge_SeqsToMPI; 17b90dcfe3SHong Zhang 18a1a4e84aSHong Zhang typedef struct { /* used by MatPtAP_MPIAIJ_MPIAIJ() and MatMatMult_MPIAIJ_MPIAIJ() */ 19b7f45c76SHong Zhang PetscInt *startsj_s,*startsj_r; /* used by MatGetBrowsOfAoCols_MPIAIJ */ 20b7f45c76SHong Zhang PetscScalar *bufa; /* used by MatGetBrowsOfAoCols_MPIAIJ */ 21a1a4e84aSHong Zhang Mat P_loc,P_oth; /* partial B_seq -- intend to replace B_seq */ 22a1a4e84aSHong Zhang PetscInt *api,*apj; /* symbolic i and j arrays of the local product A_loc*B_seq */ 23d6ab1dc0SHong Zhang PetscInt rmax; /* max num of nnz in a local row of the matrix product */ 24b7f45c76SHong Zhang MatReuse reuse; /* flag to skip MatGetBrowsOfAoCols_MPIAIJ() and MatMPIAIJGetLocalMat() in 1st call of MatPtAPNumeric_MPIAIJ_MPIAIJ() */ 25598bc09dSHong Zhang PetscScalar *apa; /* tmp array for store a row of A*P used in MatMatMult() */ 26c5af039cSHong Zhang Mat A_loc; /* used by MatTransposeMatMult(), contains api and apj */ 27f8487c73SHong Zhang 28f8487c73SHong Zhang Mat_Merge_SeqsToMPI *merge; 29f8487c73SHong Zhang PetscErrorCode (*destroy)(Mat); 304ae0847bSHong Zhang PetscErrorCode (*duplicate)(Mat,MatDuplicateOption,Mat*); 31f8487c73SHong Zhang } Mat_PtAPMPI; 32f8487c73SHong Zhang 33f8487c73SHong Zhang typedef struct { 34f8487c73SHong Zhang Mat A,B; /* local submatrices: A (diag part), 35f8487c73SHong Zhang B (off-diag part) */ 36f8487c73SHong Zhang PetscMPIInt size; /* size of communicator */ 37f8487c73SHong Zhang PetscMPIInt rank; /* rank of proc in communicator */ 38f8487c73SHong Zhang 39f8487c73SHong Zhang /* The following variables are used for matrix assembly */ 40f8487c73SHong Zhang PetscBool donotstash; /* PETSC_TRUE if off processor entries dropped */ 41f8487c73SHong Zhang MPI_Request *send_waits; /* array of send requests */ 42f8487c73SHong Zhang MPI_Request *recv_waits; /* array of receive requests */ 43f8487c73SHong Zhang PetscInt nsends,nrecvs; /* numbers of sends and receives */ 44f8487c73SHong Zhang PetscScalar *svalues,*rvalues; /* sending and receiving data */ 45f8487c73SHong Zhang PetscInt rmax; /* maximum message length */ 46f8487c73SHong Zhang #if defined (PETSC_USE_CTABLE) 47f8487c73SHong Zhang PetscTable colmap; 48f8487c73SHong Zhang #else 49f8487c73SHong Zhang PetscInt *colmap; /* local col number of off-diag col */ 50f8487c73SHong Zhang #endif 51f8487c73SHong Zhang PetscInt *garray; /* global index of all off-processor columns */ 52f8487c73SHong Zhang 53f8487c73SHong Zhang /* The following variables are used for matrix-vector products */ 54f8487c73SHong Zhang Vec lvec; /* local vector */ 55f8487c73SHong Zhang Vec diag; 56f8487c73SHong Zhang VecScatter Mvctx; /* scatter context for vector */ 57f8487c73SHong Zhang PetscBool roworiented; /* if true, row-oriented input, default true */ 58f8487c73SHong Zhang 59f8487c73SHong Zhang /* The following variables are for MatGetRow() */ 60f8487c73SHong Zhang PetscInt *rowindices; /* column indices for row */ 61f8487c73SHong Zhang PetscScalar *rowvalues; /* nonzero values in row */ 62f8487c73SHong Zhang PetscBool getrowactive; /* indicates MatGetRow(), not restored */ 63f8487c73SHong Zhang 64f8487c73SHong Zhang /* Used by MatDistribute_MPIAIJ() to allow reuse of previous matrix allocation and nonzero pattern */ 65f8487c73SHong Zhang PetscInt *ld; /* number of entries per row left of diagona block */ 66f8487c73SHong Zhang 67a1a4e84aSHong Zhang /* Used by MatMatMult() and MatPtAP() */ 68f8487c73SHong Zhang Mat_PtAPMPI *ptap; 69ca45077fSPaul Mullowney 70*bbf3fe20SPaul Mullowney /* Used by MPICUSP and MPICUSPARSE classes */ 71*bbf3fe20SPaul Mullowney void * spptr; 72f8487c73SHong Zhang } Mat_MPIAIJ; 73f8487c73SHong Zhang 7409573ac7SBarry Smith extern PetscErrorCode MatSetColoring_MPIAIJ(Mat,ISColoring); 7509573ac7SBarry Smith extern PetscErrorCode MatSetValuesAdic_MPIAIJ(Mat,void*); 7609573ac7SBarry Smith extern PetscErrorCode MatSetValuesAdifor_MPIAIJ(Mat,PetscInt,void*); 7709573ac7SBarry Smith extern PetscErrorCode MatSetUpMultiply_MPIAIJ(Mat); 78ab9863d7SBarry Smith extern PetscErrorCode MatDisAssemble_MPIAIJ(Mat); 7909573ac7SBarry Smith extern PetscErrorCode MatDuplicate_MPIAIJ(Mat,MatDuplicateOption,Mat *); 8009573ac7SBarry Smith extern PetscErrorCode MatIncreaseOverlap_MPIAIJ(Mat,PetscInt,IS [],PetscInt); 8109573ac7SBarry Smith extern PetscErrorCode MatFDColoringCreate_MPIAIJ(Mat,ISColoring,MatFDColoring); 8209573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrices_MPIAIJ (Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]); 8309573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ_All(Mat,MatGetSubMatrixOption,MatReuse,Mat *[]); 8409573ac7SBarry Smith extern PetscErrorCode MatGetSubMatricesParallel_MPIAIJ (Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]); 855494a064SHong Zhang 8609573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ(Mat,IS,IS,MatReuse,Mat *); 8709573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ_Private (Mat,IS,IS,PetscInt,MatReuse,Mat *); 88fc08c53fSHong Zhang extern PetscErrorCode MatGetMultiProcBlock_MPIAIJ(Mat,MPI_Comm,MatReuse,Mat*); 89d6037b41SHong Zhang 9009573ac7SBarry Smith extern PetscErrorCode MatLoad_MPIAIJ(Mat,PetscViewer); 918cdbd757SHong Zhang extern PetscErrorCode MatMatMult_MPIDense_MPIAIJ(Mat,Mat,MatReuse,PetscReal,Mat*); 9209573ac7SBarry Smith extern PetscErrorCode MatMatMult_MPIAIJ_MPIAIJ(Mat,Mat,MatReuse,PetscReal,Mat*); 9309573ac7SBarry Smith extern PetscErrorCode MatMatMultSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*); 9425023028SHong Zhang extern PetscErrorCode MatMatMultSymbolic_MPIAIJ_MPIAIJ_Scalable(Mat,Mat,PetscReal,Mat*); 9509573ac7SBarry Smith extern PetscErrorCode MatMatMultNumeric_MPIAIJ_MPIAIJ(Mat,Mat,Mat); 96f8487c73SHong Zhang 9709573ac7SBarry Smith extern PetscErrorCode MatPtAPSymbolic_MPIAIJ(Mat,Mat,PetscReal,Mat*); 9809573ac7SBarry Smith extern PetscErrorCode MatPtAPNumeric_MPIAIJ(Mat,Mat,Mat); 9909573ac7SBarry Smith extern PetscErrorCode MatPtAPSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*); 10009573ac7SBarry Smith extern PetscErrorCode MatPtAPNumeric_MPIAIJ_MPIAIJ(Mat,Mat,Mat); 101c5af039cSHong Zhang extern PetscErrorCode MatDestroy_MPIAIJ_PtAP(Mat); 102*bbf3fe20SPaul Mullowney extern PetscErrorCode MatDestroy_MPIAIJ(Mat); 103c5af039cSHong Zhang 104f8487c73SHong Zhang extern PetscErrorCode MatGetBrowsOfAoCols_MPIAIJ(Mat,Mat,MatReuse,PetscInt**,PetscInt**,MatScalar**,Mat*); 10509573ac7SBarry Smith extern PetscErrorCode MatSetValues_MPIAIJ(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar [],InsertMode); 10609573ac7SBarry Smith extern PetscErrorCode MatDestroy_MPIAIJ_MatMatMult(Mat); 10709573ac7SBarry Smith extern PetscErrorCode PetscContainerDestroy_Mat_MatMatMultMPI(void*); 108ca45077fSPaul Mullowney extern PetscErrorCode MatSetOption_MPIAIJ(Mat,MatOption,PetscBool); 109187b3c17SHong Zhang 110187b3c17SHong Zhang extern PetscErrorCode MatTransposeMatMult_MPIAIJ_MPIAIJ(Mat,Mat,MatReuse,PetscReal,Mat*); 111187b3c17SHong Zhang extern PetscErrorCode MatTransposeMatMultSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*); 112d6ab1dc0SHong Zhang extern PetscErrorCode MatTransposeMatMultSymbolic_MPIAIJ_MPIAIJ_Scalable(Mat,Mat,PetscReal,Mat*); 113187b3c17SHong Zhang extern PetscErrorCode MatTransposeMatMultNumeric_MPIAIJ_MPIAIJ(Mat,Mat,Mat); 114187b3c17SHong Zhang 11509573ac7SBarry Smith extern PetscErrorCode MatGetRedundantMatrix_MPIAIJ(Mat,PetscInt,MPI_Comm,PetscInt,MatReuse,Mat*); 11609573ac7SBarry Smith extern PetscErrorCode MatGetSeqNonzeroStructure_MPIAIJ(Mat,Mat*); 117c0d3702cSSatish Balay 1181472f72bSBarry Smith EXTERN_C_BEGIN 11909573ac7SBarry Smith extern PetscErrorCode MatMPIAIJSetPreallocation_MPIAIJ(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 1201472f72bSBarry Smith EXTERN_C_END 1213a7fca6bSBarry Smith 122ce63c4c1SBarry Smith #if !defined(PETSC_USE_COMPLEX) && !defined(PETSC_USE_REAL_SINGLE) && !defined(PETSC_USE_REAL___FLOAT128) 12309573ac7SBarry Smith extern PetscErrorCode MatLUFactorSymbolic_MPIAIJ_TFS(Mat,IS,IS,const MatFactorInfo*,Mat*); 12497304618SKris Buschelman #endif 12509573ac7SBarry Smith extern PetscErrorCode MatSolve_MPIAIJ(Mat,Vec,Vec); 12609573ac7SBarry Smith extern PetscErrorCode MatILUFactor_MPIAIJ(Mat,IS,IS,const MatFactorInfo *); 12797304618SKris Buschelman 12897304618SKris Buschelman EXTERN_C_BEGIN 12911bd1e4dSLisandro Dalcin extern PetscErrorCode MatGetDiagonalBlock_MPIAIJ(Mat,Mat *); 1307087cfbeSBarry Smith extern PetscErrorCode MatDiagonalScaleLocal_MPIAIJ(Mat,Vec); 13197304618SKris Buschelman EXTERN_C_END 1323a7fca6bSBarry Smith 1333369ce9aSBarry Smith #endif 134