1 #include <petsc/private/sfimpl.h> /*I "petscsf.h" I*/ 2 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 15 16 PetscFunctionList PetscSFList; 17 PetscBool PetscSFRegisterAllCalled; 18 19 /*@C 20 PetscSFRegisterAll - Registers all the PetscSF communication implementations 21 22 Not Collective 23 24 Level: advanced 25 26 .seealso: `PetscSFRegisterDestroy()` 27 @*/ 28 PetscErrorCode PetscSFRegisterAll(void) { 29 PetscFunctionBegin; 30 if (PetscSFRegisterAllCalled) PetscFunctionReturn(0); 31 PetscSFRegisterAllCalled = PETSC_TRUE; 32 PetscCall(PetscSFRegister(PETSCSFBASIC, PetscSFCreate_Basic)); 33 #if defined(PETSC_HAVE_MPI_WIN_CREATE) 34 PetscCall(PetscSFRegister(PETSCSFWINDOW, PetscSFCreate_Window)); 35 #endif 36 PetscCall(PetscSFRegister(PETSCSFALLGATHERV, PetscSFCreate_Allgatherv)); 37 PetscCall(PetscSFRegister(PETSCSFALLGATHER, PetscSFCreate_Allgather)); 38 PetscCall(PetscSFRegister(PETSCSFGATHERV, PetscSFCreate_Gatherv)); 39 PetscCall(PetscSFRegister(PETSCSFGATHER, PetscSFCreate_Gather)); 40 PetscCall(PetscSFRegister(PETSCSFALLTOALL, PetscSFCreate_Alltoall)); 41 #if defined(PETSC_HAVE_MPI_NEIGHBORHOOD_COLLECTIVES) 42 PetscCall(PetscSFRegister(PETSCSFNEIGHBOR, PetscSFCreate_Neighbor)); 43 #endif 44 PetscFunctionReturn(0); 45 } 46 47 /*@C 48 PetscSFRegister - Adds an implementation of the PetscSF communication protocol. 49 50 Not collective 51 52 Input Parameters: 53 + name - name of a new user-defined implementation 54 - create - routine to create method context 55 56 Notes: 57 PetscSFRegister() may be called multiple times to add several user-defined implementations. 58 59 Sample usage: 60 .vb 61 PetscSFRegister("my_impl",MyImplCreate); 62 .ve 63 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 68 69 Level: advanced 70 71 .seealso: `PetscSFRegisterAll()`, `PetscSFInitializePackage()` 72 @*/ 73 PetscErrorCode PetscSFRegister(const char name[], PetscErrorCode (*create)(PetscSF)) { 74 PetscFunctionBegin; 75 PetscCall(PetscSFInitializePackage()); 76 PetscCall(PetscFunctionListAdd(&PetscSFList, name, create)); 77 PetscFunctionReturn(0); 78 } 79