Boost logo

Boost Users :

Subject: Re: [Boost-users] mpi/serialization: broadcast function and the value argument
From: Hicham Mouline (hicham_at_[hidden])
Date: 2010-12-13 19:00:23


-----Original Message-----
From: "Matthias Troyer" [troyer_at_[hidden]]
Date: 13/12/2010 09:57 PM
To: "Hicham Mouline"
CC: boost-users_at_[hidden]
Subject: Re: [Boost-users] mpi/serialization: broadcast function and the value argument

>> mpi::broadcast() appears to be incapable of sending the argument "value" in a polymorphic way, ie:
>>
>> sender-------------------
>> Base* base;
>> If I call boost::mpi::broadcast(..., base, ...)
>>
>>
>> receiver-----------------
>> Base* base;
>> boost::mpi::broadcast(..., base, ...)
>> This does not construct the most derived type of base on the heap and make base point there, as serialization would do.

>Did you register the most derived type?
Yes I have all types.

>Did you test whether pointer deserialization works with other serialization archives?
>Matthias

I will test.

However, this code from boost\mpi\collectives\broadcast.hpp (see where I put the comment marker)

  // We're sending a type that does not have an associated MPI
  // datatype, so we'll need to serialize it. Unfortunately, this
  // means that we cannot use MPI_Bcast, so we'll just send from the
  // root to everyone else.
  template<typename T>
  void
  broadcast_impl(const communicator& comm, T* values, int n, int root,
                 mpl::false_)
  {
    if (comm.rank() == root) {
      packed_oarchive oa(comm);
      for (int i = 0; i < n; ++i)
        oa << values[i];
      broadcast(comm, oa, root);
    } else {
      packed_iarchive ia(comm);
      broadcast(comm, ia, root);
      for (int i = 0; i < n; ++i)
        ia >> values[i]; ///////////////////////////////////////////////////////////////////
    }
  }

template<typename T>
void broadcast(const communicator& comm, T& value, int root)
{
  detail::broadcast_impl(comm, &value, 1, root, is_mpi_datatype<T>());
}

template<typename T>
void broadcast(const communicator& comm, T* values, int n, int root)
{
  detail::broadcast_impl(comm, values, n, root, is_mpi_datatype<T>());
}

If at the receiver process, I pass a non initialized Base*, it crashes as far as I could see.

PS: I've cc'ed the email in the comments for that file as well.

regards,


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net