[MPICH] about MPI_Reduce

Thomas Moschny moschny at ipd.uni-karlsruhe.de
Tue Oct 18 02:28:51 CDT 2005


llwaeva at 21cn.com wrote:
> However, if I change the array operation to pointer operation (as the book
> "MPI: The complete reference" do), the result is wrong
> 
> void reduction(int *in, int *inout, int *len, MPI_Datatype *dptr)
> { int l, i;
>   assert(*dptr == datatype);
>   for (l=0; l<(*len); l++)
>     for (i=0; i<vlength; i++)
>       if (i%2==0) {*inout += *in; inout++; in++;}
> }
> 
> I am wondering what's going on

Now you are incrementing the pointers 'inout' and 'in' only in every
other step. Try moving the increment operations out of the if-block.

- Thomas




More information about the mpich-discuss mailing list