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

> On Sat, Jan 21, 2012 at 14:46, Barry Smith <bsmith at mcs.anl.gov> wrote:
>    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);
> 
> This was my first inclination, but
> 
> 
> 1. DisAssemble_*() functions call preallocation routines again, but the 
> values they use still aren't correct, so we have to avoid setting the options.

    The disassemble routines (in fact any PETSc library routines that call the 
preallocation routines) should ONLY call them if they are using correct values 
of preallocation otherwise they should not call them. So we should fix or 
remove all those bad uses of preallocation (preferably fix).  If you have the 
list of the ones that call with incorrect preallocation let us know.

> 
> 2. Users call preallocation directly (often through MatCreateMPIAIJ(), etc) 
> with PETSC_DECIDE. In my opinion, they should see an error for not 
> preallocating correctly. (But if you think they should have to say twice that 
> they aren't preallocating correctly---by calling MatSetOption(), I can remove 
> that uglyness.)

   I don't understand. With my model if they call MatCreateMPIAIJ() or 
MatMPIAIJSetPreallocation() it WILL set that flag and hence WILL bitch if they 
have used wrong values (even if they use PETSC_DECIDE. So it will do the right 
thing with my little fix; tell me why it won't.  Note if any of the 
preallocation routines are called it will not reset the flag in 
MatSetUpPreallocation().

> 
> 3. I didn't want to overwrite a user setting the option manually (perhaps 
> with intent to preallocate).

        I already acknowledged this in my previous email. To me the tradeoff is 
monsterous code that Matt would hate vs this 

    In conclusion I think only 3 has any validity and that not enough for 
butt-ugly code.

    Barry

> 
> 
> 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.
> 


Reply via email to