xref: /petsc/src/mat/impls/aij/mpi/mpiaij.h (revision ca45077f9abf8e7344aac749d49eef6cfd88f621)
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;
69*ca45077fSPaul Mullowney 
70*ca45077fSPaul Mullowney #if defined(PETSC_HAVE_TXPETSCGPU)
71*ca45077fSPaul Mullowney   /* The following are used by GPU capabilities to store matrix storage formats on the device */
72*ca45077fSPaul Mullowney   MatOption diagGPUMatFormat;
73*ca45077fSPaul Mullowney   MatOption offdiagGPUMatFormat;
74*ca45077fSPaul Mullowney #endif
75f8487c73SHong Zhang } Mat_MPIAIJ;
76f8487c73SHong Zhang 
7709573ac7SBarry Smith extern PetscErrorCode MatSetColoring_MPIAIJ(Mat,ISColoring);
7809573ac7SBarry Smith extern PetscErrorCode MatSetValuesAdic_MPIAIJ(Mat,void*);
7909573ac7SBarry Smith extern PetscErrorCode MatSetValuesAdifor_MPIAIJ(Mat,PetscInt,void*);
8009573ac7SBarry Smith extern PetscErrorCode MatSetUpMultiply_MPIAIJ(Mat);
81ab9863d7SBarry Smith extern PetscErrorCode MatDisAssemble_MPIAIJ(Mat);
8209573ac7SBarry Smith extern PetscErrorCode MatDuplicate_MPIAIJ(Mat,MatDuplicateOption,Mat *);
8309573ac7SBarry Smith extern PetscErrorCode MatIncreaseOverlap_MPIAIJ(Mat,PetscInt,IS [],PetscInt);
8409573ac7SBarry Smith extern PetscErrorCode MatFDColoringCreate_MPIAIJ(Mat,ISColoring,MatFDColoring);
8509573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrices_MPIAIJ (Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
8609573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ_All(Mat,MatGetSubMatrixOption,MatReuse,Mat *[]);
8709573ac7SBarry Smith extern PetscErrorCode MatGetSubMatricesParallel_MPIAIJ (Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
885494a064SHong Zhang 
8909573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ(Mat,IS,IS,MatReuse,Mat *);
9009573ac7SBarry Smith extern PetscErrorCode MatGetSubMatrix_MPIAIJ_Private (Mat,IS,IS,PetscInt,MatReuse,Mat *);
91fc08c53fSHong Zhang extern PetscErrorCode MatGetMultiProcBlock_MPIAIJ(Mat,MPI_Comm,MatReuse,Mat*);
92d6037b41SHong Zhang 
9309573ac7SBarry Smith extern PetscErrorCode MatLoad_MPIAIJ(Mat,PetscViewer);
948cdbd757SHong Zhang extern PetscErrorCode MatMatMult_MPIDense_MPIAIJ(Mat,Mat,MatReuse,PetscReal,Mat*);
9509573ac7SBarry Smith extern PetscErrorCode MatMatMult_MPIAIJ_MPIAIJ(Mat,Mat,MatReuse,PetscReal,Mat*);
9609573ac7SBarry Smith extern PetscErrorCode MatMatMultSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*);
9725023028SHong Zhang extern PetscErrorCode MatMatMultSymbolic_MPIAIJ_MPIAIJ_Scalable(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);
104c5af039cSHong Zhang extern PetscErrorCode MatDestroy_MPIAIJ_PtAP(Mat);
105c5af039cSHong Zhang 
106f8487c73SHong Zhang extern PetscErrorCode MatGetBrowsOfAoCols_MPIAIJ(Mat,Mat,MatReuse,PetscInt**,PetscInt**,MatScalar**,Mat*);
10709573ac7SBarry Smith extern PetscErrorCode MatSetValues_MPIAIJ(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar [],InsertMode);
10809573ac7SBarry Smith extern PetscErrorCode MatDestroy_MPIAIJ_MatMatMult(Mat);
10909573ac7SBarry Smith extern PetscErrorCode PetscContainerDestroy_Mat_MatMatMultMPI(void*);
110*ca45077fSPaul Mullowney extern PetscErrorCode MatSetOption_MPIAIJ(Mat,MatOption,PetscBool);
111187b3c17SHong Zhang 
112187b3c17SHong Zhang extern PetscErrorCode MatTransposeMatMult_MPIAIJ_MPIAIJ(Mat,Mat,MatReuse,PetscReal,Mat*);
113187b3c17SHong Zhang extern PetscErrorCode MatTransposeMatMultSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*);
114d6ab1dc0SHong Zhang extern PetscErrorCode MatTransposeMatMultSymbolic_MPIAIJ_MPIAIJ_Scalable(Mat,Mat,PetscReal,Mat*);
115187b3c17SHong Zhang extern PetscErrorCode MatTransposeMatMultNumeric_MPIAIJ_MPIAIJ(Mat,Mat,Mat);
116187b3c17SHong Zhang 
11709573ac7SBarry Smith extern PetscErrorCode MatGetRedundantMatrix_MPIAIJ(Mat,PetscInt,MPI_Comm,PetscInt,MatReuse,Mat*);
11809573ac7SBarry Smith extern PetscErrorCode MatGetSeqNonzeroStructure_MPIAIJ(Mat,Mat*);
119c0d3702cSSatish Balay 
1201472f72bSBarry Smith EXTERN_C_BEGIN
12109573ac7SBarry Smith extern PetscErrorCode MatMPIAIJSetPreallocation_MPIAIJ(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
1221472f72bSBarry Smith EXTERN_C_END
1233a7fca6bSBarry Smith 
124ce63c4c1SBarry Smith #if !defined(PETSC_USE_COMPLEX) && !defined(PETSC_USE_REAL_SINGLE) && !defined(PETSC_USE_REAL___FLOAT128)
12509573ac7SBarry Smith extern PetscErrorCode MatLUFactorSymbolic_MPIAIJ_TFS(Mat,IS,IS,const MatFactorInfo*,Mat*);
12697304618SKris Buschelman #endif
12709573ac7SBarry Smith extern PetscErrorCode MatSolve_MPIAIJ(Mat,Vec,Vec);
12809573ac7SBarry Smith extern PetscErrorCode MatILUFactor_MPIAIJ(Mat,IS,IS,const MatFactorInfo *);
12997304618SKris Buschelman 
13097304618SKris Buschelman EXTERN_C_BEGIN
13111bd1e4dSLisandro Dalcin extern PetscErrorCode  MatGetDiagonalBlock_MPIAIJ(Mat,Mat *);
1327087cfbeSBarry Smith extern PetscErrorCode  MatDiagonalScaleLocal_MPIAIJ(Mat,Vec);
13397304618SKris Buschelman EXTERN_C_END
1343a7fca6bSBarry Smith 
1353369ce9aSBarry Smith #endif
136