在MPI中,有非阻塞呼叫,如MPI_Isend
和MPI_Irecv
。MPI非阻塞通信和pthreads的区别?
如果我在一个p2p项目上工作,服务器将听很多客户端。
一种方式做到这一点:
for(int i = 1; i < highest_rank; i++){
MPI_Irecv(....,i,....statuses[i]); //listening to all slaves
}
while(true){
for(int i = 1; i < highest_rank; i++){
checkStatus(statuses[i])
if true do somthing
}
另一种老办法,我能做到这一点是:
Server creating many POSIX threads, pass in a function,
that function will call MPI_Recv and loop forever.
理论上,哪一个会在服务器端执行得更快?如果还有另一种更好的方式来编写服务器,请让我知道。
问:如果使用MPI_ANY_SOURCE,我能否知道哪个药膏向我发送了这个请求? – SDEZero 2013-02-10 01:40:16
@LouisTan是的,检查这个主从模型是建立在该原理http://www.lam-mpi.org/tutorials/one-step/ezstart.php – pyCthon 2013-02-10 03:17:04
@pyCthon伟大的教程,非常感谢! – SDEZero 2013-02-10 06:14:17