[petsc-dev] error on preallocation business

Barry Smith bsmith at mcs.anl.gov
Sat Jan 21 14:46:42 CST 2012


   Jed,

    That patch is hideous, introduced more complexity. 

    Why not  in MatSetUpPreallocation() add the one line

  if (!B->preallocated && B->ops->setuppreallocation) {
    ierr = PetscInfo(B,"Warning not preallocating matrix storage\n");CHKERRQ(ierr);
    ierr = (*B->ops->setuppreallocation)(B);CHKERRQ(ierr);
    ierr = MatSetOption(B,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE);CHKERRQ(ierr);

that turns of the alloc error, note this only happens if the user did not preallocate. 

   What do you say? Revert  that ugly code and add only one line of code?

   Barry

Note that it makes no sense for the user to not preallocate but then to set the error on alloc flag.


On Jan 21, 2012, at 2:32 PM, Jed Brown wrote:

> On Sat, Jan 21, 2012 at 11:50, Barry Smith <bsmith at mcs.anl.gov> wrote:
> 
>  Jed,
> 
>     It appears you changed all the MatXXXSetPreallocation() routines to set call  ierr = MatSetOption(B,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_TRUE);CHKERRQ(ierr); thus generating an error if preallocation is wrong.
> 
>     The problem is that MatXXXSetPreallocation() is ALWAYS called (with default values if the user did not call it explicitly) by MatPreallocated() which calls MatPreallocationSetUp(). Hence you are ALWAYS setting error on new allocation.
> 
>     My intention was that an error would only be generated if the user explicitly called MatXXXSetPreallocation() so
> 
>   1) Was my intention wrong and should we always default to erroring on wrong preallocation even if the user did not preallocate or   (if so we need lots of fixes because much code is broken in nightly tests)
> 
> No, I think your idea was correct.
>  
> 
>   2) is there anyway to change it so it only errors out when the user did explicitly preallocate?
> 
> This patch is not pretty, but it seems to do the job.
> 
> http://petsc.cs.iit.edu/petsc/petsc-dev/rev/e675ef955f92




More information about the petsc-dev mailing list