setting values in parallel vectors
Jed Brown
jed at 59A2.org
Thu Apr 2 13:16:09 CDT 2009
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20090402/3f357d59/attachment.pgp>
More information about the petsc-users
mailing list