[petsc-dev] How to add root values to leaves in PetscSF?

Zhang, Junchao jczhang at mcs.anl.gov
Tue Jan 22 16:56:00 CST 2019



On Tue, Jan 22, 2019 at 4:08 PM Jed Brown <jed at jedbrown.org<mailto:jed at jedbrown.org>> wrote:
It is not supported at this time.  What does your use case look like?
Do roots have degree greater than 1?
Yes. Imagine a vecscatter x[0]->y[0], x[1]->y[0], x[1]->y[1],x[2]->y[1]. I build an SF for SCATTER_FORWARD. Now I wan to do SCATTER_REVERSE with ADD_VALUES.
To solve this problem without creating another SF and without breaking current SF API, I propose to add PetscSFBcastAndOp(sf, unit, rootdata, leafdata, op)


"Zhang, Junchao via petsc-dev" <petsc-dev at mcs.anl.gov<mailto:petsc-dev at mcs.anl.gov>> writes:

> On Tue, Jan 22, 2019 at 1:35 PM Matthew Knepley <knepley at gmail.com<mailto:knepley at gmail.com><mailto:knepley at gmail.com<mailto:knepley at gmail.com>>> wrote:
> On Tue, Jan 22, 2019 at 2:23 PM Zhang, Junchao via petsc-dev <petsc-dev at mcs.anl.gov<mailto:petsc-dev at mcs.anl.gov><mailto:petsc-dev at mcs.anl.gov<mailto:petsc-dev at mcs.anl.gov>>> wrote:
> I want to add root values to leaves, and keep root unchanged. PetscSFBcast came to my mind, but unfortunately it only broadcasts roots and does not have an MPI_Op argument like PetscSFReduce for me to choose from INSERT_VALUES, ADD_VALUES, etc.
> Any tips? Thanks.
>
> PS: I met this problem when I tried to implement VecScatter in SF.  In VecScatter, multiple entries of vec x can be scattered to the same entry of vec y, and one entry of x can also be scattered to multiple entries of y.  I want to use one SF for all combinations of SCATTER_FORWARD/BACKWARD, INSERT/ADD_VALUES. It seems impossible with current SF interface.
>
> I think you might want this: https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PetscSF/PetscSFFetchAndOpBegin.html
>
> I read it as: Leaves are accumulated to root (root is changed), and leaves get a snapshot of the root before each atomic update. It is not what I want.
>
>   Thanks,
>
>     Matt
>
> --Junchao Zhang
>
>
> --
> 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
>
> https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20190122/1683c5e3/attachment-0001.html>


More information about the petsc-dev mailing list