如何知道MPI请求的接收者和发送者
我想知道是否有一种方法可以知道接收器进程,发送者进程和MPI通信在boost中的标签值。
I wonder if there is a way to know the receiver process, the sender process and tag values of an MPI communication in boost.
现在,我有一些进程其彼此发送/接收大量消息。而且,我在接收器端有一个boost :: mpi :: request的集合。此集合存储已接收的请求项目。在通信操作完成后,我可以从这个集合中提取接收者进程和发送者进程是谁吗? (我还需要知道标签的值。)或者,我应该改变我的策略?
Now, I have some processes which send/receive a lot of messages to/from each other. And, I have a collection of boost::mpi::request in the receiver side. This collection stores the request items that have been received. After the communication operations are completed, can I extract who the receiver process and the sender process are, from this collection? (I also need to know the tag value.) Or, should I change my strategy? Maybe having a collection of requests does not make sense?
这些信息在请求完成后处于状态,而不是在请求本身。
That information is in the status after the request is completed, not in the request itself.
#include <boost/mpi.hpp>
#include <iostream>
#include <string>
#include <boost/serialization/string.hpp>
namespace mpi = boost::mpi;
int main()
{
mpi::environment env;
mpi::communicator world;
if (world.rank() == 0) {
std::string msg, out_msg = "Hello from rank 0.";
world.send(1, 17, out_msg);
} else {
mpi::request req[1];
mpi::status stat[1];
std::string rmsg;
req[0] = world.irecv(mpi::any_source, mpi::any_tag, rmsg);
mpi::wait_all(req, req + 1, stat);
std::cout << "Got " << rmsg << std::endl;
std::cout << "From " << stat[0].source() << std::endl;
std::cout << "Tagged " << stat[0].tag() << std::endl;
}
return 0;
}