[MPICH] about MPI_Reduce

Thomas Moschny moschny at ipd.uni-karlsruhe.de
Tue Oct 18 04:48:32 CDT 2005


> void reduction(int *in, int *inout, int *len, MPI_Datatype *dptr)
> {
>   assert(*dptr == datatype);
>   for (int l=0; l<(*len); l++)
>     for (int i=0; i<vlength; i++)
>       if (i%2==0) inout[i] += in[i]; 
> }

BTW: My code was wrong. This should read:

void reduction(int *in, int *inout, int *len, MPI_Datatype *dptr){
  assert(*dptr == datatype);
  for (int l=0; l<(*len); l++)
    for (int i=l*vlength; i<(l+1)*vlength; i++)
      if (i%2==0) inout[i] += in[i];
}

but this bug is of course only in effect when reducing more than one
element of the user-specified datatype.

- Thomas




More information about the mpich-discuss mailing list