MPIU_Allreduce — PETSc 3.24.5 documentation

Skip to main content
`Ctrl`+`K`

# MPIU_Allreduce

A replacement for `MPI_Allreduce()` that (1) performs single-count `MPIU_INT` operations in `PetscInt64` to detect integer overflows and (2) tries to determine if the call from all the MPI ranks occur in the same place in the PETSc code. This helps to detect bugs where different MPI ranks follow different code paths resulting in inconsistent and incorrect calls to `MPI_Allreduce()`.

## Synopsis

    #include <petscsys.h>
    PetscMPIInt MPIU_Allreduce(void *indata,void *outdata,PetscCount count,MPI_Datatype dtype, MPI_Op op, MPI_Comm comm);

Collective

## Input Parameters

- a - pointer to the input data to be reduced

- count - the number of MPI data items in `a` and `b`

- dtype - the MPI datatype, for example `MPI_INT`

- op - the MPI operation, for example `MPI_SUM`

- comm - the MPI communicator on which the operation occurs

## Output Parameter

- b - the reduced values

## Note

Should be wrapped with `PetscCallMPI()` for error checking

## See Also

PETSc and standard datatypes, `MPI_Allreduce()`

## Level

developer

## Location

include/petscsys.h

## Examples

src/ksp/ksp/tutorials/ex35.cxx
src/ksp/ksp/tutorials/ex70.c
src/ksp/ksp/tutorials/ex73.c
src/ksp/ksp/tutorials/ex10.c
src/ksp/ksp/tutorials/ex42.c
src/dm/impls/plex/tutorials/ex10.c
src/ksp/ksp/tutorials/ex43.c
src/ksp/ksp/tutorials/ex82.c
src/ksp/ksp/tutorials/ex36.cxx
src/dm/impls/plex/tutorials/ex16.c

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