MatMult_Scatter woes

Jed Brown jed at 59A2.org
Wed Apr 8 15:13:02 CDT 2009


On Wed 2009-04-08 14:23, Barry Smith wrote:
>
>    Perhaps the name MatScatter should then be changed to MatScatterAdd to 
> clarify the meaning?

I'm not sure it's clearer, but the semantics should be explained in the
man pages.

>    Here is my issue (which is only indirectly related to this whole  
> discussion). I an ideal PETSc, I think that if one creates
> a VecScatter where two different locations are mapped to the same output 
> location and then uses it with INSERT_VALUES
> I think that should generate an error. To implement this we could have  
> the scatter create detect this case and set a flag in the scatter,
> then if the scatter is used with insert and the flag is set generate an 
> error. The checking could be wrapped in an #if  
> defined(PETSC_USE_DEBUGGING).

Yes, similarly to ISSetPermutation.  An easy way to test is

  ierr = VecSet(x,1);CHKERRQ(ierr);
  ierr = VecZeroEntries(y);CHKERRQ(ierr);
  ierr = VecScatterBegin(scatter,x,y,ADD_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
  ierr = VecScatterEnd(scatter,x,y,ADD_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
  ierr = VecMax(y,PETSC_NULL,&max);CHKERRQ(ierr);
  if (max > 1.0) SETERRQ(PETSC_ERR_ARG_WRONG,"Scatter destination is not injective, cannot use INSERT_VALUES");

and similarly for the transpose.  For the scatter to behave like a
matrix under INSERT_VALUES (without zeroing y first), we also need the
following, but it cannot be enforced for general scatters.

  ierr = VecMin(y,PETSC_NULL,&min);CHKERRQ(ierr);
  if (min < 1.0) SETERRQ(PETSC_ERR_ARG_WRONG,"Scatter destination is not surjective");


I think adding the check to VecScatterBegin would be easy, but to
optimize MatMult_Scatter based on these properties, we would need to
expose them in the public API.  In this case we also need setters (so
that the check can be avoided in optimized mode) which changes the API.
I don't know if there are other uses of VecScatter for which knowledge
of these properties would be useful.

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


More information about the petsc-dev mailing list