VecLockWriteSet#
Lock or unlock a vector for exclusive read/write access
Synopsis#
#include "petscvec.h"
PetscErrorCode VecLockWriteSet(Vec x, PetscBool flg)
Logically Collective
Input Parameters#
x - the vector
flg -
PETSC_TRUE
to lock the vector for exclusive read/write access;PETSC_FALSE
to unlock it.
Notes#
The function is useful in split-phase computations, which usually have a begin phase and an end phase.
One can call VecLockWriteSet
(x,PETSC_TRUE
) in the begin phase to lock a vector for exclusive
access, and call VecLockWriteSet
(x,PETSC_FALSE
) in the end phase to unlock the vector from exclusive
access. In this way, one is ensured no other operations can access the vector in between. The code may like
VecGetArray(x,&xdata); // begin phase
VecLockWriteSet(v,PETSC_TRUE);
Other operations, which can not access x anymore (they can access xdata, of course)
VecRestoreArray(x,&vdata); // end phase
VecLockWriteSet(v,PETSC_FALSE);
The call can not be nested on the same vector, in other words, one can not call VecLockWriteSet
(x,PETSC_TRUE
)
again before calling VecLockWriteSet
(v,PETSC_FALSE
).
See Also#
Vectors and Parallel Data, Vec
, VecRestoreArray()
, VecGetArrayRead()
, VecLockReadPush()
, VecLockReadPop()
, VecLockGet()
Level#
intermediate
Location#
src/vec/vec/interface/rvector.c
Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages