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 7a1a4e84aSHong Zhang typedef struct { /* used by MatMatMult_MPIAIJ_MPIAIJ_32 - implementation used in PETSc-3.2 */ 8*f639d13fSHong Zhang /* used by MatMatMult_MPIAIJ_MPIAIJ() */ 9*f639d13fSHong Zhang IS isrowa,isrowb,iscolb; 10*f639d13fSHong Zhang Mat B_seq,A_loc,C_seq; 11dce485f0SBarry Smith PetscErrorCode (*destroy)(Mat); 12dce485f0SBarry Smith PetscErrorCode (*duplicate)(Mat,MatDuplicateOption,Mat*); 13ff134f7aSHong Zhang } Mat_MatMatMultMPI; 14ff134f7aSHong Zhang 15a1a4e84aSHong Zhang typedef struct { /* used by MatMerge_SeqsToMPI for reusing the merged matrix - implementation used in PETSc-3.2 */ 1626283091SBarry Smith PetscLayout rowmap; 17de0260b3SHong Zhang PetscInt **buf_ri,**buf_rj; 180febcb4bSHong Zhang PetscMPIInt *len_s,*len_r,*id_r; /* array of length of comm->size, store send/recv matrix values */ 190febcb4bSHong Zhang PetscMPIInt nsend,nrecv; 20de0260b3SHong Zhang PetscInt *bi,*bj; /* i and j array of the local portion of mpi C=P^T*A*P */ 21de0260b3SHong Zhang PetscInt *owners_co,*coi,*coj; /* i and j array of (p->B)^T*A*P - used in the communication */ 22dce485f0SBarry Smith PetscErrorCode (*destroy)(Mat); 23dce485f0SBarry Smith PetscErrorCode (*duplicate)(Mat,MatDuplicateOption,Mat*); 24b90dcfe3SHong Zhang } Mat_Merge_SeqsToMPI; 25b90dcfe3SHong Zhang 26a1a4e84aSHong Zhang typedef struct { /* used by MatPtAP_MPIAIJ_MPIAIJ() and MatMatMult_MPIAIJ_MPIAIJ() */ 27f8487c73SHong Zhang PetscInt *startsj,*startsj_r; 28f8487c73SHong Zhang PetscScalar *bufa; 29a1a4e84aSHong Zhang Mat P_loc,P_oth; /* partial B_seq -- intend to replace B_seq */ 30a1a4e84aSHong Zhang PetscInt *api,*apj; /* symbolic i and j arrays of the local product A_loc*B_seq */ 31f8487c73SHong Zhang PetscInt abnz_max; /* max(abi[i+1] - abi[i]), max num of nnz in a row of A_loc*B_seq */ 32f8487c73SHong Zhang MatReuse reuse; 33598bc09dSHong Zhang PetscScalar *apa; /* tmp array for store a row of A*P used in MatMatMult() */ 34f8487c73SHong Zhang 35f8487c73SHong Zhang Mat_Merge_SeqsToMPI *merge; 36f8487c73SHong Zhang PetscErrorCode (*destroy)(Mat); 374ae0847bSHong Zhang PetscErrorCode (*duplicate)(Mat,MatDuplicateOption,Mat*); 38f8487c73SHong Zhang } Mat_PtAPMPI; 39f8487c73SHong Zhang 40f8487c73SHong Zhang typedef struct { 41f8487c73SHong Zhang Mat A,B; /* local submatrices: A (diag part), 42f8487c73SHong Zhang B (off-diag part) */ 43f8487c73SHong Zhang PetscMPIInt size; /* size of communicator */ 44f8487c73SHong Zhang PetscMPIInt rank; /* rank of proc in communicator */ 45f8487c73SHong Zhang 46f8487c73SHong Zhang /* The following variables are used for matrix assembly */ 47f8487c73SHong Zhang PetscBool donotstash; /* PETSC_TRUE if off processor entries dropped */ 48f8487c73SHong Zhang MPI_Request *send_waits; /* array of send requests */ 49f8487c73SHong Zhang MPI_Request *recv_waits; /* array of receive requests */ 50f8487c73SHong Zhang PetscInt nsends,nrecvs; /* numbers of sends and receives */ 51f8487c73SHong Zhang PetscScalar *svalues,*rvalues; /* sending and receiving data */ 52f8487c73SHong Zhang PetscInt rmax; /* maximum message length */ 53f8487c73SHong Zhang #if defined (PETSC_USE_CTABLE) 54f8487c73SHong Zhang PetscTable colmap; 55f8487c73SHong Zhang #else 56f8487c73SHong Zhang PetscInt *colmap; /* local col number of off-diag col */ 57f8487c73SHong Zhang #endif 58f8487c73SHong Zhang PetscInt *garray; /* global index of all off-processor columns */ 59f8487c73SHong Zhang 60f8487c73SHong Zhang /* The following variables are used for matrix-vector products */ 61f8487c73SHong Zhang Vec lvec; /* local vector */ 62f8487c73SHong Zhang Vec diag; 63f8487c73SHong Zhang VecScatter Mvctx; /* scatter context for vector */ 64f8487c73SHong Zhang PetscBool roworiented; /* if true, row-oriented input, default true */ 65f8487c73SHong Zhang 66f8487c73SHong Zhang /* The following variables are for MatGetRow() */ 67f8487c73SHong Zhang PetscInt *rowindices; /* column indices for row */ 68f8487c73SHong Zhang PetscScalar *rowvalues; /* nonzero values in row */ 69f8487c73SHong Zhang PetscBool getrowactive; /* indicates MatGetRow(), not restored */ 70f8487c73SHong Zhang 71f8487c73SHong Zhang /* Used by MatDistribute_MPIAIJ() to allow reuse of previous matrix allocation and nonzero pattern */ 72f8487c73SHong Zhang PetscInt *ld; /* number of entries per row left of diagona block */ 73f8487c73SHong Zhang 74a1a4e84aSHong Zhang /* Used by MatMatMult() and MatPtAP() */ 75f8487c73SHong Zhang Mat_PtAPMPI *ptap; 76f8487c73SHong Zhang } Mat_MPIAIJ; 77f8487c73SHong Zhang 7809573ac7SBarry Smith extern PetscErrorCode MatSetColoring_MPIAIJ(Mat,ISColoring); 7909573ac7SBarry Smith extern PetscErrorCode MatSetValuesAdic_MPIAIJ(Mat,void*); 8009573ac7SBarry Smith extern PetscErrorCode MatSetValuesAdifor_MPIAIJ(Mat,PetscInt,void*); 8109573ac7SBarry Smith extern PetscErrorCode MatSetUpMultiply_MPIAIJ(Mat); 8209573ac7SBarry Smith extern PetscErrorCode DisAssemble_MPIAIJ(Mat); 8309573ac7SBarry Smith extern PetscErrorCode MatDuplicate_MPIAIJ(Mat,MatDuplicateOption,Mat *); 8409573ac7SBarry Smith extern PetscErrorCode MatIncreaseOverlap_MPIAIJ(Mat,PetscInt,IS [],PetscInt); 8509573ac7SBarry Smith extern PetscErrorCode MatFDColoringCreate_MPIAIJ(Mat,ISColoring,MatFDColoring); 8609573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrices_MPIAIJ (Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]); 8709573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ_All(Mat,MatGetSubMatrixOption,MatReuse,Mat *[]); 8809573ac7SBarry Smith extern PetscErrorCode MatGetSubMatricesParallel_MPIAIJ (Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]); 895494a064SHong Zhang 9009573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ(Mat,IS,IS,MatReuse,Mat *); 9109573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ_Private (Mat,IS,IS,PetscInt,MatReuse,Mat *); 9209573ac7SBarry Smith extern PetscErrorCode MatGetMultiProcBlock_MPIAIJ(Mat,MPI_Comm,Mat*); 93d6037b41SHong Zhang 9409573ac7SBarry Smith extern PetscErrorCode MatLoad_MPIAIJ(Mat,PetscViewer); 958cdbd757SHong Zhang extern PetscErrorCode MatMatMult_MPIDense_MPIAIJ(Mat,Mat,MatReuse,PetscReal,Mat*); 9609573ac7SBarry Smith extern PetscErrorCode MatMatMult_MPIAIJ_MPIAIJ(Mat,Mat,MatReuse,PetscReal,Mat*); 9709573ac7SBarry Smith extern PetscErrorCode MatMatMultSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*); 9809573ac7SBarry Smith extern PetscErrorCode MatMatMultNumeric_MPIAIJ_MPIAIJ(Mat,Mat,Mat); 99f8487c73SHong Zhang 10009573ac7SBarry Smith extern PetscErrorCode MatPtAPSymbolic_MPIAIJ(Mat,Mat,PetscReal,Mat*); 10109573ac7SBarry Smith extern PetscErrorCode MatPtAPNumeric_MPIAIJ(Mat,Mat,Mat); 10209573ac7SBarry Smith extern PetscErrorCode MatPtAPSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*); 10309573ac7SBarry Smith extern PetscErrorCode MatPtAPNumeric_MPIAIJ_MPIAIJ(Mat,Mat,Mat); 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); 107a1a4e84aSHong Zhang extern PetscErrorCode MatDestroy_MPIAIJ_MatMatMult_32(Mat); 10809573ac7SBarry Smith extern PetscErrorCode PetscContainerDestroy_Mat_MatMatMultMPI(void*); 10909573ac7SBarry Smith extern PetscErrorCode MatGetRedundantMatrix_MPIAIJ(Mat,PetscInt,MPI_Comm,PetscInt,MatReuse,Mat*); 11009573ac7SBarry Smith extern PetscErrorCode MatGetSeqNonzeroStructure_MPIAIJ(Mat,Mat*); 111c0d3702cSSatish Balay 1121472f72bSBarry Smith EXTERN_C_BEGIN 11309573ac7SBarry Smith extern PetscErrorCode MatMPIAIJSetPreallocation_MPIAIJ(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 1141472f72bSBarry Smith EXTERN_C_END 1153a7fca6bSBarry Smith 116ce63c4c1SBarry Smith #if !defined(PETSC_USE_COMPLEX) && !defined(PETSC_USE_REAL_SINGLE) && !defined(PETSC_USE_REAL___FLOAT128) 11709573ac7SBarry Smith extern PetscErrorCode MatLUFactorSymbolic_MPIAIJ_TFS(Mat,IS,IS,const MatFactorInfo*,Mat*); 11897304618SKris Buschelman #endif 11909573ac7SBarry Smith extern PetscErrorCode MatSolve_MPIAIJ(Mat,Vec,Vec); 12009573ac7SBarry Smith extern PetscErrorCode MatILUFactor_MPIAIJ(Mat,IS,IS,const MatFactorInfo *); 12197304618SKris Buschelman 12297304618SKris Buschelman EXTERN_C_BEGIN 12311bd1e4dSLisandro Dalcin extern PetscErrorCode MatGetDiagonalBlock_MPIAIJ(Mat,Mat *); 1247087cfbeSBarry Smith extern PetscErrorCode MatDiagonalScaleLocal_MPIAIJ(Mat,Vec); 12597304618SKris Buschelman EXTERN_C_END 1263a7fca6bSBarry Smith 1273369ce9aSBarry Smith #endif 128