setting values in parallel vectors

Matthew Knepley knepley at gmail.com
Thu Apr 2 14:18:56 CDT 2009


On Thu, Apr 2, 2009 at 2:09 PM, Khan, Irfan <irfan.khan at gatech.edu> wrote:

> Thank you, that was very helpful. Please do let me know if I understood
> this right. Generally VecSetValues()+VecGhostUpdateBegin/End() is faster
> than
> VecGetArray()+assign_array()+VecRestoreArray()+VecGhostUpdateBegin/End().
> Also both these operation would be equivalent.


1) The ghost update is independent of the method used to set values

2) Getting the array is general faster than a function call

  Matt


>
> Thank you
> Irfan
>
> ----- Original Message -----
> From: "Jed Brown" <jed at 59A2.org>
> To: petsc-users at mcs.anl.gov
> Sent: Thursday, April 2, 2009 2:16:09 PM GMT -05:00 US/Canada Eastern
> Subject: Re: setting values in parallel vectors
>
> On Thu 2009-04-02 12:54, Khan, Irfan wrote:
> > Hello
> > I have a question about setting values in parallel vectors. Which of the
> following two options is more efficient or does it matter at all.
> >
> > Using VecGhostGetLocalForm:
> >
> >  - Obtain the local array form of global vector using
> VeGhostGetLocalForm() and VecGetArray()
> >  - Fill in the values
> >  - Use VecGhostRestoreLocalForm() and VecRestoreArray()
> >  - Use VecGhostUpdateBegin() and VecGhostUpdateEnd()
> >
> > Using VecSetValues:
> >
> >  - Fill in the values of the values in the global parallel vector using
> VecSetValues()
> >  - Use VecAssemblyBegin() and VecAssemblyEnd()
> >
> >
> > Please note that in both the cases the values being filled are local
> values to the rank.
>
> These choices are not equivalent.  Assuming you use
>
>  VecGhostUpdateBegin(x,INSERT_VALUES,SCATTER_FORWARD);
>  VecGhostUpdateEnd(x,INSERT_VALUES,SCATTER_FORWARD);
>
> the ghosted values will be updated on every process.  In contrast
> VecAssemblyBegin/End only updates the owner's copy, it knows nothing
> about the ghost values.  If you are only setting owned values,
> VecAssembly* does almost nothing, you will still have to update the
> ghost values.  Note that if you only need owned values, you can call
> VecGetArray on the global form instead of working with the local form.
>
> Setting local values directly after VecGetArray (with or without the
> local form) is faster, but it's irrelevant (VecSetValues is plenty
> fast).
>
> Jed
>



-- 
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20090402/da706171/attachment.htm>


More information about the petsc-users mailing list