[MPI] lifetime of data sent through communicator::isend()

Hello, I'm using mpi::communicator::isend where the payload data comes from a pointer (e.g., "req = comm_.isend(dest, tag. *data)"). When am I free to "delete" the pointer? Immediately after isend() returns? Or should I wait until the request is completed? Does setting BOOST_MPI_HOMOGENEOUS have any influence on this? Best regards, Riccardo

Hi Riccardo, On Nov 20, 2010, at 11:50 AM, Riccardo Murri wrote:
I'm using mpi::communicator::isend where the payload data comes from a pointer (e.g., "req = comm_.isend(dest, tag. *data)"). When am I free to "delete" the pointer? Immediately after isend() returns? Or should I wait until the request is completed?
According to the documentation, isend is non-blocking and returns immediately. I think you'll need to query the returned request object to determine when you can safely delete the pointer (after the message has been delivered).
Does setting BOOST_MPI_HOMOGENEOUS have any influence on this?
I'm not sure about this. -- Noel

Hi,
On Sat, 20 Nov 2010 19:50:02 +0100
Riccardo Murri
Hello,
I'm using mpi::communicator::isend where the payload data comes from a pointer (e.g., "req = comm_.isend(dest, tag. *data)"). When am I free to "delete" the pointer? Immediately after isend() returns? Or should I wait until the request is completed?
yes, you have to wait before you can free your memory. See http://www.mpi-forum.org/docs/mpi22-report/node57.htm and the following pages.
Does setting BOOST_MPI_HOMOGENEOUS have any influence on this?
It should not have any influence on this. Heiko -- -- Wer das Leben nicht schätzt, der verdient es nicht. (Leonardo da Vinci) -- Number Crunch Blog @ http://numbercrunch.de -- Cluster Computing @ http://www.clustercomputing.de -- Heiko Bauke @ http://www.mpi-hd.mpg.de/personalhomes/bauke

Hi Heiko and Noel,
On Sun, Nov 21, 2010 at 9:27 AM, Heiko Bauke
Riccardo Murri
wrote: I'm using mpi::communicator::isend where the payload data comes from a pointer (e.g., "req = comm_.isend(dest, tag. *data)"). When am I free to "delete" the pointer? Immediately after isend() returns? Or should I wait until the request is completed?
yes, you have to wait before you can free your memory. See http://www.mpi-forum.org/docs/mpi22-report/node57.htm and the following pages.
Thanks for the answers. However, I think I didn't make myself clear: I know what I should do with the C-level MPI_ISend() calls, I'm not sure what I can do after an Boost.MPI's communicator::isend(). My reading of the docs is that Boost.MPI creates an instance of boost::mpi::packed_oarchive archive and sends *that* one with MPI_ISend(). So the question is: can I "delete data;" immediately after I do "communicator::isend(..., *data);", or does the Boost.MPI archive hold a reference to the "*data" buffer? In other words, does Boost.MPI *copy* data into the archive or does it just reference it somehow? Thanks again and best regards, Riccardo

Hi Riccardo, On Nov 21, 2010, at 2:18 AM, Riccardo Murri wrote:
On Sun, Nov 21, 2010 at 9:27 AM, Heiko Bauke
wrote: Riccardo Murri
wrote: I'm using mpi::communicator::isend where the payload data comes from a pointer (e.g., "req = comm_.isend(dest, tag. *data)"). When am I free to "delete" the pointer? Immediately after isend() returns? Or should I wait until the request is completed?
yes, you have to wait before you can free your memory. See http://www.mpi-forum.org/docs/mpi22-report/node57.htm and the following pages.
Thanks for the answers. However, I think I didn't make myself clear: I know what I should do with the C-level MPI_ISend() calls, I'm not sure what I can do after an Boost.MPI's communicator::isend().
My reading of the docs is that Boost.MPI creates an instance of boost::mpi::packed_oarchive archive and sends *that* one with MPI_ISend(). So the question is: can I "delete data;" immediately after I do "communicator::isend(..., *data);", or does the Boost.MPI archive hold a reference to the "*data" buffer? In other words, does Boost.MPI *copy* data into the archive or does it just reference it somehow?
It seems you're asking what the Boost.MPI implementation does and, to me, you shouldn't depend on an implementation detail of Boost.MPI for the correct operation of your code. I'd stick to the documented behavior and either use a blocking form of send so that you know you're free to release the data once send returns, or use iSend and correctly interrogate or wait on the returned request object. -- Noel

On 21 Nov 2010, at 10:18, Riccardo Murri wrote:
Hi Heiko and Noel,
On Sun, Nov 21, 2010 at 9:27 AM, Heiko Bauke
wrote: Riccardo Murri
wrote: I'm using mpi::communicator::isend where the payload data comes from a pointer (e.g., "req = comm_.isend(dest, tag. *data)"). When am I free to "delete" the pointer? Immediately after isend() returns? Or should I wait until the request is completed?
yes, you have to wait before you can free your memory. See http://www.mpi-forum.org/docs/mpi22-report/node57.htm and the following pages.
Thanks for the answers. However, I think I didn't make myself clear: I know what I should do with the C-level MPI_ISend() calls, I'm not sure what I can do after an Boost.MPI's communicator::isend().
My reading of the docs is that Boost.MPI creates an instance of boost::mpi::packed_oarchive archive and sends *that* one with MPI_ISend(). So the question is: can I "delete data;" immediately after I do "communicator::isend(..., *data);", or does the Boost.MPI archive hold a reference to the "*data" buffer? In other words, does Boost.MPI *copy* data into the archive or does it just reference it somehow?
Hi Riccardo, It actually does not even create the packed_oarchive until you wait on the request. Matthias
participants (4)
-
Belcourt, K. Noel
-
Heiko Bauke
-
Matthias Troyer
-
Riccardo Murri