<div class="gmail_quote">On Tue, Feb 21, 2012 at 07:43, Thomas Witkowski <span dir="ltr"><<a href="mailto:thomas.witkowski@tu-dresden.de">thomas.witkowski@tu-dresden.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">Seems not to work correctly. I made some small changes in
src/ksp/ksp/examples/tests/ex22.c:<br>
<br>
21c21<br>
< np = 2;<br>
---<br>
> np = 3;<br>
62c62<br>
< tmp[0][0] = A11;<br>
---<br>
> tmp[0][0] = A12;<br>
<br>
When running with 2 threads, it ends with a segmentation violation.
The stack is as follows:<br>
<br>
[0]PETSC ERROR: [0] MatStashScatterEnd_Private line 109
src/mat/utils/matstash.c<br>
[0]PETSC ERROR: [0] MatAssemblyEnd_MPIAIJ line 641
src/mat/impls/aij/mpi/mpiaij.c<br>
[0]PETSC ERROR: [0] MatAssemblyEnd line 4934
src/mat/interface/matrix.c<br>
[0]PETSC ERROR: [0] MatAssemblyEnd_Nest line 228
src/mat/impls/nest/matnest.c<br>
[0]PETSC ERROR: [0] MatAssemblyEnd line 4934
src/mat/interface/matrix.c<br>
[0]PETSC ERROR: [0] test_solve line 17
src/ksp/ksp/examples/tests/ex22.c<br></div></blockquote></div><br><div>Okay, the problem is that MatAssemblyBegin and MatAssemblyEnd are called twice on the same matrix. There are two ways to fix this:</div><div><br>
</div><div>1. Add a flag to Mat so we can tell when a matrix is being assembled. This makes it so we can't error if an external user leaves a MatAssemblyBegin() open with no closing MatAssemblyEnd().</div><div><br></div>
<div>2. Uniquify a list of non-empty mats so we only call it once. This doesn't work because you could have nested MatNests:</div><div><br></div><div>[[A 0;0 B] 0; 0 A]</div><div><br></div><div><br></div><div>I'm in the midst of something right now, but I'll get back to this if nobody beats me to it.</div>