petsc-3.11.2 2019-05-18
Report Typos and Errors


Lock or unlock a vector for exclusive read/write access


#include "petscvec.h"   
PetscErrorCode VecLockWriteSet_Private(Vec x,PetscBool flg)
Logically Collective on Vec

Input Parameter

x - the vector
flg - PETSC_TRUE to lock the vector for writing; PETSC_FALSE to unlock it.


The function is usefull in split-phase computations, which usually have a begin phase and an end phase. One can call VecLockWriteSet_Private(x,PETSC_TRUE) in the begin phase to lock a vector for exclusive access, and call VecLockWriteSet_Private(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_Private(v,PETSC_TRUE);

Other operations, which can not acceess x anymore (they can access xdata, of course)

VecRestoreArray(x,&vdata); // end phase VecLockWriteSet_Private(v,PETSC_FALSE);

The call can not be nested on the same vector, in other words, one can not call VecLockWriteSet_Private(x,PETSC_TRUE) again before calling VecLockWriteSet_Private(v,PETSC_FALSE).

See Also

VecRestoreArray(), VecGetArrayRead(), VecLockReadPush(), VecLockReadPop(), VecLockGet()




Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages