On Nov 1, 2004, at 3:47 PM, atarpley wrote:
> I am trying to do a non-blocking send in MPI. I realize there is a
> function
> called MPI_Isend. This would be fine, except for the requirement that
> the
> buffer not be modified until after the request has been completed by a
> call to
> one of the (blocking) wait MPI functions.
Mostly right -- you can use MPI_TEST (or any of its variants), too,
which do not block. They provide polling functionality.
> I want to deallocate the send
> buffer after the message is on it's way -- am I forced to block so I
> can
> safely do this?
Yes. You can't send a message from a buffer that has been freed (i.e.,
is no potentially longer part of the process) -- that would cause MPI
to [potentially] later read from the buffer that has now been freed.
This could cause a seg fault or other nastiness.
> Why wouldn't I just use MPI_Send if I have to call a blocking
> wait for a nonblocking send to complete?
Because you can do all kinds of other things (unrelated to MPI) in
between when you call MPI_ISEND and MPI_TEST / MPI_WAIT. It gives you
the ability to potentially overlap communication and computation. It's
not intended to be a "fire and forget" mechanism.
> I am converting to MPI from PVM so
> maybe there is a MPI call that acts similarly to pvm_send? I want to
> avoid
> deadlock and I thought that MPI_Isend was the way to do it but now I
> am having
> second thoughts because of the need to call MPI_wait.
You may want to investigate the buffered send modes (MPI_BSEND and
friends). This will cause MPI to copy your buffer before returning so
that you can free your buffer immediately. But be aware that this
definitely causes a performance degredation -- it *forces* an
additional memory copy.
--
{+} Jeff Squyres
{+} jsquyres_at_[hidden]
{+} http://www.lam-mpi.org/
|