[petsc-dev] multiple VecGetArray

Jed Brown jed at 59A2.org
Tue Aug 31 12:07:47 CDT 2010


On Tue, 31 Aug 2010 11:21:02 -0300, Lisandro Dalcin <dalcinl at gmail.com> wrote:
> Calling VecGetArray multiple times on the same vec seems to work (at
> least for native vectors). However, in VecSeq impl there is code to
> prevent such usage. What's the correct usage?

I think that correct usage should not allow multiple access to the same
vector, so that VecGetArray implies exclusive access.  I think PETSc is
consistent about this internally and it just doesn't check for native
vectors to avoid a function call.

  VecGetArray(X,&x);
  VecGetArray(X,&y);
  FunctionAssumingNoAliasing(x,y);
  VecRestoreArray(X,&x);  /* Is it safe to free buffer/move to GPU? */
  y[0] = 2.;              /* If so, then this line is invalid. */

Jed



More information about the petsc-dev mailing list