Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] About the necessity of cancelation of pending communication and the use of buffer
From: Fernando Lemos (fernandotcl_at_[hidden])
Date: 2010-05-25 09:19:20


On Tue, May 25, 2010 at 1:03 AM, Yves Caniou <yves.caniou_at_[hidden]> wrote:
> 2 ** When I use a Isend() operation, the manpage says that I can't use the
> buffer until the operation completes.
> What happens if I use an Isend() operation in a function, with a buffer
> declared inside the function?
> Do I have to Wait() for the communication to finish before returning, or to
> declare the buffer as a global variable?

If you declare it inside the function (an auto variable), you're
declaring it on the stack. When the function is over, the stack may be
reused and this is gonna have nasty effects. You don't need to declare
the buffer as a global, just allocate it on the heap (with new or
malloc or whatever), just make sure you don't lose track of it cause
you're probably gonna need to free that memory eventually.