这已经被完成等待请求 [英] Waiting requests which have been already completed

查看:97
本文介绍了这已经被完成等待请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现使用boost MPI库异步消息传递机制(点校验机制)。在我的code,接收器等经由irecv别人的消息。在irecv后,他们不叫等待功能。相反,他们所谓的测试功能。如果测试成功,它们会处理所接收的消息,并启动一个新的irecv。否则,他们会提前到检查点。在检查站,他们等待所有的在途信息使用等待函数来完成。换句话说,检查点是稳定的同步点。

I am trying to implement an asynchronous messaging mechanism (a checkpointing mechanism) using boost mpi library. In my code, receivers wait a message from the others via irecv. After the irecv, they do not call wait function. Instead, they call the test function. If test is successful, they will process the received message and start a new irecv. Else, they will advance until the checkpoint. During the checkpoint, they wait all of the in transit messages to be completed using wait function. In other words, checkpoints are stable synchronization points.

我在下面简化我的code,并希望它是明确的:

I simplified my code below and hope it is clear:

接收侧:

mpiReceiveRequest = RepastProcess::instance()->getCommunicator()->irecv(1, 100, receivedData);

for(int i=0; i<=20; i++){
    if(i%5 == 0){   // checkpoints
        while(true){
            mpiReceiveRequest.wait();
            if(receivedData > 0)
                mpiReceiveRequest = world.irecv(1, 100, receivedData);
            else
                break;
        }

    }

    else{
        if(mpiReceiveRequest.test()){
            if(receivedData > 0)
                mpiReceiveRequest = world.irecv(1, 100, receivedData);
        }
    }
}

发送方:

for(int i=0; i<=20; i++){
    int randomNumber = // select a random number between 1-20
    if(i > randomNumber)
        world.isend(0, 100, i);
    else
        world.isend(0, 100, -1);
}    

正如你可以在上面看到,我不得不打电话等功能完成的请求。我的意思是,我所说的等待功能为已试验成功的消息。现在,问题是一个分割的错,因为这一呼吁的。此外,还有关于测试功能的boost :: MPI API一些解释。它说,

As you can see above, I had to call wait function for completed requests. I mean, I call the wait function for an already successfully tested message. Now, problem is a segmentation fault because of this call. And, there are some explanations about test function in boost::mpi api. It says that

您应该注意,一旦@c测试()返回一个@c状态对象,请求完成并等待@c()不应该叫。

you should Note that once @c test() returns a @c status object, the request has completed and @c wait() should not be called.

其实,我可以存储未能通过测试功能的要求。然后,我可以调用等待功能仅用于这些请求。不过,我想知道,如果有可以克服这个问题的另一个简单的解决方案。

Actually, I can store the requests which could not pass the test function. Then, I can call wait function for only these requests. However, I am wondering that if there can be another simpler solution for overcoming this issue.

推荐答案

这是我能找到的存储而无法通过测试功能的要求,然后使用等待或升压库wait_all功能等待着它们的唯一解决方案。

The only solution that I could find is storing the requests which could not pass the test function, then waiting them using wait or wait_all function of boost library.

这篇关于这已经被完成等待请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆