:orphan:
# PetscSFFetchAndOpBegin
begin operation that fetches values from root and updates atomically by applying operation using my leaf value, to be completed with `PetscSFFetchAndOpEnd()` 
## Synopsis
```
#include "petscsf.h" 
PetscErrorCode PetscSFFetchAndOpBegin(PetscSF sf, MPI_Datatype unit, void *rootdata, const void *leafdata, void *leafupdate, MPI_Op op)
```
Collective


## Input Parameters

- ***sf -*** star forest
- ***unit -*** data type
- ***leafdata -*** leaf values to use in reduction
- ***op -*** operation to use for reduction



## Output Parameters

- ***rootdata -*** root values to be updated, input state is seen by first process to perform an update
- ***leafupdate -*** state at each leaf's respective root immediately prior to my atomic update





## Note
The update is only atomic at the granularity provided by the hardware. Different roots referenced by the same process
might be updated in a different order. Furthermore, if a composite type is used for the unit datatype, atomicity is
not guaranteed across the whole vertex. Therefore, this function is mostly only used with primitive types such as
integers.


## See Also
 `PetscSF`, `PetscSFComputeDegreeBegin()`, `PetscSFReduceBegin()`, `PetscSFSetGraph()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/interface/sf.c.html#PetscSFFetchAndOpBegin">src/vec/is/sf/interface/sf.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/tutorials/ex1.c.html">src/vec/is/sf/tutorials/ex1.c</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/allgatherv/sfallgatherv.c.html#PetscSFFetchAndOpBegin_Allgatherv">PetscSFFetchAndOpBegin_Allgatherv in src/vec/is/sf/impls/basic/allgatherv/sfallgatherv.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/gatherv/sfgatherv.c.html#PetscSFFetchAndOpBegin_Gatherv">PetscSFFetchAndOpBegin_Gatherv in src/vec/is/sf/impls/basic/gatherv/sfgatherv.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c.html#PetscSFFetchAndOpBegin_Neighbor">PetscSFFetchAndOpBegin_Neighbor in src/vec/is/sf/impls/basic/neighbor/sfneighbor.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/sfbasic.c.html#PetscSFFetchAndOpBegin_Basic">PetscSFFetchAndOpBegin_Basic in src/vec/is/sf/impls/basic/sfbasic.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/window/sfwindow.c.html#PetscSFFetchAndOpBegin_Window">PetscSFFetchAndOpBegin_Window in src/vec/is/sf/impls/window/sfwindow.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/is/sf/interface/sf.c)


[Index of all PetscSF routines](index.md)  
[Table of Contents for all manual pages](/manualpages/index.md)  
[Index of all manual pages](/manualpages/singleindex.md)  
