[MPICH] Re: (瑞星提示-此邮件可能是垃圾邮件)RE: [MPICH] about MPI_Reduce
llwaeva at 21cn.com
llwaeva at 21cn.com
Mon Oct 17 12:27:43 CDT 2005
> If you use a derived datatype, you need to provide the reduction function
> that does the reduction operation locally on the derived datatype. MPI will
> do the communication and call this function to do the reduction. So if the
> reduction is not happening, the myOp function you provide is probably not
> right.
I don't know what's going on. It seems that the reduction function never
know the structure of the derived datatype. Moreover, the entry of the
data sent to the reduction function is not valid.
Suppose the data list is
buffer=[0 1 2 3 4 5 6 7 8]
mydatatype is a derived type which hold the data in even index, i.e.
from mydatatype, we get [0 2 4 6 8]
MPI_Reduce( &buffer, &output, 1, mydatatype, myOp, 0, MPI_COMM_WORLD);
The self-defined reduction function is
void myReFun(int *in, int *inout, int *len, MPI_Datatype *dptr)
{ int i;
for (i=0; i<8; i++)
{
if (i%2==0)
{
printf("%d\n", *in); fflush(stdout);
*inout = 2*(*in);
}
in++; inout++;
}
}
Anything wrong?
More information about the mpich-discuss
mailing list