Actual source code: sfregi.c

      1: #include <petsc/private/sfimpl.h>

      3: PETSC_INTERN PetscErrorCode PetscSFCreate_Basic(PetscSF);
      4: #if defined(PETSC_HAVE_MPI_WIN_CREATE)
      5: PETSC_INTERN PetscErrorCode PetscSFCreate_Window(PetscSF);
      6: #endif
      7: PETSC_INTERN PetscErrorCode PetscSFCreate_Allgatherv(PetscSF);
      8: PETSC_INTERN PetscErrorCode PetscSFCreate_Allgather(PetscSF);
      9: PETSC_INTERN PetscErrorCode PetscSFCreate_Gatherv(PetscSF);
     10: PETSC_INTERN PetscErrorCode PetscSFCreate_Gather(PetscSF);
     11: PETSC_INTERN PetscErrorCode PetscSFCreate_Alltoall(PetscSF);
     12: #if defined(PETSC_HAVE_MPI_NEIGHBORHOOD_COLLECTIVES)
     13: PETSC_INTERN PetscErrorCode PetscSFCreate_Neighbor(PetscSF);
     14: #endif

     16: PetscFunctionList PetscSFList;
     17: PetscBool         PetscSFRegisterAllCalled;

     19: /*@C
     20:    PetscSFRegisterAll - Registers all the PetscSF communication implementations

     22:    Not Collective

     24:    Level: advanced

     26: .seealso:  PetscSFRegisterDestroy()
     27: @*/
     28: PetscErrorCode  PetscSFRegisterAll(void)
     29: {
     30:   if (PetscSFRegisterAllCalled) return 0;
     31:   PetscSFRegisterAllCalled = PETSC_TRUE;
     32:   PetscSFRegister(PETSCSFBASIC,  PetscSFCreate_Basic);
     33: #if defined(PETSC_HAVE_MPI_WIN_CREATE)
     34:   PetscSFRegister(PETSCSFWINDOW, PetscSFCreate_Window);
     35: #endif
     36:   PetscSFRegister(PETSCSFALLGATHERV,PetscSFCreate_Allgatherv);
     37:   PetscSFRegister(PETSCSFALLGATHER, PetscSFCreate_Allgather);
     38:   PetscSFRegister(PETSCSFGATHERV,   PetscSFCreate_Gatherv);
     39:   PetscSFRegister(PETSCSFGATHER,    PetscSFCreate_Gather);
     40:   PetscSFRegister(PETSCSFALLTOALL,  PetscSFCreate_Alltoall);
     41: #if defined(PETSC_HAVE_MPI_NEIGHBORHOOD_COLLECTIVES)
     42:   PetscSFRegister(PETSCSFNEIGHBOR,  PetscSFCreate_Neighbor);
     43: #endif
     44:   return 0;
     45: }

     47: /*@C
     48:   PetscSFRegister  - Adds an implementation of the PetscSF communication protocol.

     50:    Not collective

     52:    Input Parameters:
     53: +  name - name of a new user-defined implementation
     54: -  create - routine to create method context

     56:    Notes:
     57:    PetscSFRegister() may be called multiple times to add several user-defined implementations.

     59:    Sample usage:
     60: .vb
     61:    PetscSFRegister("my_impl",MyImplCreate);
     62: .ve

     64:    Then, this implementation can be chosen with the procedural interface via
     65: $     PetscSFSetType(sf,"my_impl")
     66:    or at runtime via the option
     67: $     -sf_type my_impl

     69:    Level: advanced

     71: .seealso: PetscSFRegisterAll(), PetscSFInitializePackage()
     72: @*/
     73: PetscErrorCode  PetscSFRegister(const char name[],PetscErrorCode (*create)(PetscSF))
     74: {
     75:   PetscSFInitializePackage();
     76:   PetscFunctionListAdd(&PetscSFList,name,create);
     77:   return 0;
     78: }