<div class="gmail_quote">On Thu, Nov 24, 2011 at 07:14, Dominik Szczerba <span dir="ltr"><<a href="mailto:dominik@itis.ethz.ch">dominik@itis.ethz.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":2a6">In any case, I use KSPSetOperators(ksp, A, A, SAME_NONZERO_PATTERN).<br>
<br>
1) If I provide only approximation for number of zeros per row (d_nz<br>
and o_nz) and I overshoot - will the extra memory still be there or is<br>
automatically freed?<br></div></blockquote><div><br></div><div>It will still be there, but the data structure is compacted so that the "holes" are all at the very end of the arrays, so it does not influence performance at all. Reallocating and copying would cause much higher peak memory usage, so it's usually not desirable.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div id=":2a6">
<br>
2) Do I need to MatMPIAIJSetPreallocation() after MatZeroEntries(A)?<br></div></blockquote><div><br></div><div>No</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":2a6">
MatZeroEntries man page says:<br>
<br>
If the matrix was not preallocated then a default, likely poor<br>
preallocation will be set in the matrix, so this should be called<br>
after the preallocation phase.<br>
<br>
A was preallocated during creation, but unless I call<br>
MatMPIAIJSetPreallocation after MatZeroEntries, I get a lot of unneded<br>
mallocs.</div></blockquote></div><div><br></div><div>That should not happen. Perhaps the type was not set in your original preallocation, but this function does not change allocation.</div><div><br></div><div><div>PetscErrorCode MatZeroEntries_SeqAIJ(Mat A)</div>
<div>{</div><div> Mat_SeqAIJ *a = (Mat_SeqAIJ*)A->data; </div><div> PetscErrorCode ierr;</div><div><br></div><div> PetscFunctionBegin; </div><div> ierr = PetscMemzero(a->a,(a->i[A->rmap->n])*sizeof(PetscScalar));CHKERRQ(ierr);</div>
<div> a->idiagvalid = PETSC_FALSE;</div><div> a->ibdiagvalid = PETSC_FALSE;</div><div> PetscFunctionReturn(0);</div><div>}</div></div><div><br></div>