<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:13pt"><div><span>hi, MPICH users</span></div><div style="color: rgb(0, 0, 0); font-size: 17.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span>I have some problems on the function Gather and Op::Init</span></div><div style="color: rgb(0, 0, 0); font-size: 17.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span><span style="color: rgb(255, 0, 0);">Gather:</span> the function prototype is</span></div><div style="color: rgb(0, 0, 0); font-size: 17.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span>void MPI::Comm::Gather(const void* sendbuf, int sendcount,const MPI::Datatype&amp; sendtype, void* recvbuf,int recvcount, const MPI::Datatype&amp; recvtype, int root) const = 0 <br><span
 style="color: rgb(255, 0, 0);">I don't know the difference between the second parameter( sendcount)and the fifth parameter(recvcount). can they be different?</span></span></div><div style="color: rgb(0, 0, 0); font-size: 17.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span><span style="color: rgb(255, 0, 0);">Op::Init</span> the function prototype is</span></div><div style="color: rgb(0, 0, 0); font-size: 17.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span>void Init( User_function *, bool )</span></div><div style="color: rgb(0, 0, 0); font-size: 17.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span>MPI_Op_create(MPI_User_function *, int ,MPI_Op*)<br></span></div><div style="color: rgb(0, 0, 0); font-size: 17.3333px; font-family: arial,helvetica,sans-serif; background-color:
 transparent; font-style: normal;"><span><span style="color: rgb(255, 0, 0);">can you show me how to use User_function to define a user function? and where is the faults below?</span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 17.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span>-----------</span></div><div style="color: rgb(0, 0, 0); font-size: 17.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span><font style="color: rgb(0, 0, 255);" size="2"><span style="font-family: lucida console,sans-serif;">void sumfunc(const void* x,void * y,int length,MPI::Datatype &amp; dtype)</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">{</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">&nbsp;&nbsp;&nbsp; int
 n=dtype.Get_size();</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">&nbsp;&nbsp;&nbsp; for(int i=0;i&lt;length;i++)</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; *(y+n*i)=*(x+n*i)+*(y+n*i);</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">&nbsp;&nbsp;&nbsp; return;</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">}</span><br style="font-family: lucida console,sans-serif;"><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">void op-test(){</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">&nbsp;&nbsp;&nbsp; MPI::Op mysum;</span><br style="font-family:
 lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">&nbsp;&nbsp;&nbsp; mysum.Init(sumfunc,true);</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">&nbsp;&nbsp;&nbsp; int unit=pow(MPI::COMM_WORLD.Get_size(),3);</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">&nbsp;&nbsp;&nbsp; int result1,result2;</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">&nbsp;&nbsp;&nbsp; MPI::COMM_WORLD.Reduce(&amp;unit,&amp;resut1,1,MPI::INT,MPI::SUM,0);</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">&nbsp;&nbsp;&nbsp; MPI::COMM_WORLD.Reduce(&amp;unit,&amp;resut2,1,MPI::INT,mysum,0);</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida
 console,sans-serif;">&nbsp;&nbsp;&nbsp; if(unit==0)</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; cout&lt;&lt;"The results via sum&amp;mysum are "&lt;&lt;result1&lt;&lt;" , "&lt;&lt;result2&lt;&lt;endl;</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">}</span></font><br></span></div><div style="color: rgb(0, 0, 0); font-size: 17.3333px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span><br class="yui-cursor"></span></div><div>Thank you very much, waiting for your reply <br></div><div><font size="2"><span style="font-family:tahoma, new york, times, serif;"><span style="font-family:tahoma, new york, times, serif;"></span>---<br>Kong Tao</span></font><font size="2"><br style="font-family:tahoma, new york, times, serif;"><span
 style="font-family:tahoma, new york, times, serif;">School of Maths,Shandong Univ. P.R.C.</span><br></font></div></div></body></html>