<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& sendtype, void* recvbuf,int recvcount, const MPI::Datatype& 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 & 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;"> int
n=dtype.Get_size();</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> for(int i=0;i<length;i++)</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> *(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;"> 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;"> MPI::Op mysum;</span><br style="font-family:
lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> mysum.Init(sumfunc,true);</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> 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;"> int result1,result2;</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> MPI::COMM_WORLD.Reduce(&unit,&resut1,1,MPI::INT,MPI::SUM,0);</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> MPI::COMM_WORLD.Reduce(&unit,&resut2,1,MPI::INT,mysum,0);</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida
console,sans-serif;"> if(unit==0)</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> cout<<"The results via sum&mysum are "<<result1<<" , "<<result2<<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>