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