[petsc-dev] changes coming to PETSc master branch

Barry Smith bsmith at mcs.anl.gov
Fri Jan 30 13:15:44 CST 2015


  Pushed in barry/feature-vec-lock and next

  Thanks Barry

> On Jan 30, 2015, at 12:36 PM, Satish Balay <balay at mcs.anl.gov> wrote:
> 
> There are nightlybuild errors with this. Perhaps the following is the fix?
> 
> Satish
> 
> ----------
> 
> diff --git a/include/petscvec.h b/include/petscvec.h
> index 1369ff0..3c751d7 100644
> --- a/include/petscvec.h
> +++ b/include/petscvec.h
> @@ -457,9 +457,10 @@ PETSC_EXTERN PetscErrorCode VecLockPush(Vec);
> PETSC_EXTERN PetscErrorCode VecLockPop(Vec);
> #define VecLocked(x,arg) do {PetscInt _st; PetscErrorCode __ierr = VecLockGet(x,&_st); CHKERRQ(__ierr); if (_st > 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE," Vec is locked read only, argument # %d",arg);} while (0)
> #else
> -#define VecLockPush(x) do {} while (0)
> -#define VecLockPop(x)  do {} while (0)
> -#define VecLocked(x,arg)   do {} while (0)
> +#define VecLockGet(x,arg)  *(arg) = 0
> +#define VecLockPush(x)     0
> +#define VecLockPop(x)      0
> +#define VecLocked(x,arg)
> #endif
> 
> PETSC_EXTERN PetscErrorCode VecValidValues(Vec,PetscInt,PetscBool);
> 
> 
> On Thu, 29 Jan 2015, Barry Smith wrote:
> 
>> 
>>  I have implemented Jed's excellant VecLockPush/Pop() idea into a branch and will be merging it into next today and then eventually into master. 
>> 
>>  VecLockPush() puts a vector into read only state which can only be undone by the appropriate number of VecLockPop()s. Routines such as VecSetValues() and VecGetArray() check the read only state and generate errors when it is set. 
>> 
>>  This means that everyone must be much more careful when using VecGetArray() and friends and default to VecGetArrayRead() and friends unless they are specifically changing the values. It also means that many more array variables need to be marked as const (which is always a good thing). I have updated the core PETSc with all these changes but users will need to change code and any outstanding branches may need these changes also to work cleanly with next.
>> 
>>   Barry
>> 
>> It is a minor headache now but is a good move going forward. Why I didn't do it in 1994 I'll never know.
>> 
>> 
> 




More information about the petsc-dev mailing list