On Thu, Apr 2, 2009 at 2:09 PM, Khan, Irfan <span dir="ltr"><<a href="mailto:irfan.khan@gatech.edu">irfan.khan@gatech.edu</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
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.</blockquote>
<div><br>1) The ghost update is independent of the method used to set values<br><br>2) Getting the array is general faster than a function call<br><br> Matt<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Thank you<br>
Irfan<br>
<br>
----- Original Message -----<br>
From: "Jed Brown" <jed@59A2.org><br>
To: <a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a><br>
Sent: Thursday, April 2, 2009 2:16:09 PM GMT -05:00 US/Canada Eastern<br>
Subject: Re: setting values in parallel vectors<br>
<br>
On Thu 2009-04-02 12:54, Khan, Irfan wrote:<br>
> Hello<br>
> 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.<br>
><br>
> Using VecGhostGetLocalForm:<br>
><br>
> - Obtain the local array form of global vector using VeGhostGetLocalForm() and VecGetArray()<br>
> - Fill in the values<br>
> - Use VecGhostRestoreLocalForm() and VecRestoreArray()<br>
> - Use VecGhostUpdateBegin() and VecGhostUpdateEnd()<br>
><br>
> Using VecSetValues:<br>
><br>
> - Fill in the values of the values in the global parallel vector using VecSetValues()<br>
> - Use VecAssemblyBegin() and VecAssemblyEnd()<br>
><br>
><br>
> Please note that in both the cases the values being filled are local values to the rank.<br>
<br>
These choices are not equivalent. Assuming you use<br>
<br>
VecGhostUpdateBegin(x,INSERT_VALUES,SCATTER_FORWARD);<br>
VecGhostUpdateEnd(x,INSERT_VALUES,SCATTER_FORWARD);<br>
<br>
the ghosted values will be updated on every process. In contrast<br>
VecAssemblyBegin/End only updates the owner's copy, it knows nothing<br>
about the ghost values. If you are only setting owned values,<br>
VecAssembly* does almost nothing, you will still have to update the<br>
ghost values. Note that if you only need owned values, you can call<br>
VecGetArray on the global form instead of working with the local form.<br>
<br>
Setting local values directly after VecGetArray (with or without the<br>
local form) is faster, but it's irrelevant (VecSetValues is plenty<br>
fast).<br>
<br>
Jed<br>
</blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>