[petsc-users] Add a matrix to MatNest twice

Barry Smith bsmith at mcs.anl.gov
Tue Feb 21 15:37:57 CST 2012


  Jed,

   Why not just have MatAssemblyBegin_Nest() call the inner MatAssemblyBegin/End() together and stop the charade that there is any overlap of communication and computations etc anyway? 

    Barry

On Feb 21, 2012, at 8:09 AM, Jed Brown wrote:

> On Tue, Feb 21, 2012 at 07:43, Thomas Witkowski <thomas.witkowski at tu-dresden.de> wrote:
> Seems not to work correctly. I made some small changes in src/ksp/ksp/examples/tests/ex22.c:
> 
> 21c21
> <   np = 2;
> ---
> >   np = 3;
> 62c62
> <   tmp[0][0] = A11;
> ---
> >   tmp[0][0] = A12;
> 
> When running with 2 threads, it ends with a segmentation violation. The stack is as follows:
> 
> [0]PETSC ERROR: [0] MatStashScatterEnd_Private line 109 src/mat/utils/matstash.c
> [0]PETSC ERROR: [0] MatAssemblyEnd_MPIAIJ line 641 src/mat/impls/aij/mpi/mpiaij.c
> [0]PETSC ERROR: [0] MatAssemblyEnd line 4934 src/mat/interface/matrix.c
> [0]PETSC ERROR: [0] MatAssemblyEnd_Nest line 228 src/mat/impls/nest/matnest.c
> [0]PETSC ERROR: [0] MatAssemblyEnd line 4934 src/mat/interface/matrix.c
> [0]PETSC ERROR: [0] test_solve line 17 src/ksp/ksp/examples/tests/ex22.c
> 
> Okay, the problem is that MatAssemblyBegin and MatAssemblyEnd are called twice on the same matrix. There are two ways to fix this:
> 
> 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().
> 
> 2. Uniquify a list of non-empty mats so we only call it once. This doesn't work because you could have nested MatNests:
> 
> [[A 0;0 B] 0; 0 A]
> 
> 
> I'm in the midst of something right now, but I'll get back to this if nobody beats me to it.



More information about the petsc-users mailing list