[petsc-dev] MATOP_MAT_MULT

Jose E. Roman jroman at dsic.upv.es
Sat May 9 13:28:19 CDT 2020



> El 9 may 2020, a las 20:00, Stefano Zampini <stefano.zampini at gmail.com> escribió:
> 
> 
> 
> Il giorno sab 9 mag 2020 alle ore 19:43 Jose E. Roman <jroman at dsic.upv.es> ha scritto:
> 
> 
> > El 9 may 2020, a las 12:45, Stefano Zampini <stefano.zampini at gmail.com> escribió:
> > 
> > Jose
> > 
> > I have just pushed a test https://gitlab.com/petsc/petsc/-/blob/d64c2bc63c8d5d1a8c689f1abc762ae2722bba26/src/mat/tests/ex69.c
> > See if it fits your framework, and feel free to modify the test to add more checks
> 
> Almost good. The following modification of the example fails with -test 1:
> 
> 
> diff --git a/src/mat/tests/ex69.c b/src/mat/tests/ex69.c
> index e562f1e2e3..2df2c89be1 100644
> --- a/src/mat/tests/ex69.c
> +++ b/src/mat/tests/ex69.c
> @@ -84,6 +84,10 @@ int main(int argc,char **argv)
>    }
>    ierr = VecCUDARestoreArray(v,&vv);CHKERRQ(ierr);
> 
> +  if (test==1) {
> +    ierr = MatDenseCUDAGetArray(B,&aa);CHKERRQ(ierr);
> +    if (aa) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_USER,"Expected a null pointer");
> +  }
> 
>    /* free work space */
>    ierr = MatDestroy(&B);CHKERRQ(ierr);
> 
> 
> 
> I would expect that after MatDenseCUDAResetArray() the pointer is NULL because it was set so in line 60. In the CPU counterpart it works as expected.
> 
> Pushed a fix for this, thanks.
>  
> Another comment is: in line 60 you have changed MatDenseCUDAPlaceArray() to MatDenseCUDAReplaceArray(). This is ok, but it is strange because MatDenseReplaceArray() does not exist. So the interface is different in GPU vs CPU, but I guess it is necessary here.
> 
> I think we do not support calling PlaceArray twice anywhere PETSc. This is why I have added MatDenseCUDAReplaceArray(). If you need support for the CPU case too, I can add it.

Yes, please. It is better to have the same thing in both cases.

I am attaching the modified example, now performs a mat-mat product. If I do A*B it works well, but if I replace A with a shell matrix I get a memory leak.

[ 0]32 bytes VecCUDAAllocateCheck() line 34 in /home/users/proy/copa/jroman/soft/petsc/src/vec/vec/impls/seq/seqcuda/veccuda2.cu
[ 0]32 bytes VecCUDAAllocateCheck() line 34 in /home/users/proy/copa/jroman/soft/petsc/src/vec/vec/impls/seq/seqcuda/veccuda2.cu



>  
> Thanks.
> Jose
> 
> 
> > 
> > 
> > Il giorno ven 8 mag 2020 alle ore 18:48 Jose E. Roman <jroman at dsic.upv.es> ha scritto:
> > Attached. Run with -test 1 or -test 2
> > 
> > > El 8 may 2020, a las 17:14, Stefano Zampini <stefano.zampini at gmail.com> escribió:
> > > 
> > > Jose
> > > 
> > > Just send me a MWE and I’ll fix the case for you
> > > 
> > > Thanks
> > > Stefano
> > 
> > 
> > -- 
> > Stefano
> 
> 
> 
> -- 
> Stefano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex69.c
Type: application/octet-stream
Size: 5094 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20200509/2c2f60b6/attachment.obj>


More information about the petsc-dev mailing list