Boost logo

Boost Users :

Subject: Re: [Boost-users] mpi non-blocking communication
From: Kraus Philipp (philipp.kraus_at_[hidden])
Date: 2010-11-28 11:44:13


Am 28.11.2010 um 13:42 schrieb Riccardo Murri:

> On Sun, Nov 28, 2010 at 1:25 PM, Philipp Kraus
> <philipp.kraus_at_[hidden]> wrote:
>> I understand the recv in this way, that it waits until a message is
>> send. I
>> think if I have no messages, the receive blocks the loop, do it?
>> I would like to create the code in that way:
>>
>> while (...) {
>> while mpi-message-is-there
>> do something
>> }
>>
>
> Indeed, `recv` is a blocking call. To receive a message only if one
> is available, you need to probe for it first, and then receive.
> Something along these lines::
>
>
> while(...) {
> while(boost::optional<mpi::status> status =
> p_comm.iprobe(mpi::any_source, TAG)) {
> // a message is available, receive it
> mpi::recv(status->source(), status->tag(), l_str);
> // process `l_str`
> };
> // ...
> };
>
> Caveat: use `status->source()` and `status->tag()` in the recv call to
> ensure you recv the message that you probed for (this may still fail
> if you're running iprobe/recv loops in several threads concurrently
> within the same MPI process).

Thanks, this works very well.

I'll get now some compiler warning in the boost::optional line

Boost/1.45/include/boost/mpi/status.hpp: In member function 'void
machinelearning::tools::logger::listener(const
boost::mpi::communicator&)':
/Boost/1.45/include/boost/mpi/status.hpp:48: warning: dereferencing
pointer '<anonymous>' does break strict-aliasing rules

Do you think this warnings can be create a problem?

Thanks

Phil


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