[petsc-users] Clarification of INSERT_VALUES for vec with ghost nodes
Zhang, Junchao
jczhang at mcs.anl.gov
Thu Sep 26 11:02:50 CDT 2019
With VecGhostUpdateBegin(v, INSERT_VALUES, SCATTER_REVERSE), the owner will get updated by ghost values. So in your case 1, proc0 gets either value1 or value2 from proc1/2; in case 2; proc0 gets either value0 or value2 from proc1/2.
In short, you could not achieve your goal with INSERT_VALUES. Though you can do it with other interfaces in PETSc, e.g., PetscSFReduceBegin/End, I believe it is better to extend VecGhostUpdate to support MAX/MIN_VALUES, because it is a simpler interface for you and it is very easy to add.
Could you try branch jczhang/feature-vscat-min-values to see if it works for you? See the end of src/vec/vec/examples/tutorials/ex9.c for an example of the new functionality. Use mpirun -n 2 ./ex9 -minvalues to test it and its expected output is output/ex9_2.out
Petsc will have a new release this weekend. Let's see whether I can put it in the new release.
Thanks.
--Junchao Zhang
On Thu, Sep 26, 2019 at 3:28 AM Aulisa, Eugenio <Eugenio.Aulisa at ttu.edu<mailto:Eugenio.Aulisa at ttu.edu>> wrote:
On Wed, Sep 25, 2019 at 9:11 AM Aulisa, Eugenio via petsc-users <petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>> wrote:
Hi,
I have a vector with ghost nodes where each process may or may not change the value of a specific ghost node (using INSERT_VALUES).
At the end I would like for each process, that see a particular ghost node, to have the smallest of the set values.
Do you mean owner of ghost nodes gets the smallest values. That is, in your example below, proc0 gets Min(value0, value1, value2)?
If I can get the Min(value0, value1, value2) on the owner then I can scatter it forward with INSERT_VALUES to all processes that ghost it. And if there is a easy way to get Min(value0, value1, value2) on the owner (or on all processes) I would like to know.
Since I do not think there is a straightforward way to achieve that, I was looking at a workaround, and to do that I need to know the behavior of scatter reverse in the cases described below. Notice that I used the option INSERT_VALUES which I am not even sure is allowed.
I do not think there is a straightforward way to achieve this, but I would like to be wrong.
Any suggestion?
%%%%%%%%%%%%%%%%
To build a work around I need to understand better the behavior of VecGhostUpdateBegin(...); VecGhostUpdateEnd(...).
In particular in the documentation I do not see the option
VecGhostUpdateBegin(v, INSERT_VALUES, SCATTER_REVERSE);
VecGhostUpdateEnd(v, INSERT_VALUES, SCATTER_REVERSE);
In case this is possible to be used, what is the behavior of this call in the following two cases?
1) Assume that node-i belongs to proc0, and is ghosted in proc1 and proc2, also
assume that the current value of node-i is value0 and proc0 does not modify it, but proc1 and proc2 do.
start with:
proc0 -> value0
proc1 -> value0
proc2 -> value0
change to:
proc0 -> value0
proc1 -> value1
proc2 -> value2
I assume that calling
VecGhostUpdateBegin(v, INSERT_VALUES, SCATTER_REVERSE);
VecGhostUpdateEnd(v, INSERT_VALUES, SCATTER_REVERSE);
will have an unpredictable behavior as
proc0 -> either value1 or value2
proc1 -> value1
proc2 -> value2
2) Assume now that node-i belongs to proc0, and is ghosted in proc1 and proc2, also
assume that the current value of node-i is value0 and proc0 and proc1 do not modify it, but proc2 does.
start with:
proc0 -> value0
proc1 -> value0
proc2 -> value0
change to:
proc0 -> value0
proc1 -> value0
proc2 -> value2
Is the call
VecGhostUpdateBegin(v, INSERT_VALUES, SCATTER_REVERSE);
VecGhostUpdateEnd(v, INSERT_VALUES, SCATTER_REVERSE);
still unpredictable?
proc0 -> either value0 or value2
proc1 -> value0
proc2 -> value2
or
proc0 -> value2 (since proc1 did not modify the original value, so it did not reverse scatter)
proc1 -> value0
proc2 -> value2
Thanks a lot for your help
Eugenio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190926/98ed1ebc/attachment-0001.html>
More information about the petsc-users
mailing list