# MPIU_Allreduce#

a PETSc replacement for MPI_Allreduce() that tries to determine if the call from all the MPI ranks occur from 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(). Collective

## Synopsis#

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


## Input Parameters#

• a - pointer to the input data to be reduced

• c - the number of MPI data items in a and b

• d - the MPI datatype, for example MPI_INT

• e - the MPI operation, for example MPI_SUM

• fcomm - the MPI communicator on which the operation occurs

## Output Parameter#

• b - the reduced values

## Notes#

In optimized mode this directly calls MPI_Allreduce()

This is defined as a macro that can return error codes internally so it cannot be used in a subroutine that returns void.

The error code this returns should be checked with PetscCall() even though it looks like an MPI function because it always returns PETSc error codes

MPI_Allreduce()

developer

## Location#

include/petscsys.h

Edit on GitLab