[petsc-dev] VecGetArrayRead vs. VecGetArrayPrivate

Matthew Knepley knepley at gmail.com
Mon Nov 22 22:22:30 CST 2010


On Mon, Nov 22, 2010 at 10:09 PM, Dmitry Karpeev <karpeev at mcs.anl.gov>wrote:

> This sounds good to me.  While at it, why not make
> VecGet/RestoreArrayRead take a const PetscScalar ** second argument?
> Somewhat unrelated: should VecGet/RestoreArray(Read) be renamed
> VecGet/RestoreLocalArray(Read)?
> This would conform to the IS usage.  I guess that last change would
> have a significant impact on the user code, though.
>

I am against this for the same reasons Barry laid out before. "Local" would
imply
ghost values which are not there.

  Matt


> Dmitry.
>
> On Mon, Nov 22, 2010 at 9:57 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> >
> >   Hg pull; hg update before reading this.
> >
> >   VecGet/RestoreArrayRead() is suppose to be read only.
> VecGet/RestoreArray() is read/write and increases the state of the vector.
> These are the standard public methods.
> >
> >
> >   VecGetArrayPrivate() is read/write but DOES NOT increase the state of
> the vector directly, this is used by Vector operations that manage the
> change in state themselves. For example VecGetArrayPrivate() is used in, for
> example VecScale_Seq() because the VecScale() outer method manages
> increasing the state and preserving the norm value if it was set. If we used
> VecGetArrayRead() in that location (and did not have VecGetArrayPrivate() it
> would be very confusing since in VecScale_Seq() it does change the values so
> read is not appropriate but VecGetArray() would result in a double increase
> in the state and hence lose the VecNorm cached.
> >
> >   In looking at the code now I make the following observation. The state
> increase operation being given inside the outer method (for example
> VecScale) comes from the days when the individual implementations (like
> VecScale_Seq) did not call VecGetArray....() but just accessed the array
> inside the structure directly.  We then went to the model where NO method
> (like VecScale_Seq) was ever suppose to directly access the array and always
> when through a VecGetArray....(), I had to introduce the
> VecGetArrayPrivate() to avoid double increasing the state of the vector (and
> thus losing some cached VecNorms).  I think if we removed ALL the increase
> state from the outer methods (like VecScale) we could remove the
> VecGetArrayPrivate() and always use VecGetArray() or write ones and
> VecGetArrayRead() for read ones inside the private methods. This has to be
> done with care, if all agree I'll do it.
> >
> >
> >   Barry
> >
> >
> > On Nov 22, 2010, at 8:54 PM, Matthew Knepley wrote:
> >
> >> Why would you use Private, since Read jsut seems to call it?
> >>
> >>   Thanks,
> >>
> >>      Matt
> >>
> >> --
> >> 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
> >
> >
>



-- 
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-dev/attachments/20101122/000ebf0a/attachment.html>


More information about the petsc-dev mailing list