HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
MPIMin.c File Reference

Functions to compute the minimum over all MPI ranks. More...

#include <mpivars.h>

Go to the source code of this file.

Functions

int MPIMin_integer (int *global, int *var, int size, void *comm)
 
int MPIMin_double (double *global, double *var, int size, void *comm)
 

Detailed Description

Functions to compute the minimum over all MPI ranks.

Author
Debojyoti Ghosh

Definition in file MPIMin.c.

Function Documentation

◆ MPIMin_integer()

int MPIMin_integer ( int *  global,
int *  var,
int  size,
void *  comm 
)

Compute the global minimum over all MPI ranks in a given communicator for int datatype.

  • If var is an array of size greater than 1, global will be an array of the same size with each element as the minimum value of he that element in var on all the MPI ranks in the given communicator.
Parameters
globalarray to contain the global minimums
varthe local array
sizesize of the local array
commMPI communicator

Definition at line 15 of file MPIMin.c.

21 {
22 #ifdef serial
23  int i;
24  for (i = 0; i < size; i++) global[i] = var[i];
25 #else
26  MPI_Allreduce((var==global?MPI_IN_PLACE:var),global,size,MPI_INT,MPI_MIN,*((MPI_Comm*)comm));
27 #endif
28  return(0);
29 }

◆ MPIMin_double()

int MPIMin_double ( double *  global,
double *  var,
int  size,
void *  comm 
)

Compute the global minimum over all MPI ranks in a given communicator for double datatype.

  • If var is an array of size greater than 1, global will be an array of the same size with each element as the minimum value of that element in var on all the MPI ranks in the given communicator.
Parameters
globalarray to contain the global minimums
varthe local array
sizesize of the local array
commMPI communicator

Definition at line 38 of file MPIMin.c.

44 {
45 #ifdef serial
46  int i;
47  for (i = 0; i < size; i++) global[i] = var[i];
48 #else
49  MPI_Allreduce((var==global?MPI_IN_PLACE:var),global,size,MPI_DOUBLE,MPI_MIN,*((MPI_Comm*)comm));
50 #endif
51  return(0);
52 }