[petsc-users] Set nnz for Mat & MatSetValues

Jed Brown jedbrown at mcs.anl.gov
Tue Sep 27 21:48:46 CDT 2011


On Tue, Sep 27, 2011 at 21:44, Shiyuan <gshy2014 at gmail.com> wrote:

> 1.
>  I want to allow setting the MatType by option -mat_type. It seems that I
> can rewrite
>   ierr=MatCreateSeqAIJ(comm,m,n,nz,nnz,A); CHKERRQ(ierr);
>   to
>   ierr=MatCreate(comm,A);CHKERRQ(ierr);
>   ierr=MatSetSizes(*A,PETSC_DECIDE,PETSC_DECIDE,m,n);CHKERRQ(ierr);
>   ierr=MatSetFromOptions(*A);CHKERRQ(ierr);
>   So that the MatType can be set using -mat_type options.
>   But then how can the nz or nnz be specified?
>

MatSeqAIJSetPreallocation() and others (you can call all of them).


>
> 2. If we set mat_type to cusp and use MatSetValues, when do the values goto
> device memory? Is it assembly first on host memory and then copy it once to
> device memory together after MatAssemblyEnd() or is it done in a different
> way? Does it also contain a flag to indicate whether the data value is
> current?
>

It's updated when needed and a flag is held for which copies are current so
there are no unnecessary copies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110927/6898c773/attachment.htm>


More information about the petsc-users mailing list