xref: /petsc/src/mat/impls/aij/mpi/mpiaij.h (revision b549a33df52e18f44cd122c2139f7c5486754f82)
1 
2 #if !defined(__MPIAIJ_H)
3 #define __MPIAIJ_H
4 
5 #include <../src/mat/impls/aij/seq/aij.h>
6 
7 typedef struct {
8   Mat           A,B;                   /* local submatrices: A (diag part),
9                                            B (off-diag part) */
10   PetscMPIInt   size;                   /* size of communicator */
11   PetscMPIInt   rank;                   /* rank of proc in communicator */
12 
13   /* The following variables are used for matrix assembly */
14 
15   PetscBool     donotstash;             /* PETSC_TRUE if off processor entries dropped */
16   MPI_Request   *send_waits;            /* array of send requests */
17   MPI_Request   *recv_waits;            /* array of receive requests */
18   PetscInt      nsends,nrecvs;         /* numbers of sends and receives */
19   PetscScalar   *svalues,*rvalues;     /* sending and receiving data */
20   PetscInt      rmax;                   /* maximum message length */
21 #if defined (PETSC_USE_CTABLE)
22   PetscTable    colmap;
23 #else
24   PetscInt      *colmap;                /* local col number of off-diag col */
25 #endif
26   PetscInt      *garray;                /* global index of all off-processor columns */
27 
28   /* The following variables are used for matrix-vector products */
29 
30   Vec           lvec;              /* local vector */
31   Vec           diag;
32   VecScatter    Mvctx;             /* scatter context for vector */
33   PetscBool     roworiented;       /* if true, row-oriented input, default true */
34 
35   /* The following variables are for MatGetRow() */
36 
37   PetscInt      *rowindices;       /* column indices for row */
38   PetscScalar   *rowvalues;        /* nonzero values in row */
39   PetscBool     getrowactive;      /* indicates MatGetRow(), not restored */
40 
41   /* Used by MatDistribute_MPIAIJ() to allow reuse of previous matrix allocation  and nonzero pattern */
42   PetscInt      *ld;               /* number of entries per row left of diagona block */
43 } Mat_MPIAIJ;
44 
45 typedef struct { /* used by MatMatMult_MPIAIJ_MPIAIJ and MatPtAP_MPIAIJ_MPIAIJ for reusing symbolic mat product */
46   /* used by MatMatMult_MPIAIJ_MPIAIJ() */
47   IS             isrowa,isrowb,iscolb;
48   Mat            B_seq,A_loc,C_seq;
49 
50   /* used by MatPtAP_MPIAIJ_MPIAIJ */
51   PetscInt       *startsj,*startsj_r;
52   PetscScalar    *bufa;
53   Mat            B_loc,B_oth;  /* partial B_seq -- intend to replace B_seq */
54   PetscInt       *abi,*abj;    /* symbolic i and j arrays of the local product A_loc*B_seq */
55   PetscInt       abnz_max;     /* max(abi[i+1] - abi[i]), max num of nnz in a row of A_loc*B_seq */
56   MatReuse       reuse;
57 
58   PetscErrorCode (*destroy)(Mat);
59   PetscErrorCode (*duplicate)(Mat,MatDuplicateOption,Mat*);
60 } Mat_MatMatMultMPI;
61 
62 typedef struct { /* used by MatMerge_SeqsToMPI for reusing the merged matrix */
63   PetscLayout    rowmap;
64   PetscInt       **buf_ri,**buf_rj;
65   PetscMPIInt    *len_s,*len_r,*id_r; /* array of length of comm->size, store send/recv matrix values */
66   PetscMPIInt    nsend,nrecv;
67   PetscInt       *bi,*bj; /* i and j array of the local portion of mpi C=P^T*A*P */
68   PetscInt       *owners_co,*coi,*coj; /* i and j array of (p->B)^T*A*P - used in the communication */
69   PetscErrorCode (*destroy)(Mat);
70   PetscErrorCode (*duplicate)(Mat,MatDuplicateOption,Mat*);
71 } Mat_Merge_SeqsToMPI;
72 
73 extern PetscErrorCode MatSetColoring_MPIAIJ(Mat,ISColoring);
74 extern PetscErrorCode MatSetValuesAdic_MPIAIJ(Mat,void*);
75 extern PetscErrorCode MatSetValuesAdifor_MPIAIJ(Mat,PetscInt,void*);
76 extern PetscErrorCode MatSetUpMultiply_MPIAIJ(Mat);
77 extern PetscErrorCode DisAssemble_MPIAIJ(Mat);
78 extern PetscErrorCode MatDuplicate_MPIAIJ(Mat,MatDuplicateOption,Mat *);
79 extern PetscErrorCode MatIncreaseOverlap_MPIAIJ(Mat,PetscInt,IS [],PetscInt);
80 extern PetscErrorCode MatFDColoringCreate_MPIAIJ(Mat,ISColoring,MatFDColoring);
81 extern PetscErrorCode MatGetSubMatrices_MPIAIJ (Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
82 extern PetscErrorCode MatGetSubMatrix_MPIAIJ_All(Mat,MatGetSubMatrixOption,MatReuse,Mat *[]);
83 extern PetscErrorCode MatGetSubMatricesParallel_MPIAIJ (Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
84 
85 extern PetscErrorCode MatGetSubMatrix_MPIAIJ(Mat,IS,IS,MatReuse,Mat *);
86 extern PetscErrorCode MatGetSubMatrix_MPIAIJ_Private (Mat,IS,IS,PetscInt,MatReuse,Mat *);
87 extern PetscErrorCode MatGetMultiProcBlock_MPIAIJ(Mat,MPI_Comm,Mat*);
88 
89 extern PetscErrorCode MatLoad_MPIAIJ(Mat,PetscViewer);
90 extern PetscErrorCode MatMatMult_MPIAIJ_MPIAIJ(Mat,Mat,MatReuse,PetscReal,Mat*);
91 extern PetscErrorCode MatMatMultSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*);
92 extern PetscErrorCode MatMatMultNumeric_MPIAIJ_MPIAIJ(Mat,Mat,Mat);
93 extern PetscErrorCode MatPtAPSymbolic_MPIAIJ(Mat,Mat,PetscReal,Mat*);
94 extern PetscErrorCode MatPtAPNumeric_MPIAIJ(Mat,Mat,Mat);
95 extern PetscErrorCode MatPtAPSymbolic_MPIAIJ_MPIAIJ(Mat,Mat,PetscReal,Mat*);
96 extern PetscErrorCode MatPtAPNumeric_MPIAIJ_MPIAIJ(Mat,Mat,Mat);
97 extern PetscErrorCode MatSetValues_MPIAIJ(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar [],InsertMode);
98 extern PetscErrorCode MatDestroy_MPIAIJ_MatMatMult(Mat);
99 extern PetscErrorCode PetscContainerDestroy_Mat_MatMatMultMPI(void*);
100 extern PetscErrorCode MatGetRedundantMatrix_MPIAIJ(Mat,PetscInt,MPI_Comm,PetscInt,MatReuse,Mat*);
101 extern PetscErrorCode MatGetSeqNonzeroStructure_MPIAIJ(Mat,Mat*);
102 
103 EXTERN_C_BEGIN
104 extern PetscErrorCode MatMPIAIJSetPreallocation_MPIAIJ(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
105 EXTERN_C_END
106 
107 #if !defined(PETSC_USE_COMPLEX) && !defined(PETSC_USE_REAL_SINGLE) && !defined(PETSC_USE_REAL___FLOAT128)
108 extern PetscErrorCode MatLUFactorSymbolic_MPIAIJ_TFS(Mat,IS,IS,const MatFactorInfo*,Mat*);
109 #endif
110 extern PetscErrorCode MatSolve_MPIAIJ(Mat,Vec,Vec);
111 extern PetscErrorCode MatILUFactor_MPIAIJ(Mat,IS,IS,const MatFactorInfo *);
112 
113 EXTERN_C_BEGIN
114 extern PetscErrorCode  MatGetDiagonalBlock_MPIAIJ(Mat,Mat *);
115 extern PetscErrorCode  MatDiagonalScaleLocal_MPIAIJ(Mat,Vec);
116 EXTERN_C_END
117 
118 #endif
119