I am trying to find out in what cases a potentially blocking boost mpi "send" will actually block and causes a deadlock.
#include <boost/mpi.hpp>
#include <iostream>
int main(int argc, char *argv[])
{
boost::mpi::environment env{argc, argv};
boost::mpi::communicator world;
if (world.rank() == 0)
{
char buffer[14];
const char *c = "Hello, world from 1!";
world.send(1, 1, c, 13);
std::cout << "1--11111n";
world.send(1, 1, c, 13);
std::cout << "1--22222n";
world.recv(1, 1, buffer, 13);
std::cout << "1--33333n";
world.recv(1, 1, buffer, 13);
std::cout << "1--44444n";
buffer[13] = '';
std::cout << buffer << "11 n";
}
else
{
char buffer[14];
const char *c = "Hello, world from 2!";
world.send(0, 1, c, 13);
std::cout << "2--11111n";
world.send(0, 1, c, 13);
std::cout << "2--22222n";
world.recv(0, 1, buffer, 13);
std::cout << "2--33333n";
world.recv(0, 1, buffer, 13);
std::cout << "2--44444n";
buffer[13] = '';
std::cout << buffer << "22 n";
}
}
but it runs just fine and the with this order:
2--11111
2--22222
1--11111
1--22222
1--33333
1--44444
Hello, world 11
2--33333
2--44444
Hello, world 22
I will be grateful if someone could give me a scenario in which I have actually deadlock. How does the potentially blocking boost mpi works?
Thank you.
Aucun commentaire:
Enregistrer un commentaire