18a729477SBarry Smith 23369ce9aSBarry Smith #if !defined(__MPIAIJ_H) 33369ce9aSBarry Smith #define __MPIAIJ_H 43369ce9aSBarry Smith 57c4f633dSBarry Smith #include "../src/mat/impls/aij/seq/aij.h" 67c4f633dSBarry Smith #include "../src/sys/ctable.h" 78a729477SBarry Smith 88a729477SBarry Smith typedef struct { 98c386bf4SBarry Smith Mat A,B; /* local submatrices: A (diag part), 108c386bf4SBarry Smith B (off-diag part) */ 1197f1f81fSBarry Smith PetscMPIInt size; /* size of communicator */ 1297f1f81fSBarry Smith PetscMPIInt rank; /* rank of proc in communicator */ 138c386bf4SBarry Smith 148c386bf4SBarry Smith /* The following variables are used for matrix assembly */ 158c386bf4SBarry Smith 16ace3abfcSBarry Smith PetscBool donotstash; /* PETSC_TRUE if off processor entries dropped */ 178c386bf4SBarry Smith MPI_Request *send_waits; /* array of send requests */ 188c386bf4SBarry Smith MPI_Request *recv_waits; /* array of receive requests */ 1997f1f81fSBarry Smith PetscInt nsends,nrecvs; /* numbers of sends and receives */ 20ea709b57SSatish Balay PetscScalar *svalues,*rvalues; /* sending and receiving data */ 2197f1f81fSBarry Smith PetscInt rmax; /* maximum message length */ 22ac2a4f0dSBarry Smith #if defined (PETSC_USE_CTABLE) 23ac2a4f0dSBarry Smith PetscTable colmap; 2432b39ab2SSatish Balay #else 2597f1f81fSBarry Smith PetscInt *colmap; /* local col number of off-diag col */ 2632b39ab2SSatish Balay #endif 2797f1f81fSBarry Smith PetscInt *garray; /* global index of all off-processor columns */ 288c386bf4SBarry Smith 298c386bf4SBarry Smith /* The following variables are used for matrix-vector products */ 308c386bf4SBarry Smith 318c386bf4SBarry Smith Vec lvec; /* local vector */ 32a7420bb7SBarry Smith Vec diag; 338c386bf4SBarry Smith VecScatter Mvctx; /* scatter context for vector */ 34ace3abfcSBarry Smith PetscBool roworiented; /* if true, row-oriented input, default true */ 353369ce9aSBarry Smith 363369ce9aSBarry Smith /* The following variables are for MatGetRow() */ 373369ce9aSBarry Smith 38b1d57f15SBarry Smith PetscInt *rowindices; /* column indices for row */ 39ea709b57SSatish Balay PetscScalar *rowvalues; /* nonzero values in row */ 40ace3abfcSBarry Smith PetscBool getrowactive; /* indicates MatGetRow(), not restored */ 41b0a32e0cSBarry Smith 428aa348c1SBarry Smith /* Used by MatDistribute_MPIAIJ() to allow reuse of previous matrix allocation and nonzero pattern */ 438aa348c1SBarry Smith PetscInt *ld; /* number of entries per row left of diagona block */ 44180e1086SBarry Smith } Mat_MPIAIJ; 453369ce9aSBarry Smith 4632fba14fSHong Zhang typedef struct { /* used by MatMatMult_MPIAIJ_MPIAIJ and MatPtAP_MPIAIJ_MPIAIJ for reusing symbolic mat product */ 471d79065fSBarry Smith PetscInt *startsj,*startsj_r; 48a6b2eed2SHong Zhang PetscScalar *bufa; 49ff134f7aSHong Zhang IS isrowa,isrowb,iscolb; 50ff134f7aSHong Zhang Mat *aseq,*bseq,C_seq; /* A_seq=aseq[0], B_seq=bseq[0] */ 515a5f83e5SHong Zhang Mat A_loc,B_seq; 5232fba14fSHong Zhang Mat B_loc,B_oth; /* partial B_seq -- intend to replace B_seq */ 5397f1f81fSBarry Smith PetscInt brstart; /* starting owned rows of B in matrix bseq[0]; brend = brstart+B->m */ 541677a5d7SHong Zhang PetscInt *abi,*abj; /* symbolic i and j arrays of the local product A_loc*B_seq */ 551677a5d7SHong Zhang PetscInt abnz_max; /* max(abi[i+1] - abi[i]), max num of nnz in a row of A_loc*B_seq */ 566c6e00e0SHong Zhang MatReuse reuse; 574a7f9380SHong Zhang PetscErrorCode (*MatDestroy)(Mat); 58abf897f8SHong Zhang PetscErrorCode (*MatDuplicate)(Mat,MatDuplicateOption,Mat*); 59ff134f7aSHong Zhang } Mat_MatMatMultMPI; 60ff134f7aSHong Zhang 61b90dcfe3SHong Zhang typedef struct { /* used by MatMerge_SeqsToMPI for reusing the merged matrix */ 6226283091SBarry Smith PetscLayout rowmap; 63de0260b3SHong Zhang PetscInt **buf_ri,**buf_rj; 640febcb4bSHong Zhang PetscMPIInt *len_s,*len_r,*id_r; /* array of length of comm->size, store send/recv matrix values */ 650febcb4bSHong Zhang PetscMPIInt nsend,nrecv; 66de0260b3SHong Zhang PetscInt *bi,*bj; /* i and j array of the local portion of mpi C=P^T*A*P */ 67de0260b3SHong Zhang PetscInt *owners_co,*coi,*coj; /* i and j array of (p->B)^T*A*P - used in the communication */ 68abf897f8SHong Zhang PetscErrorCode (*MatDestroy)(Mat); 69abf897f8SHong Zhang PetscErrorCode (*MatDuplicate)(Mat,MatDuplicateOption,Mat*); 70b90dcfe3SHong Zhang } Mat_Merge_SeqsToMPI; 71b90dcfe3SHong Zhang 72*09573ac7SBarry Smith extern PetscErrorCode MatSetColoring_MPIAIJ(Mat,ISColoring); 73*09573ac7SBarry Smith extern PetscErrorCode MatSetValuesAdic_MPIAIJ(Mat,void*); 74*09573ac7SBarry Smith extern PetscErrorCode MatSetValuesAdifor_MPIAIJ(Mat,PetscInt,void*); 75*09573ac7SBarry Smith extern PetscErrorCode MatSetUpMultiply_MPIAIJ(Mat); 76*09573ac7SBarry Smith extern PetscErrorCode DisAssemble_MPIAIJ(Mat); 77*09573ac7SBarry Smith extern PetscErrorCode MatDuplicate_MPIAIJ(Mat,MatDuplicateOption,Mat *); 78*09573ac7SBarry Smith extern PetscErrorCode MatIncreaseOverlap_MPIAIJ(Mat,PetscInt,IS [],PetscInt); 79*09573ac7SBarry Smith extern PetscErrorCode MatFDColoringCreate_MPIAIJ(Mat,ISColoring,MatFDColoring); 80*09573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrices_MPIAIJ (Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]); 81*09573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ_All(Mat,MatGetSubMatrixOption,MatReuse,Mat *[]); 82*09573ac7SBarry Smith extern PetscErrorCode MatGetSubMatricesParallel_MPIAIJ (Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]); 835494a064SHong Zhang 84*09573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ(Mat,IS,IS,MatReuse,Mat *); 85*09573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ_Private (Mat,IS,IS,PetscInt,MatReuse,Mat *); 86*09573ac7SBarry Smith extern PetscErrorCode MatGetMultiProcBlock_MPIAIJ(Mat,MPI_Comm,Mat*); 87d6037b41SHong Zhang 88*09573ac7SBarry Smith extern PetscErrorCode MatLoad_MPIAIJ(Mat,PetscViewer); 89*09573ac7SBarry Smith extern PetscErrorCode MatMatMult_MPIAIJ_MPIAIJ(Mat,Mat,MatReuse,PetscReal,Mat*); 90*09573ac7SBarry Smith extern PetscErrorCode MatMatMultSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*); 91*09573ac7SBarry Smith extern PetscErrorCode MatMatMultNumeric_MPIAIJ_MPIAIJ(Mat,Mat,Mat); 92*09573ac7SBarry Smith extern PetscErrorCode MatPtAPSymbolic_MPIAIJ(Mat,Mat,PetscReal,Mat*); 93*09573ac7SBarry Smith extern PetscErrorCode MatPtAPNumeric_MPIAIJ(Mat,Mat,Mat); 94*09573ac7SBarry Smith extern PetscErrorCode MatPtAPSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*); 95*09573ac7SBarry Smith extern PetscErrorCode MatPtAPNumeric_MPIAIJ_MPIAIJ(Mat,Mat,Mat); 96*09573ac7SBarry Smith extern PetscErrorCode MatSetValues_MPIAIJ(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar [],InsertMode); 97*09573ac7SBarry Smith extern PetscErrorCode MatDestroy_MPIAIJ_MatMatMult(Mat); 98*09573ac7SBarry Smith extern PetscErrorCode PetscContainerDestroy_Mat_MatMatMultMPI(void*); 99*09573ac7SBarry Smith extern PetscErrorCode MatGetRedundantMatrix_MPIAIJ(Mat,PetscInt,MPI_Comm,PetscInt,MatReuse,Mat*); 100*09573ac7SBarry Smith extern PetscErrorCode MatGetSeqNonzeroStructure_MPIAIJ(Mat,Mat*); 101c0d3702cSSatish Balay 1021472f72bSBarry Smith EXTERN_C_BEGIN 103*09573ac7SBarry Smith extern PetscErrorCode MatMPIAIJSetPreallocation_MPIAIJ(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 1041472f72bSBarry Smith EXTERN_C_END 1053a7fca6bSBarry Smith 10665460251SBarry Smith #if !defined(PETSC_USE_COMPLEX) && !defined(PETSC_USE_SCALAR_SINGLE) && !defined(PETSC_USE_SCALAR_MAT_SINGLE) 107*09573ac7SBarry Smith extern PetscErrorCode MatLUFactorSymbolic_MPIAIJ_TFS(Mat,IS,IS,const MatFactorInfo*,Mat*); 10897304618SKris Buschelman #endif 109*09573ac7SBarry Smith extern PetscErrorCode MatSolve_MPIAIJ(Mat,Vec,Vec); 110*09573ac7SBarry Smith extern PetscErrorCode MatILUFactor_MPIAIJ(Mat,IS,IS,const MatFactorInfo *); 11197304618SKris Buschelman 11297304618SKris Buschelman EXTERN_C_BEGIN 113*09573ac7SBarry Smith extern PetscErrorCode PETSCMAT_DLLEXPORT MatGetDiagonalBlock_MPIAIJ(Mat,PetscBool *,MatReuse,Mat *); 114*09573ac7SBarry Smith extern PetscErrorCode PETSCMAT_DLLEXPORT MatDiagonalScaleLocal_MPIAIJ(Mat,Vec); 11597304618SKris Buschelman EXTERN_C_END 1163a7fca6bSBarry Smith 1173369ce9aSBarry Smith #endif 118