[mpich-discuss] Why do predefined MPI_Ops function elementwise in MPI_Accumulate, but not in MPI-1 routines?

Jed Brown jedbrown at mcs.anl.gov
Mon Apr 23 20:37:27 CDT 2012


On Mon, Apr 23, 2012 at 20:29, Jeff Hammond <jhammond at alcf.anl.gov> wrote:

> I was under the impression that the use for MPI_Accumulate was a
> proper subset of MPIReduce, etc.
>

So did I, until recently.


>  What part of the standard leads you
> to believe that restrictions pertaining to MPI_Reduce, etc. are
> stricter than for MPI_Accumulate?
>

Well, both MPICH2 and Open MPI error saying it is unsupported and section
5.9.2 (Predefined Reduction Operations) has no verbiage indicating that
they should work with any derived datatypes.

*"For the other predefined operations, we enumerate below the allowed
combinations of op and datatype arguments."*


#include <mpi.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
  MPI_Datatype MPIMe_2DOUBLE;
  double local[2],global[2];
  int rank,size;

  MPI_Init(&argc,&argv);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Type_contiguous(2,MPI_DOUBLE,&MPIMe_2DOUBLE);
  MPI_Type_commit(&MPIMe_2DOUBLE);
  local[0] = (double)rank;
  local[1] = (double)size;
  MPI_Allreduce(local,global,1,MPIMe_2DOUBLE,MPI_MAX,MPI_COMM_WORLD);
  if (!rank) printf("global [%g,%g]\n",global[0],global[1]);
  MPI_Finalize();
  return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20120423/fc4825e6/attachment.htm>


More information about the mpich-discuss mailing list