Skip to main content
`Ctrl`+`K`

# PetscSFWindowSetFlavorType

Set flavor type for `MPI_Win` creation

## Synopsis

    #include "petscsf.h"
    PetscErrorCode PetscSFWindowSetFlavorType(PetscSF sf, PetscSFWindowFlavorType flavor)

Logically Collective

## Input Parameters

- sf - star forest for communication of type `PETSCSFWINDOW`

- flavor - flavor type

## Options Database Key

- -sf_window_flavor <flavor> - sets the flavor type CREATE, DYNAMIC, ALLOCATE or SHARED (see `PetscSFWindowFlavorType`)

## Notes

Windows reuse follows these rules:

         PETSCSF_WINDOW_FLAVOR_CREATE: creates a new window every time, uses MPI_Win_create

         PETSCSF_WINDOW_FLAVOR_DYNAMIC: uses MPI_Win_create_dynamic/MPI_Win_attach and tries to reuse windows by comparing the root array. Intended to be used on repeated applications of the same SF, e.g.
           PetscSFRegisterPersistent(sf,rootdata1,leafdata);
           for i=1 to K
             PetscSFOperationBegin(sf,rootdata1,leafdata);
             PetscSFOperationEnd(sf,rootdata1,leafdata);
             ...
             PetscSFOperationBegin(sf,rootdata1,leafdata);
             PetscSFOperationEnd(sf,rootdata1,leafdata);
           endfor
           PetscSFDeregisterPersistent(sf,rootdata1,leafdata);

           The following pattern will instead raise an error
             PetscSFOperationBegin(sf,rootdata1,leafdata);
             PetscSFOperationEnd(sf,rootdata1,leafdata);
             PetscSFOperationBegin(sf,rank ? rootdata1 : rootdata2,leafdata);
             PetscSFOperationEnd(sf,rank ? rootdata1 : rootdata2,leafdata);

         PETSCSF_WINDOW_FLAVOR_ALLOCATE: uses MPI_Win_allocate, reuses any pre-existing window which fits the data and it is not in use

         PETSCSF_WINDOW_FLAVOR_SHARED: uses MPI_Win_allocate_shared, reusage policy as for PETSCSF_WINDOW_FLAVOR_ALLOCATE

## See Also

`PetscSF`, `PETSCSFWINDOW`, `PetscSFSetFromOptions()`, `PetscSFWindowGetFlavorType()`

## Level

advanced

## Location

src/vec/is/sf/impls/window/sfwindow.c

## Implementations

PetscSFWindowSetFlavorType_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