[Boost.Uuid] Passing UUIDs with MPI
Hello, I'm having troubles trying to pass a uuid with MPI routines. Since a uuid is serialized as a primitive type, I was expecting it could be declared as an MPI datatype using: BOOST_IS_MPI_DATATYPE(boost::uuids::uuid) and sent via MPI routines. I've written a short program to illustrate the problem. It compiles but produces a "segmentation fault" error when I'm trying to run it: #include <iostream> #include <boost/mpi.hpp> #include <boost/uuid/uuid.hpp> #include <boost/uuid/uuid_io.hpp> #include <boost/uuid/uuid_generators.hpp> #include <boost/uuid/uuid_serialize.hpp> BOOST_IS_MPI_DATATYPE(boost::uuids::uuid) int main() { boost::mpi::environment env; boost::mpi::communicator world; if (world.rank() == 0) { boost::uuids::uuid u; u = boost::uuids::random_generator()(); std::cout << "u = " << u << std::endl; world.send(1, 0, u); } else { boost::uuids::uuid v; world.recv(0, 0, v); std::cout << "v = " << v << std::endl; } return 0; } Does anybody have an idea whether passing uuids would be possible, and if yes what is wrong in my code? Thank you, Didier Devaurs
Hi Didier, On Thu, 10 Jun 2010 22:53 +0200, "Didier Devaurs" <ddevaurs@know-center.at> wrote:
Hello,
I'm having troubles trying to pass a uuid with MPI routines. Since a uuid is serialized as a primitive type, I was expecting it could be declared as an MPI datatype using: BOOST_IS_MPI_DATATYPE(boost::uuids::uuid) and sent via MPI routines.
This makes sense to me from reading the docs: http://www.boost.org/doc/libs/1_43_0/doc/html/mpi/tutorial.html#mpi.user_dat...
I've written a short program to illustrate the problem. It compiles but produces a "segmentation fault" error when I'm trying to run it:
In the same section, I also read that if one uses this optimization (BOOST_IS_MPI_DATATYPE) but shouldn't be, a result could be a segmentation fault.
#include <iostream> #include <boost/mpi.hpp> #include <boost/uuid/uuid.hpp> #include <boost/uuid/uuid_io.hpp> #include <boost/uuid/uuid_generators.hpp> #include <boost/uuid/uuid_serialize.hpp>
BOOST_IS_MPI_DATATYPE(boost::uuids::uuid)
int main() { boost::mpi::environment env; boost::mpi::communicator world;
if (world.rank() == 0) { boost::uuids::uuid u; u = boost::uuids::random_generator()(); std::cout << "u = " << u << std::endl; world.send(1, 0, u); } else { boost::uuids::uuid v; world.recv(0, 0, v); std::cout << "v = " << v << std::endl; } return 0; }
Does anybody have an idea whether passing uuids would be possible, and if yes what is wrong in my code?
Thank you, Didier Devaurs
I do not know much about Boost.MPI. I will continue learning about it to try to solve the problem. Regards, Andy.
On 5 Jul 2010, at 19:08, Andy Tompkins wrote:
Hi Didier,
On Thu, 10 Jun 2010 22:53 +0200, "Didier Devaurs" <ddevaurs@know-center.at> wrote:
Hello,
I'm having troubles trying to pass a uuid with MPI routines. Since a uuid is serialized as a primitive type, I was expecting it could be declared as an MPI datatype using: BOOST_IS_MPI_DATATYPE(boost::uuids::uuid) and sent via MPI routines.
This makes sense to me from reading the docs: http://www.boost.org/doc/libs/1_43_0/doc/html/mpi/tutorial.html#mpi.user_dat...
You have to be very careful when declaring a type as primitive. Declaring a type as a primitive type means that EVERY archive that you want to use the type with has to provide special support for your type. I would strongly discourage you from doing so. BOOST_IS_MPI_DATATYPE(boost::uuids::uuid) can certainly be used, but this implies that either the type is serializable and you provide a serialize function, or you provide special support for the type by manually overloading the get_mpi_datatype function. The recommended course of action is providing a serialize function. Matthias
participants (3)
-
Andy Tompkins
-
Didier Devaurs
-
Matthias Troyer