-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
I believe this is a regression from 1.70.
In the following code, an asynchronous recv is initiated then later an other thread marks the operation for cancellation (and that should guarantee wait() to return according to the spec).
This works for fundamental type (such as int) but not for serialized types.
#include <mpi.h>
#include <iostream>
#include <future>
#include <boost/mpi.hpp>
#include <boost/serialization/serialization.hpp>
using namespace std::literals::chrono_literals;
namespace mpi = boost::mpi;
void async_cancel(boost::mpi::request request)
{
std::this_thread::sleep_for(1s);
std::cout << "Before MPI_Cancel" << std::endl;
request.cancel();
std::cout << "After MPI_Cancel" << std::endl;
}
struct data
{
int i;
};
template <typename Archive>
void serialize(Archive& ar, data& t, const unsigned int version)
{
ar & t.i;
}
int main(int argc, char* argv[])
{
mpi::environment env(mpi::threading::level::multiple);
mpi::communicator world;
if (world.rank() == 0)
{
//int buffer; // WORKS
data buffer; // FAILS
auto request = world.irecv(0, 0, buffer);
auto res = std::async(std::launch::async, &async_cancel, request);
std::cout << "Before MPI_Wait" << std::endl;
auto status = request.wait();
std::cout << "After MPI_Wait " << std::endl;
}
else
std::this_thread::sleep_for(2s);
return 0;
}The expected result is:
Before MPI_Wait
Before MPI_Cancel
After MPI_Cancel
After MPI_Wait
Metadata
Metadata
Assignees
Labels
No labels