[mpich-discuss] Help with the source file

KongTao hawk_kongtao at yahoo.com.cn
Sat Apr 9 09:08:18 CDT 2011


I Write the following  MPI source file binding with c++, it is error ,why ? can anyone help me to fix it?

-----
void sumfunc(const void* x,void * y,int length,const MPI::Datatype & dtype)
{
    int n=dtype.Get_size();
    for(int i=0;i<length;i++)
        *(y+n*i)=*(x+n*i)+*(y+n*i);
    return;
}

void op_test(){
    MPI::Op mysum;
    mysum.Init(sumfunc,true);
    int unit=pow(MPI::COMM_WORLD.Get_size(),3);
    int result1,result2;
    MPI::COMM_WORLD.Reduce(&unit,&result1,1,MPI::INT,MPI::SUM,0);
    MPI::COMM_WORLD.Reduce(&unit,&result2,1,MPI::INT,mysum,0);
    if(unit==0)
        cout<<"The results via sum&mysum are "<<result1<<" , "<<result2<<endl;
}

Thank you very much!
 
---
Kong Tao
School of Maths,Shandong Univ. P.R.C.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20110409/b7684169/attachment.htm>


More information about the mpich-discuss mailing list