<div class="gmail_quote">On Tue, Sep 27, 2011 at 21:44, Shiyuan <span dir="ltr"><<a href="mailto:gshy2014@gmail.com">gshy2014@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":2xi">1. <br> I want to allow setting the MatType by option -mat_type. It seems that I can rewrite <br> ierr=MatCreateSeqAIJ(comm,m,n,nz,nnz,A); CHKERRQ(ierr);<br> to <br> ierr=MatCreate(comm,A);CHKERRQ(ierr);<br>
ierr=MatSetSizes(*A,PETSC_DECIDE,PETSC_DECIDE,m,n);CHKERRQ(ierr);<br>
ierr=MatSetFromOptions(*A);CHKERRQ(ierr);<br> So that the MatType can be set using -mat_type options.<br> But then how can the nz or nnz be specified? <br></div></blockquote><div><br></div><div>MatSeqAIJSetPreallocation() and others (you can call all of them).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div id=":2xi"><br>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? </div>
</blockquote></div><br><div>It's updated when needed and a flag is held for which copies are current so there are no unnecessary copies.</div>