Skip to main content
`Ctrl`+`K`

# PetscSFCreate

create a star forest communication context

## Synopsis

    #include "petscsf.h"
    PetscErrorCode PetscSFCreate(MPI_Comm comm, PetscSF *sf)

Collective

## Input Parameter

- comm - communicator on which the star forest will operate

## Output Parameter

- sf - new star forest context

## Options Database Key

- -sf_type (basic|window|neighbor) - Use MPI persistent Isend/Irecv, or MPI-3 one-sided window, or MPI-3 neighborhood collectives for communication

- -sf_neighbor_persistent (true|false) - Use MPI-4 persistent neighborhood collectives for communication (used along with `-sf_type neighbor`)

## Note

When one knows the communication graph is one of the predefined graph, such as `MPI_Alltoall()`, `MPI_Allgatherv()`, `MPI_Gatherv()`, one can create a `PetscSF` and then set its graph with `PetscSFSetGraphWithPattern()`. These special `PetscSF`s are optimized and have better performance than the general `PetscSF`s.

## See Also

PetscSF - an alternative to low-level MPI calls for data communication, `PetscSF`, `PetscSFSetType`, `PetscSFSetGraph()`, `PetscSFSetGraphWithPattern()`, `PetscSFDestroy()`

## Level

intermediate

## Location

src/vec/is/sf/interface/sf.c

## Examples

src/vec/is/sf/tutorials/ex1f.F90
src/vec/is/sf/tutorials/ex3.c
src/dm/impls/plex/tutorials/ex15.c
src/vec/is/sf/tutorials/ex1.c
src/vec/is/sf/tutorials/ex2.c

## Implementations

PetscSFCreate_Allgather() in src/vec/is/sf/impls/basic/allgather/sfallgather.c
PetscSFCreate_Allgatherv() in src/vec/is/sf/impls/basic/allgatherv/sfallgatherv.c
PetscSFCreate_Alltoall() in src/vec/is/sf/impls/basic/alltoall/sfalltoall.c
PetscSFCreate_Gather() in src/vec/is/sf/impls/basic/gather/sfgather.c
PetscSFCreate_Gatherv() in src/vec/is/sf/impls/basic/gatherv/sfgatherv.c
PetscSFCreate_Neighbor() in src/vec/is/sf/impls/basic/neighbor/sfneighbor.c
PetscSFCreate_Basic() in src/vec/is/sf/impls/basic/sfbasic.c
PetscSFCreate_Window() in src/vec/is/sf/impls/window/sfwindow.c

Index of all PetscSF routines
Table of Contents for all manual pages
Index of all manual pages