这是 How do I free a boost::mpi::request? 的后续问题.在收听列表而不是单个项目时,我注意到奇怪的行为。这是我的错误还是boost的错误?我正在使用 MSVC 和 MSMPI,Boost 1.62。我很确定它在等待取消的作业时表现不正常。
如果您使用 mpiexec -n 2 尝试版本 B,那么您将得到一个干净的退出 - 如果您尝试版本 A,它会无限期地挂起。大家也看到了吗?这是错误吗?
#include "boost/mpi.hpp"
#include "mpi.h"
#include <list>
#include "boost/serialization/list.hpp"
int main()
{
MPI_Init(NULL, NULL);
MPI_Comm regional;
MPI_Comm_dup(MPI_COMM_WORLD, ®ional);
boost::mpi::communicator comm = boost::mpi::communicator(regional, boost::mpi::comm_attach);
if (comm.rank() == 1)
{
//VERSION A:
std::list<int> q;
boost::mpi::request z = comm.irecv<std::list<int>>(1, 0, q);
z.cancel();
z.wait();
//VERSION B:
// int q;
// boost::mpi::request z = comm.irecv<int>(1, 0, q);
// z.cancel();
// z.wait();
}
MPI_Comm_disconnect(®ional);
MPI_Finalize();
return 0;
}
最佳答案
这显然是 Boost.MPI 中的错误。
对于序列化类型,如 std::list
,取消是从 request::cancel()
转发的至 request::handle_serialized_irecv
,它没有为 ra_cancel
指定正确的处理方式。
关于c++ - Boost MPI 在监听列表时不释放资源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44114624/