[petsc-dev] MatAXPY does not increase state

Jed Brown jed at jedbrown.org
Tue May 6 19:34:56 CDT 2014


"Jose E. Roman" <jroman at dsic.upv.es> writes:
> I have created a pull request with the change in MatHeaderReplace,
> with state+1.  Regarding the other changes in MatAXPY, I don't know
> where they should go, so I left it unchanged. Hence, the problem still
> exists in the case of same and subset nonzero pattern.

Sorry about dropping this.  The place where memory is modified should
have the update.  Like I would write this for AIJ (if not using an
access interface to manage state).

diff --git i/src/mat/impls/aij/seq/aij.c w/src/mat/impls/aij/seq/aij.c
index 3c8fe3a..dbb12e6 100644
--- i/src/mat/impls/aij/seq/aij.c
+++ w/src/mat/impls/aij/seq/aij.c
@@ -2826,6 +2826,7 @@ PetscErrorCode MatAXPY_SeqAIJ(Mat Y,PetscScalar a,Mat X,MatStructure str)
     PetscScalar alpha = a;
     PetscStackCallBLAS("BLASaxpy",BLASaxpy_(&bnz,&alpha,x->a,&one,y->a,&one));
     ierr = MatSeqAIJInvalidateDiagonal(Y);CHKERRQ(ierr);
+    ierr = PetscObjectStateIncrease((PetscObject)Y);CHKERRQ(ierr);
   } else if (str == SUBSET_NONZERO_PATTERN) { /* nonzeros of X is a subset of Y's */
     if (y->xtoy && y->XtoY != X) {
       ierr = PetscFree(y->xtoy);CHKERRQ(ierr);
@@ -2837,6 +2838,7 @@ PetscErrorCode MatAXPY_SeqAIJ(Mat Y,PetscScalar a,Mat X,MatStructure str)
       ierr    = PetscObjectReference((PetscObject)X);CHKERRQ(ierr);
     }
     for (i=0; i<x->nz; i++) y->a[y->xtoy[i]] += a*(x->a[i]);
+    ierr = PetscObjectStateIncrease((PetscObject)Y);CHKERRQ(ierr);
     ierr = PetscInfo3(Y,"ratio of nnz(X)/nnz(Y): %D/%D = %g\n",x->nz,y->nz,(double)((PetscReal)(x->nz)/(y->nz+1)));CHKERRQ(ierr);
   } else {
     Mat      B;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20140506/ec2f3be8/attachment.sig>


More information about the petsc-dev mailing list