# PetscSFReduceBegin
begin reduction of leafdata into rootdata, to be completed with call to `PetscSFReduceEnd()` 
## Synopsis
```
#include "petscsf.h" 
PetscErrorCode PetscSFReduceBegin(PetscSF sf, MPI_Datatype unit, const void *leafdata, void *rootdata, MPI_Op op)
```
Collective


## Input Parameters

- ***sf -*** star forest
- ***unit -*** data type
- ***leafdata -*** values to reduce
- ***op -*** reduction operation



## Output Parameter

- ***rootdata -*** result of reduction of values from all leaves of each root





## Notes
When petsc is configured with device support, it will use its own mechanism to figure out whether the given data pointers
are host pointers or device pointers, which may incur a noticable cost. If you already knew the info, you should
use `PetscSFReduceWithMemTypeBegin()` instead.


## See Also
 `PetscSF`, `PetscSFBcastBegin()`, `PetscSFReduceWithMemTypeBegin()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/interface/sf.c.html#PetscSFReduceBegin">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.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/allgather/sfallgather.c.html#PetscSFReduceBegin_Allgather">PetscSFReduceBegin_Allgather in src/vec/is/sf/impls/basic/allgather/sfallgather.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/allgatherv/sfallgatherv.c.html#PetscSFReduceBegin_Allgatherv">PetscSFReduceBegin_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/alltoall/sfalltoall.c.html#PetscSFReduceBegin_Alltoall">PetscSFReduceBegin_Alltoall in src/vec/is/sf/impls/basic/alltoall/sfalltoall.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/gather/sfgather.c.html#PetscSFReduceBegin_Gather">PetscSFReduceBegin_Gather in src/vec/is/sf/impls/basic/gather/sfgather.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/gatherv/sfgatherv.c.html#PetscSFReduceBegin_Gatherv">PetscSFReduceBegin_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#PetscSFReduceBegin_Neighbor">PetscSFReduceBegin_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#PetscSFReduceBegin_Basic">PetscSFReduceBegin_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#PetscSFReduceBegin_Window">PetscSFReduceBegin_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](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
