LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Brian Barrett (brbarret_at_[hidden])
Date: 2005-05-09 14:19:22


On May 9, 2005, at 2:15 PM, Brian Barrett wrote:

> On May 9, 2005, at 11:29 AM, Steve Lowder wrote:
>
>
>> I’m trying to understand some of the memory allocation issues
>> about this code.
>>
>> When the first two derived types are created, I assume that memory
>> is allocated for opaque objects and the handle is stored in the
>> variables oneslice and twoslice. If this was inside a subroutine
>> and called many times, I would assume I need to explicitly free
>> these objects inside the subroutine prior to exit otherwise I have
>> small memory leak. Is this correct?
>>
> Correct - you need to use MPI_TYPE_FREE() to free created datatypes
> or a resource leak will occur.

Apologize everyone, but I clicked the "send" button a bit too fast.
I wanted to follow up on something David Cronk mentioned. Creating a
datatype is not necessarily a quick operation. If you are going to
use the same datatype more than once, it's much better to build it
once and stick the handle somewhere you can reuse it. Otherwise, you
are going to spend an awful lot of time building datatypes. This is
actually one of the places MPI implementations are getting a bit
slower. As the datatype engines get better (so they do something
faster than repacking a buffer), the work required to build a
datatype is bigger. Most applications don't use more than a couple
user-defined datatypes, so it's generally a much better idea to
optimize the usage at the cost of building than vice-versa. So reuse
those datatypes :).

Brian