xref: /petsc/src/mat/impls/aij/mpi/mpiaij.h (revision 09f3b4e5628a00a1eaf17d80982cfbcc515cc9c1)
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   PetscInt      *rowners,*cowners;     /* ranges owned by each processor */
10   PetscInt      rstart,rend;           /* starting and ending owned rows */
11   PetscInt      cstart,cend;           /* starting and ending owned columns */
12   Mat           A,B;                   /* local submatrices: A (diag part),
13                                            B (off-diag part) */
14   PetscMPIInt   size;                   /* size of communicator */
15   PetscMPIInt   rank;                   /* rank of proc in communicator */
16 
17   /* The following variables are used for matrix assembly */
18 
19   PetscTruth    donotstash;             /* PETSC_TRUE if off processor entries dropped */
20   MPI_Request   *send_waits;            /* array of send requests */
21   MPI_Request   *recv_waits;            /* array of receive requests */
22   PetscInt      nsends,nrecvs;         /* numbers of sends and receives */
23   PetscScalar   *svalues,*rvalues;     /* sending and receiving data */
24   PetscInt      rmax;                   /* maximum message length */
25 #if defined (PETSC_USE_CTABLE)
26   PetscTable    colmap;
27 #else
28   PetscInt      *colmap;                /* local col number of off-diag col */
29 #endif
30   PetscInt      *garray;                /* global index of all off-processor columns */
31 
32   /* The following variables are used for matrix-vector products */
33 
34   Vec           lvec;              /* local vector */
35   VecScatter    Mvctx;             /* scatter context for vector */
36   PetscTruth    roworiented;       /* if true, row-oriented input, default true */
37 
38   /* The following variables are for MatGetRow() */
39 
40   PetscInt      *rowindices;       /* column indices for row */
41   PetscScalar   *rowvalues;        /* nonzero values in row */
42   PetscTruth    getrowactive;      /* indicates MatGetRow(), not restored */
43 
44 } Mat_MPIAIJ;
45 
46 typedef struct { /* used by MatMatMult_MPIAIJ_MPIAIJ and MatPtAP_MPIAIJ_MPIAIJ for reusing symbolic mat product */
47   PetscInt    *startsj;
48   PetscScalar *bufa;
49   IS          isrowa,isrowb,iscolb;
50   Mat         *aseq,*bseq,C_seq; /* A_seq=aseq[0], B_seq=bseq[0] */
51   Mat         A_loc,B_seq;
52   Mat         B_loc,B_oth;  /* partial B_seq -- intend to replace B_seq */
53   PetscInt    brstart; /* starting owned rows of B in matrix bseq[0]; brend = brstart+B->m */
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   PetscErrorCode (*MatDestroy)(Mat);
58 } Mat_MatMatMultMPI;
59 
60 typedef struct { /* used by MatMerge_SeqsToMPI for reusing the merged matrix */
61   PetscMap     rowmap;
62   PetscInt     **buf_ri,**buf_rj;
63   PetscMPIInt  *len_s,*len_r,*id_r; /* array of length of comm->size, store send/recv matrix values */
64   PetscMPIInt  nsend,nrecv;
65   PetscInt     *bi,*bj; /* i and j array of the local portion of mpi C=P^T*A*P */
66   PetscInt     *owners_co,*coi,*coj; /* i and j array of (p->B)^T*A*P - used in the communication */
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 PetscObjectContainerDestroy_Mat_MatMatMultMPI(void*);
90 
91 EXTERN_C_BEGIN
92 EXTERN PetscErrorCode MatMPIAIJSetPreallocation_MPIAIJ(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
93 EXTERN_C_END
94 
95 #if !defined(PETSC_USE_COMPLEX) && !defined(PETSC_USE_SINGLE) && !defined(PETSC_USE_MAT_SINGLE)
96 EXTERN PetscErrorCode MatLUFactorSymbolic_MPIAIJ_TFS(Mat,IS,IS,MatFactorInfo*,Mat*);
97 #endif
98 
99 EXTERN_C_BEGIN
100 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetDiagonalBlock_MPIAIJ(Mat,PetscTruth *,MatReuse,Mat *);
101 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDiagonalScaleLocal_MPIAIJ(Mat,Vec);
102 EXTERN_C_END
103 
104 #endif
105