[petsc-dev] What's the point of D(A/M)GetGlobalVector?

Barry Smith bsmith at mcs.anl.gov
Fri Aug 27 10:50:22 CDT 2010


On Aug 27, 2010, at 8:47 AM, Jed Brown wrote:

> On Fri, 27 Aug 2010 08:27:22 -0500, Barry Smith <bsmith at mcs.anl.gov> wrote:
>>     It would actually be nice if we made DACreateGlobal/LocalVector()
>> so light-weight that it could be used for work vectors (instead of
>> needing a different set of light weight get routines) but then we
>> would need DADestroyGlobal/Vector() to handle putting back in the free
>> list or need to modify VecDestroy() to handle not actually destroying
>> but managing a free list).
> 
> Hmm, I'm not sure that only having Create versions would be a good
> thing.  Overhead could be reduced to a VecDuplicate, but you still have
> to allocate the memory.  Malloc is plenty fast (~400 cycles everywhere
> I've checked) if you don't touch the memory, but traversing it extra
> times is not ideal, yet the reproducibility of always zeroing newly
> created vectors is handy.  Maybe there are places that malloc() is more
> expensive, or that fragmentation (if you have some very small vectors,
> or are using huge pages) would become a factor.

    If the DACreateVec managed a pool and the destroy put it back in a pool then you would not all this overhead. 

    It is fine to have a DACreate and DAGet but I think it is possible to have just one.

    Barry

> 
> If the vectors are going to be persistent, their life has to be managed
> somehow, in which case the Get versions are needed.  It also helps (me)
> to clarify intent: if I see a Get, then I know the vector is temporary
> without needing to check for a matching Destroy.
> 
> Jed




More information about the petsc-dev mailing list