gpt4 book ai didi

c++ - MPI_测试 : MPI_ERR_TRUNCATE

转载 作者:行者123 更新时间:2023-11-28 05:08:08 27 4
gpt4 key购买 nike

下面的代码给出了这个错误信息:

terminate called after throwing an instance of 'boost::exception_detail::clone_impl'
what(): MPI_Test: MPI_ERR_TRUNCATE: message truncated

该问题可能与 boost::mpi 的一个错误有关,该错误在 this post 中有所讨论。 .我想确定错误的原因。

如果我只循环一次 ( for (int z=0; z<1; ++z) ) 但对于 z<2 则代码有效我收到提到的错误消息。

#include <boost/mpi.hpp>

class MyClass
{
std::vector<double> vec;

public:

void send_data(const boost::mpi::communicator& world, boost::mpi::request& req)
{
if (world.rank() == 0)
{
vec.resize(1000);
req = world.isend(1, 0, vec);
}
}

void recv_data(const boost::mpi::communicator& world)
{
if (world.rank() == 1)
{
while (true)
{
boost::mpi::request req = world.irecv(boost::mpi::any_source, 0, vec);
if (!req.test())
{
req.cancel();
//req.wait(); <-- hangs the program.
break;
}
}
}
}
};

int main()
{
boost::mpi::environment env;
boost::mpi::communicator world;

MyClass myclass;

for (int z=0; z<2; ++z) // works if loop only once.
{
boost::mpi::request req;

myclass.send_data(world, req);
world.barrier();
myclass.recv_data(world);
world.barrier();
if (world.rank() == 0)
req.wait();
}

return 0;
}

最佳答案

a bug当同一个通信器上有多个 irecv 时,标签、序列化类型的源似乎非常相关。所以你可以尝试使用不同的标签。然而,由于取消的错误,它不会工作......

关于c++ - MPI_测试 : MPI_ERR_TRUNCATE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44162979/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com