首页 \ 问答 \ 等待已经完成的请求(Waiting requests which have been already completed)

等待已经完成的请求(Waiting requests which have been already completed)

我正在尝试使用boost mpi库实现异步消息传递机制(检查点机制)。 在我的代码中,接收者通过irecv等待来自其他人的消息。 在irecv之后,他们不会调用等待函数。 相反,他们称之为测试功能。 如果测试成功,他们将处理收到的消息并启动新的irecv。 否则,他们将前进到检查站。 在检查点期间,他们使用等待功能等待所有传输消息完成。 换句话说,检查点是稳定的同步点。

我简化了下面的代码并希望它很清楚:

接收方:

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);
}    

正如您在上面所看到的,我不得不为已完成的请求调用wait函数。 我的意思是,我为已经成功测试的消息调用了wait函数。 现在,由于这个调用,问题是一个分段错误。 并且,对于boost :: mpi api中的测试函数有一些解释。 它说

你应该注意,一旦@c test()返回一个@c状态对象,请求就完成了,并且不应该调用@c wait()。

实际上,我可以存储无法通过测试功能的请求。 然后,我只能为这些请求调用wait函数。 但是,我想知道如果可以有另一个更简单的解决方案来克服这个问题。


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.

I simplified my code below and hope it is clear:

Receiver side:

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);
        }
    }
}

Sender side:

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);
}    

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

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.


原文:https://stackoverflow.com/questions/31301557
更新时间:2023-04-17 06:04

最满意答案

在Androidmanifest .xml中

 <application
        android:name="your.Packagename.CpuSpyApp"

In Androidmanifest .xml

 <application
        android:name="your.Packagename.CpuSpyApp"

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。