<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div><font size="3">I Write the following MPI source file binding with c++, it is error ,why ? can anyone help me to fix it?</font><br><br>-----<br><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">void sumfunc(const void* x,void * y,int length,const MPI::Datatype & dtype)</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">{</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> int n=dtype.Get_size();</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">
for(int i=0;i<length;i++)</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> *(y+n*i)=*(x+n*i)+*(y+n*i);</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> return;</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">}</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">void op_test(){</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida
console,sans-serif; color: rgb(0, 0, 255);"> MPI::Op mysum;</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> mysum.Init(sumfunc,true);</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> int unit=pow(MPI::COMM_WORLD.Get_size(),3);</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> int result1,result2;</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> MPI::COMM_WORLD.Reduce(&unit,&result1,1,MPI::INT,MPI::SUM,0);</span><br
style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> MPI::COMM_WORLD.Reduce(&unit,&result2,1,MPI::INT,mysum,0);</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> if(unit==0)</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> cout<<"The results via sum&mysum are "<<result1<<" , "<<result2<<endl;</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">}</span><br><br><font size="3">Thank you very much!<br> </font></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>