xref: /petsc/src/mat/impls/aij/mpi/mpiaij.h (revision 8cdbd7576f676fd2f0cf4ce91c9fbf7f9b0d4574)
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 
78a729477SBarry Smith typedef struct {
88c386bf4SBarry Smith   Mat           A,B;                   /* local submatrices: A (diag part),
98c386bf4SBarry Smith                                            B (off-diag part) */
1097f1f81fSBarry Smith   PetscMPIInt   size;                   /* size of communicator */
1197f1f81fSBarry Smith   PetscMPIInt   rank;                   /* rank of proc in communicator */
128c386bf4SBarry Smith 
138c386bf4SBarry Smith   /* The following variables are used for matrix assembly */
148c386bf4SBarry Smith 
15ace3abfcSBarry Smith   PetscBool     donotstash;             /* PETSC_TRUE if off processor entries dropped */
168c386bf4SBarry Smith   MPI_Request   *send_waits;            /* array of send requests */
178c386bf4SBarry Smith   MPI_Request   *recv_waits;            /* array of receive requests */
1897f1f81fSBarry Smith   PetscInt      nsends,nrecvs;         /* numbers of sends and receives */
19ea709b57SSatish Balay   PetscScalar   *svalues,*rvalues;     /* sending and receiving data */
2097f1f81fSBarry Smith   PetscInt      rmax;                   /* maximum message length */
21ac2a4f0dSBarry Smith #if defined (PETSC_USE_CTABLE)
22ac2a4f0dSBarry Smith   PetscTable    colmap;
2332b39ab2SSatish Balay #else
2497f1f81fSBarry Smith   PetscInt      *colmap;                /* local col number of off-diag col */
2532b39ab2SSatish Balay #endif
2697f1f81fSBarry Smith   PetscInt      *garray;                /* global index of all off-processor columns */
278c386bf4SBarry Smith 
288c386bf4SBarry Smith   /* The following variables are used for matrix-vector products */
298c386bf4SBarry Smith 
308c386bf4SBarry Smith   Vec           lvec;              /* local vector */
31a7420bb7SBarry Smith   Vec           diag;
328c386bf4SBarry Smith   VecScatter    Mvctx;             /* scatter context for vector */
33ace3abfcSBarry Smith   PetscBool     roworiented;       /* if true, row-oriented input, default true */
343369ce9aSBarry Smith 
353369ce9aSBarry Smith   /* The following variables are for MatGetRow() */
363369ce9aSBarry Smith 
37b1d57f15SBarry Smith   PetscInt      *rowindices;       /* column indices for row */
38ea709b57SSatish Balay   PetscScalar   *rowvalues;        /* nonzero values in row */
39ace3abfcSBarry Smith   PetscBool     getrowactive;      /* indicates MatGetRow(), not restored */
40b0a32e0cSBarry Smith 
418aa348c1SBarry Smith   /* Used by MatDistribute_MPIAIJ() to allow reuse of previous matrix allocation  and nonzero pattern */
428aa348c1SBarry Smith   PetscInt      *ld;               /* number of entries per row left of diagona block */
43180e1086SBarry Smith } Mat_MPIAIJ;
443369ce9aSBarry Smith 
4532fba14fSHong Zhang typedef struct { /* used by MatMatMult_MPIAIJ_MPIAIJ and MatPtAP_MPIAIJ_MPIAIJ for reusing symbolic mat product */
46*f639d13fSHong Zhang   /* used by MatMatMult_MPIAIJ_MPIAIJ() */
47*f639d13fSHong Zhang   IS             isrowa,isrowb,iscolb;
48*f639d13fSHong Zhang   Mat            B_seq,A_loc,C_seq;
49*f639d13fSHong Zhang 
50*f639d13fSHong Zhang   /* used by MatPtAP_MPIAIJ_MPIAIJ */
511d79065fSBarry Smith   PetscInt       *startsj,*startsj_r;
52a6b2eed2SHong Zhang   PetscScalar    *bufa;
5332fba14fSHong Zhang   Mat            B_loc,B_oth;  /* partial B_seq -- intend to replace B_seq */
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;
57*f639d13fSHong Zhang 
58dce485f0SBarry Smith   PetscErrorCode (*destroy)(Mat);
59dce485f0SBarry Smith   PetscErrorCode (*duplicate)(Mat,MatDuplicateOption,Mat*);
60ff134f7aSHong Zhang } Mat_MatMatMultMPI;
61ff134f7aSHong Zhang 
62b90dcfe3SHong Zhang typedef struct { /* used by MatMerge_SeqsToMPI for reusing the merged matrix */
6326283091SBarry Smith   PetscLayout    rowmap;
64de0260b3SHong Zhang   PetscInt       **buf_ri,**buf_rj;
650febcb4bSHong Zhang   PetscMPIInt    *len_s,*len_r,*id_r; /* array of length of comm->size, store send/recv matrix values */
660febcb4bSHong Zhang   PetscMPIInt    nsend,nrecv;
67de0260b3SHong Zhang   PetscInt       *bi,*bj; /* i and j array of the local portion of mpi C=P^T*A*P */
68de0260b3SHong Zhang   PetscInt       *owners_co,*coi,*coj; /* i and j array of (p->B)^T*A*P - used in the communication */
69dce485f0SBarry Smith   PetscErrorCode (*destroy)(Mat);
70dce485f0SBarry Smith   PetscErrorCode (*duplicate)(Mat,MatDuplicateOption,Mat*);
71b90dcfe3SHong Zhang } Mat_Merge_SeqsToMPI;
72b90dcfe3SHong Zhang 
7309573ac7SBarry Smith extern PetscErrorCode MatSetColoring_MPIAIJ(Mat,ISColoring);
7409573ac7SBarry Smith extern PetscErrorCode MatSetValuesAdic_MPIAIJ(Mat,void*);
7509573ac7SBarry Smith extern PetscErrorCode MatSetValuesAdifor_MPIAIJ(Mat,PetscInt,void*);
7609573ac7SBarry Smith extern PetscErrorCode MatSetUpMultiply_MPIAIJ(Mat);
7709573ac7SBarry Smith extern PetscErrorCode DisAssemble_MPIAIJ(Mat);
7809573ac7SBarry Smith extern PetscErrorCode MatDuplicate_MPIAIJ(Mat,MatDuplicateOption,Mat *);
7909573ac7SBarry Smith extern PetscErrorCode MatIncreaseOverlap_MPIAIJ(Mat,PetscInt,IS [],PetscInt);
8009573ac7SBarry Smith extern PetscErrorCode MatFDColoringCreate_MPIAIJ(Mat,ISColoring,MatFDColoring);
8109573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrices_MPIAIJ (Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
8209573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ_All(Mat,MatGetSubMatrixOption,MatReuse,Mat *[]);
8309573ac7SBarry Smith extern PetscErrorCode MatGetSubMatricesParallel_MPIAIJ (Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
845494a064SHong Zhang 
8509573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ(Mat,IS,IS,MatReuse,Mat *);
8609573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ_Private (Mat,IS,IS,PetscInt,MatReuse,Mat *);
8709573ac7SBarry Smith extern PetscErrorCode MatGetMultiProcBlock_MPIAIJ(Mat,MPI_Comm,Mat*);
88d6037b41SHong Zhang 
8909573ac7SBarry Smith extern PetscErrorCode MatLoad_MPIAIJ(Mat,PetscViewer);
908cdbd757SHong Zhang extern PetscErrorCode MatMatMult_MPIDense_MPIAIJ(Mat,Mat,MatReuse,PetscReal,Mat*);
9109573ac7SBarry Smith extern PetscErrorCode MatMatMult_MPIAIJ_MPIAIJ(Mat,Mat,MatReuse,PetscReal,Mat*);
9209573ac7SBarry Smith extern PetscErrorCode MatMatMultSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*);
9309573ac7SBarry Smith extern PetscErrorCode MatMatMultNumeric_MPIAIJ_MPIAIJ(Mat,Mat,Mat);
9409573ac7SBarry Smith extern PetscErrorCode MatPtAPSymbolic_MPIAIJ(Mat,Mat,PetscReal,Mat*);
9509573ac7SBarry Smith extern PetscErrorCode MatPtAPNumeric_MPIAIJ(Mat,Mat,Mat);
9609573ac7SBarry Smith extern PetscErrorCode MatPtAPSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*);
9709573ac7SBarry Smith extern PetscErrorCode MatPtAPNumeric_MPIAIJ_MPIAIJ(Mat,Mat,Mat);
9809573ac7SBarry Smith extern PetscErrorCode MatSetValues_MPIAIJ(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar [],InsertMode);
9909573ac7SBarry Smith extern PetscErrorCode MatDestroy_MPIAIJ_MatMatMult(Mat);
10009573ac7SBarry Smith extern PetscErrorCode PetscContainerDestroy_Mat_MatMatMultMPI(void*);
10109573ac7SBarry Smith extern PetscErrorCode MatGetRedundantMatrix_MPIAIJ(Mat,PetscInt,MPI_Comm,PetscInt,MatReuse,Mat*);
10209573ac7SBarry Smith extern PetscErrorCode MatGetSeqNonzeroStructure_MPIAIJ(Mat,Mat*);
103c0d3702cSSatish Balay 
1041472f72bSBarry Smith EXTERN_C_BEGIN
10509573ac7SBarry Smith extern PetscErrorCode MatMPIAIJSetPreallocation_MPIAIJ(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
1061472f72bSBarry Smith EXTERN_C_END
1073a7fca6bSBarry Smith 
108ce63c4c1SBarry Smith #if !defined(PETSC_USE_COMPLEX) && !defined(PETSC_USE_REAL_SINGLE) && !defined(PETSC_USE_REAL___FLOAT128)
10909573ac7SBarry Smith extern PetscErrorCode MatLUFactorSymbolic_MPIAIJ_TFS(Mat,IS,IS,const MatFactorInfo*,Mat*);
11097304618SKris Buschelman #endif
11109573ac7SBarry Smith extern PetscErrorCode MatSolve_MPIAIJ(Mat,Vec,Vec);
11209573ac7SBarry Smith extern PetscErrorCode MatILUFactor_MPIAIJ(Mat,IS,IS,const MatFactorInfo *);
11397304618SKris Buschelman 
11497304618SKris Buschelman EXTERN_C_BEGIN
11511bd1e4dSLisandro Dalcin extern PetscErrorCode  MatGetDiagonalBlock_MPIAIJ(Mat,Mat *);
1167087cfbeSBarry Smith extern PetscErrorCode  MatDiagonalScaleLocal_MPIAIJ(Mat,Vec);
11797304618SKris Buschelman EXTERN_C_END
1183a7fca6bSBarry Smith 
1193369ce9aSBarry Smith #endif
120