Actual source code: sfimpl.h

petsc-master 2019-06-22
Report Typos and Errors
  1: #if !defined(_PETSCSFIMPL_H)
  2: #define _PETSCSFIMPL_H

  4:  #include <petscsf.h>
  5:  #include <petsc/private/petscimpl.h>
  6:  #include <petscviewer.h>

  8: PETSC_EXTERN PetscLogEvent PETSCSF_SetGraph;
  9: PETSC_EXTERN PetscLogEvent PETSCSF_SetUp;
 10: PETSC_EXTERN PetscLogEvent PETSCSF_BcastBegin;
 11: PETSC_EXTERN PetscLogEvent PETSCSF_BcastEnd;
 12: PETSC_EXTERN PetscLogEvent PETSCSF_BcastAndOpBegin;
 13: PETSC_EXTERN PetscLogEvent PETSCSF_BcastAndOpEnd;
 14: PETSC_EXTERN PetscLogEvent PETSCSF_ReduceBegin;
 15: PETSC_EXTERN PetscLogEvent PETSCSF_ReduceEnd;
 16: PETSC_EXTERN PetscLogEvent PETSCSF_FetchAndOpBegin;
 17: PETSC_EXTERN PetscLogEvent PETSCSF_FetchAndOpEnd;
 18: PETSC_EXTERN PetscLogEvent PETSCSF_EmbedSF;
 19: PETSC_EXTERN PetscLogEvent PETSCSF_DistSect;
 20: PETSC_EXTERN PetscLogEvent PETSCSF_SectSF;
 21: PETSC_EXTERN PetscLogEvent PETSCSF_RemoteOff;

 23: struct _PetscSFOps {
 24:   PetscErrorCode (*Reset)(PetscSF);
 25:   PetscErrorCode (*Destroy)(PetscSF);
 26:   PetscErrorCode (*SetUp)(PetscSF);
 27:   PetscErrorCode (*SetFromOptions)(PetscOptionItems*,PetscSF);
 28:   PetscErrorCode (*View)(PetscSF,PetscViewer);
 29:   PetscErrorCode (*Duplicate)(PetscSF,PetscSFDuplicateOption,PetscSF);
 30:   PetscErrorCode (*BcastBegin)(PetscSF,MPI_Datatype,const void*,void*);
 31:   PetscErrorCode (*BcastEnd)(PetscSF,MPI_Datatype,const void*,void*);
 32:   PetscErrorCode (*BcastAndOpBegin)(PetscSF,MPI_Datatype,const void*,void*,MPI_Op);
 33:   PetscErrorCode (*BcastAndOpEnd)(PetscSF,MPI_Datatype,const void*,void*,MPI_Op);
 34:   PetscErrorCode (*ReduceBegin)(PetscSF,MPI_Datatype,const void*,void*,MPI_Op);
 35:   PetscErrorCode (*ReduceEnd)(PetscSF,MPI_Datatype,const void*,void*,MPI_Op);
 36:   PetscErrorCode (*FetchAndOpBegin)(PetscSF,MPI_Datatype,void*,const void*,void*,MPI_Op);
 37:   PetscErrorCode (*FetchAndOpEnd)(PetscSF,MPI_Datatype,void*,const void *,void *,MPI_Op);
 38:   PetscErrorCode (*GetLeafRanks)(PetscSF,PetscInt*,const PetscMPIInt**,const PetscInt**,const PetscInt **);
 39: };

 41: struct _p_PetscSF {
 42:   PETSCHEADER(struct _PetscSFOps);
 43:   PetscInt        nroots;       /* Number of root vertices on current process (candidates for incoming edges) */
 44:   PetscInt        nleaves;      /* Number of leaf vertices on current process (this process specifies a root for each leaf) */
 45:   PetscInt        *mine;        /* Location of leaves in leafdata arrays provided to the communication routines */
 46:   PetscInt        *mine_alloc;
 47:   PetscInt        minleaf,maxleaf;
 48:   PetscSFNode     *remote;      /* Remote references to roots for each local leaf */
 49:   PetscSFNode     *remote_alloc;
 50:   PetscInt        nranks;       /* Number of ranks owning roots connected to my leaves */
 51:   PetscInt        ndranks;      /* Number of ranks in distinguished group holding roots connected to my leaves */
 52:   PetscMPIInt     *ranks;       /* List of ranks referenced by "remote" */
 53:   PetscInt        *roffset;     /* Array of length nranks+1, offset in rmine/rremote for each rank */
 54:   PetscInt        *rmine;       /* Concatenated array holding local indices referencing each remote rank */
 55:   PetscInt        *rremote;     /* Concatenated array holding remote indices referenced for each remote rank */
 56:   PetscBool       degreeknown;  /* The degree is currently known, do not have to recompute */
 57:   PetscInt        *degree;      /* Degree of each of my root vertices */
 58:   PetscInt        *degreetmp;   /* Temporary local array for computing degree */
 59:   PetscBool       rankorder;    /* Sort ranks for gather and scatter operations */
 60:   MPI_Group       ingroup;      /* Group of processes connected to my roots */
 61:   MPI_Group       outgroup;     /* Group of processes connected to my leaves */
 62:   PetscSF         multi;        /* Internal graph used to implement gather and scatter operations */
 63:   PetscBool       graphset;     /* Flag indicating that the graph has been set, required before calling communication routines */
 64:   PetscBool       setupcalled;  /* Type and communication structures have been set up */

 66:   void *data;                   /* Pointer to implementation */
 67: };

 69: PETSC_EXTERN PetscBool PetscSFRegisterAllCalled;
 70: PETSC_EXTERN PetscErrorCode PetscSFRegisterAll(void);

 72: PETSC_EXTERN PetscErrorCode MPIPetsc_Type_unwrap(MPI_Datatype,MPI_Datatype*,PetscBool*);
 73: PETSC_EXTERN PetscErrorCode MPIPetsc_Type_compare(MPI_Datatype,MPI_Datatype,PetscBool*);
 74: PETSC_EXTERN PetscErrorCode MPIPetsc_Type_compare_contig(MPI_Datatype,MPI_Datatype,PetscInt*);

 76: #endif