Skip to main content
`Ctrl`+`K`

# PetscSFReduceBegin

begin reduction (communication) 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 (communicate)

- op - reduction operation

## Output Parameter

- rootdata - result of reduction of values (`leafdata`) from all leaves to each root

## Note

When PETSc is configured with device support, it will use `PetscGetMemType()` to determine whether the given data pointers are host pointers or device pointers, which may incur a noticeable cost. If you already knew the memory type, you should use `PetscSFReduceWithMemTypeBegin()` instead.

## See Also

PetscSF - an alternative to low-level MPI calls for data communication, `PetscSF`, `PetscSFBcastBegin()`, `PetscSFReduceWithMemTypeBegin()`, `PetscSFReduceEnd()`, `MPI_Datatype`

## Level

intermediate

## Location

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

## Examples

src/ts/tutorials/ex30.c
src/vec/is/sf/tutorials/ex1f.F90
src/vec/is/sf/tutorials/ex1.c

## Implementations

PetscSFReduceBegin_Allgather() in src/vec/is/sf/impls/basic/allgather/sfallgather.c
PetscSFReduceBegin_Allgatherv() in src/vec/is/sf/impls/basic/allgatherv/sfallgatherv.c
PetscSFReduceBegin_Basic() in src/vec/is/sf/impls/basic/sfbasic.c
PetscSFReduceBegin_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