xref: /petsc/src/mat/impls/aij/mpi/mpiaij.h (revision f8487c7373c1533f3bf25724e12928e7f7a4f17b)
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 
732fba14fSHong Zhang typedef struct { /* used by MatMatMult_MPIAIJ_MPIAIJ and MatPtAP_MPIAIJ_MPIAIJ for reusing symbolic mat product */
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;
11*f639d13fSHong Zhang 
12f8487c73SHong Zhang   /* used by MatPtAP_MPIAIJ_MPIAIJ - mv!*/
131d79065fSBarry Smith   PetscInt       *startsj,*startsj_r;
14a6b2eed2SHong Zhang   PetscScalar    *bufa;
1532fba14fSHong Zhang   Mat            B_loc,B_oth;  /* partial B_seq -- intend to replace B_seq */
161677a5d7SHong Zhang   PetscInt       *abi,*abj;    /* symbolic i and j arrays of the local product A_loc*B_seq */
171677a5d7SHong Zhang   PetscInt       abnz_max;     /* max(abi[i+1] - abi[i]), max num of nnz in a row of A_loc*B_seq */
186c6e00e0SHong Zhang   MatReuse       reuse;
19*f639d13fSHong Zhang 
20dce485f0SBarry Smith   PetscErrorCode (*destroy)(Mat);
21dce485f0SBarry Smith   PetscErrorCode (*duplicate)(Mat,MatDuplicateOption,Mat*);
22ff134f7aSHong Zhang } Mat_MatMatMultMPI;
23ff134f7aSHong Zhang 
24b90dcfe3SHong Zhang typedef struct { /* used by MatMerge_SeqsToMPI for reusing the merged matrix */
2526283091SBarry Smith   PetscLayout    rowmap;
26de0260b3SHong Zhang   PetscInt       **buf_ri,**buf_rj;
270febcb4bSHong Zhang   PetscMPIInt    *len_s,*len_r,*id_r; /* array of length of comm->size, store send/recv matrix values */
280febcb4bSHong Zhang   PetscMPIInt    nsend,nrecv;
29de0260b3SHong Zhang   PetscInt       *bi,*bj; /* i and j array of the local portion of mpi C=P^T*A*P */
30de0260b3SHong Zhang   PetscInt       *owners_co,*coi,*coj; /* i and j array of (p->B)^T*A*P - used in the communication */
31dce485f0SBarry Smith   PetscErrorCode (*destroy)(Mat);
32dce485f0SBarry Smith   PetscErrorCode (*duplicate)(Mat,MatDuplicateOption,Mat*);
33b90dcfe3SHong Zhang } Mat_Merge_SeqsToMPI;
34b90dcfe3SHong Zhang 
35f8487c73SHong Zhang typedef struct { /* used by MatPtAP_MPIAIJ_MPIAIJ */
36f8487c73SHong Zhang   PetscInt       *startsj,*startsj_r;
37f8487c73SHong Zhang   PetscScalar    *bufa;
38f8487c73SHong Zhang   Mat            B_loc,B_oth;  /* partial B_seq -- intend to replace B_seq */
39f8487c73SHong Zhang   PetscInt       *abi,*abj;    /* symbolic i and j arrays of the local product A_loc*B_seq */
40f8487c73SHong Zhang   PetscInt       abnz_max;     /* max(abi[i+1] - abi[i]), max num of nnz in a row of A_loc*B_seq */
41f8487c73SHong Zhang   MatReuse       reuse;
42f8487c73SHong Zhang 
43f8487c73SHong Zhang   Mat_Merge_SeqsToMPI *merge;
44f8487c73SHong Zhang   PetscErrorCode (*destroy)(Mat);
45f8487c73SHong Zhang } Mat_PtAPMPI;
46f8487c73SHong Zhang 
47f8487c73SHong Zhang typedef struct {
48f8487c73SHong Zhang   Mat           A,B;                   /* local submatrices: A (diag part),
49f8487c73SHong Zhang                                            B (off-diag part) */
50f8487c73SHong Zhang   PetscMPIInt   size;                   /* size of communicator */
51f8487c73SHong Zhang   PetscMPIInt   rank;                   /* rank of proc in communicator */
52f8487c73SHong Zhang 
53f8487c73SHong Zhang   /* The following variables are used for matrix assembly */
54f8487c73SHong Zhang   PetscBool     donotstash;             /* PETSC_TRUE if off processor entries dropped */
55f8487c73SHong Zhang   MPI_Request   *send_waits;            /* array of send requests */
56f8487c73SHong Zhang   MPI_Request   *recv_waits;            /* array of receive requests */
57f8487c73SHong Zhang   PetscInt      nsends,nrecvs;         /* numbers of sends and receives */
58f8487c73SHong Zhang   PetscScalar   *svalues,*rvalues;     /* sending and receiving data */
59f8487c73SHong Zhang   PetscInt      rmax;                   /* maximum message length */
60f8487c73SHong Zhang #if defined (PETSC_USE_CTABLE)
61f8487c73SHong Zhang   PetscTable    colmap;
62f8487c73SHong Zhang #else
63f8487c73SHong Zhang   PetscInt      *colmap;                /* local col number of off-diag col */
64f8487c73SHong Zhang #endif
65f8487c73SHong Zhang   PetscInt      *garray;                /* global index of all off-processor columns */
66f8487c73SHong Zhang 
67f8487c73SHong Zhang   /* The following variables are used for matrix-vector products */
68f8487c73SHong Zhang   Vec           lvec;              /* local vector */
69f8487c73SHong Zhang   Vec           diag;
70f8487c73SHong Zhang   VecScatter    Mvctx;             /* scatter context for vector */
71f8487c73SHong Zhang   PetscBool     roworiented;       /* if true, row-oriented input, default true */
72f8487c73SHong Zhang 
73f8487c73SHong Zhang   /* The following variables are for MatGetRow() */
74f8487c73SHong Zhang   PetscInt      *rowindices;       /* column indices for row */
75f8487c73SHong Zhang   PetscScalar   *rowvalues;        /* nonzero values in row */
76f8487c73SHong Zhang   PetscBool     getrowactive;      /* indicates MatGetRow(), not restored */
77f8487c73SHong Zhang 
78f8487c73SHong Zhang   /* Used by MatDistribute_MPIAIJ() to allow reuse of previous matrix allocation  and nonzero pattern */
79f8487c73SHong Zhang   PetscInt      *ld;               /* number of entries per row left of diagona block */
80f8487c73SHong Zhang 
81f8487c73SHong Zhang   /* Used by MatPtAP */
82f8487c73SHong Zhang   Mat_PtAPMPI   *ptap;
83f8487c73SHong Zhang } Mat_MPIAIJ;
84f8487c73SHong Zhang 
8509573ac7SBarry Smith extern PetscErrorCode MatSetColoring_MPIAIJ(Mat,ISColoring);
8609573ac7SBarry Smith extern PetscErrorCode MatSetValuesAdic_MPIAIJ(Mat,void*);
8709573ac7SBarry Smith extern PetscErrorCode MatSetValuesAdifor_MPIAIJ(Mat,PetscInt,void*);
8809573ac7SBarry Smith extern PetscErrorCode MatSetUpMultiply_MPIAIJ(Mat);
8909573ac7SBarry Smith extern PetscErrorCode DisAssemble_MPIAIJ(Mat);
9009573ac7SBarry Smith extern PetscErrorCode MatDuplicate_MPIAIJ(Mat,MatDuplicateOption,Mat *);
9109573ac7SBarry Smith extern PetscErrorCode MatIncreaseOverlap_MPIAIJ(Mat,PetscInt,IS [],PetscInt);
9209573ac7SBarry Smith extern PetscErrorCode MatFDColoringCreate_MPIAIJ(Mat,ISColoring,MatFDColoring);
9309573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrices_MPIAIJ (Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
9409573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ_All(Mat,MatGetSubMatrixOption,MatReuse,Mat *[]);
9509573ac7SBarry Smith extern PetscErrorCode MatGetSubMatricesParallel_MPIAIJ (Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
965494a064SHong Zhang 
9709573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ(Mat,IS,IS,MatReuse,Mat *);
9809573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ_Private (Mat,IS,IS,PetscInt,MatReuse,Mat *);
9909573ac7SBarry Smith extern PetscErrorCode MatGetMultiProcBlock_MPIAIJ(Mat,MPI_Comm,Mat*);
100d6037b41SHong Zhang 
10109573ac7SBarry Smith extern PetscErrorCode MatLoad_MPIAIJ(Mat,PetscViewer);
1028cdbd757SHong Zhang extern PetscErrorCode MatMatMult_MPIDense_MPIAIJ(Mat,Mat,MatReuse,PetscReal,Mat*);
10309573ac7SBarry Smith extern PetscErrorCode MatMatMult_MPIAIJ_MPIAIJ(Mat,Mat,MatReuse,PetscReal,Mat*);
10409573ac7SBarry Smith extern PetscErrorCode MatMatMultSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*);
10509573ac7SBarry Smith extern PetscErrorCode MatMatMultNumeric_MPIAIJ_MPIAIJ(Mat,Mat,Mat);
106f8487c73SHong Zhang 
10709573ac7SBarry Smith extern PetscErrorCode MatPtAPSymbolic_MPIAIJ(Mat,Mat,PetscReal,Mat*);
10809573ac7SBarry Smith extern PetscErrorCode MatPtAPNumeric_MPIAIJ(Mat,Mat,Mat);
10909573ac7SBarry Smith extern PetscErrorCode MatPtAPSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*);
11009573ac7SBarry Smith extern PetscErrorCode MatPtAPNumeric_MPIAIJ_MPIAIJ(Mat,Mat,Mat);
111f8487c73SHong Zhang extern PetscErrorCode MatGetBrowsOfAoCols_MPIAIJ(Mat,Mat,MatReuse,PetscInt**,PetscInt**,MatScalar**,Mat*);
11209573ac7SBarry Smith extern PetscErrorCode MatSetValues_MPIAIJ(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar [],InsertMode);
11309573ac7SBarry Smith extern PetscErrorCode MatDestroy_MPIAIJ_MatMatMult(Mat);
11409573ac7SBarry Smith extern PetscErrorCode PetscContainerDestroy_Mat_MatMatMultMPI(void*);
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