MPI_Test: MPI_ERR_TRUNCATE

599 views Asked by At

The following code gives this error message:

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

The problem might be related to a bug of boost::mpi which is discussed in this post. I want to be sure about reason of the error.

The code works if I loop only once (for (int z=0; z<1; ++z)) but for z<2 I get the mentioned error message.

#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;
}
1

There are 1 answers

2
Zulan On

There is a bug when there are multiple irecv on the same communicator, tag, source for serialized types that seems very related. So you could try that with different tags. Nevertheless it wouldn't work due to the bug with cancel...