.
@AhmedMasud, :
http://mpi-forum.org/docs/mpi-3.1/mpi31-report/node297.htm#Node297
, , , Irecv, - ( MPI ).
, , . , : - MPI? , - , Irecv Isend, - , , (, , ( )).
, ?
0- > 1, 1- > 2... n-1- > n, n- > 0, ( ), ( , : -)):
template<class Type>
void Parallel::sendUp(Type& bufferSend,
Type& bufferRec,
long len)
{
if(this->rank()%2==0)
{
if(this->rank()!=this->size()-1)
{
this->send(bufferSend,len,this->rank());
}
if(this->rank()!= 0)
{
this->receive(bufferRec,len,this->rank()-1);
}
else if(this->size()%2==0)
{
this->receive(bufferRec,len,this->size()-1);
}
}
else
{
this->receive( bufferRec, len , this->rank()-1);
if(this->grid_rank()!=this->grid_size()-1)
{
this->send(bufferSend,len,this->rank()+1);
}
else
{
this->send( bufferSend, len , 0);
}
}
if(this->size()%2!=0)
{
if(this->rank()==this->size()-1)
{
this->send( bufferSend, len , 0);
}
if(this->grid()==0)
{
this->receive(bufferRec, len , this->size()-1);
}
}
}
"" MPI, :
parallel.rank() = rank in the comm
parallel.size() = size of the comm
parallel.send/rec() is defined as follow
template<class Type>
void Parallel::send(Type* array, int len, int to)
{
MPI_Send(array, len*sizeof(Type), MPI_BYTE, to, 0,comm_);
}
template<class Type>
void Parallel::rec(Type* array, int len, int to)
{
MPI_Send(array, len*sizeof(Type), MPI_BYTE, to, 0,comm_);
}
template<class Type>
MPI_Status Parallel2d::receive(Type& array, int from, int len)
{
MPI_Status status;
MPI_Recv( &array, len*sizeof(Type), MPI_BYTE, from, 0,comm_,&status);
return status;
}
, .