Boost logo

Boost Users :

Subject: Re: [Boost-users] mpi non-blocking communication
From: Philipp Kraus (philipp.kraus_at_[hidden])
Date: 2010-12-02 14:15:23


On 2010-12-02 18:00:27 +0100, Riccardo Murri said:

> Hi Philipp,
>
> On Thu, Dec 2, 2010 at 4:12 PM, Philipp Kraus
> <philipp.kraus_at_[hidden]> wrote:
>> There is only one problem at the time:  The CPU 0 does not catch every
>> message.
>> The main method:
>>
>> MPI::Init_thread( argc, argv, MPI_THREAD_SERIALIZED );
>> mpi::communicator loMPICom;
>> tl::logger::getInstance()->startListener(loMPICom);
>> tl::logger::getInstance()->write(loMPICom, tl::logger::warn, "test all");
>> tl::logger::getInstance()->shutdownListener(loMPICom);
>> MPI::Finalize();
>>
>>
>> So every process shoudl create a message and the CPU 0 should catch them
>> all. The write method sends the data with isend (non-blocking).
>> The CPU 0 runs a thread in background with
>>
>> while (m_listenerrunnging) {
>>        while (boost::optional<mpi::status> l_status =
>> p_mpi.iprobe(mpi::any_source, LOGGER_MPI_TAG)) {
>>                        std::string l_str;
>>                p_mpi.recv(  l_status->source(),
>> l_status->tag(), l_str );
>>        }
>>        boost::this_thread::yield();
>> }
>>
>
> This code for the background thread will only probe for new messages
> until m_listenerrunnging is true; as soon as it turns to false (in
> logger::getInstance()->shutdownListener?), it will stop and receive no
> more messages.
>
> You probably want to make it run until all messages have arrived. How
> you do this depends on your application: if you know how many messages
> will be coming, just count them; if you don't, make ranks !=1 send an
> "end of transmission" message when they are done and only shutdown the
> listener when all "end of transmission" messages have been received.
> There might be other methods that are more suited to your application.

I have created a end-of-transmission code in my shutdown method. That
works now very well

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