<div dir="ltr"><div><br></div><div><div class="gmail_extra"><div class="gmail_quote">On Thu, Jun 8, 2017 at 3:17 PM, Hong <span dir="ltr"><<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Xiangdong:</div><div class="gmail_quote">MatCreateMPIBAIJWithArrays() is obviously buggy, and not been tested.</div><div class="gmail_quote"><br></div><div class="gmail_quote"><span class="gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>1) In the remark of the function MatCreateMPIBAIJWithArrays, it says " bs<span style="white-space:pre-wrap"> </span>- the block size, only a block size of 1 is supported". Why must the block size be 1? Is this a typo? </div><div><br></div><div><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateMPIBAIJWithArrays.html" target="_blank">http://www.mcs.anl.gov/petsc/p<wbr>etsc-current/docs/manualpages/<wbr>Mat/MatCreateMPIBAIJWithArrays<wbr>.html</a></div></div></blockquote><div><br></div></span><div>It seems only bs=1 was implemented. I would not trust it without a test example. </div><span class="gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>2) In the Line 4040 of the implemention of MatCreateMPIBAIJWithArrays, would the matrix type be matmpibaij instead of matmpiSbaij?</div></div></blockquote><div><br></div></span><div>This is an error. It should be matmpibaij.</div><span class="gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><a href="http://www.mcs.anl.gov/petsc/petsc-current/src/mat/impls/baij/mpi/mpibaij.c.html#MatCreateMPIBAIJWithArrays" target="_blank">http://www.mcs.anl.gov/petsc/p<wbr>etsc-current/src/mat/impls/bai<wbr>j/mpi/mpibaij.c.html#MatCreate<wbr>MPIBAIJWithArrays</a><br><div><br></div><div><div>4031: PetscErrorCode  MatCreateMPIBAIJWithArrays(MP<wbr>I_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt i[],const PetscInt j[],const PetscScalar a[],Mat *mat)</div><div>4032: {</div><div><br></div><div>4036:   if (i[0]) SETERRQ(PETSC_COMM_SELF,PETSC_<wbr>ERR_ARG_OUTOFRANGE,"i (row indices) must start with 0");</div><div>4037:   if (m < 0) SETERRQ(PETSC_COMM_SELF,PETSC_<wbr>ERR_ARG_OUTOFRANGE,"local number of rows (m) cannot be PETSC_DECIDE, or negative");</div><div>4038:   MatCreate(comm,mat);</div><div>4039:   MatSetSizes(*mat,m,n,M,N);</div><div>4040:   MatSetType(*mat,MATMPISBAIJ);</div></div></div></blockquote><div> </div></span><div> It should be MATMPIBAIJ.</div><span class="gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>3) I want to create a petsc matrix M equivalent to the sum of two block csr matrix/array (M1csr, M2csr). What is the best way to achieve it? I am thinking of created two petsc baij matrix (M1baij and M2baij) by calling MatCreateMPIBAIJWithAr<wbr>rays twice and then call MATAXPY to get the sum M=M1baij + M2baij. Is there a better way to do it?</div></div></blockquote><div><br></div></span><div>This is an approach. However  MatCreateMPIBAIJWithArrays() needs to be fixed, tested and implemented with requested bs. What bs do you need?</div></div></div></div></blockquote><div><br></div><div>Why does each bs need to be implemented separately? In the mean time, I modifed the implementation of MatCreateMPIBAIJWithArrays() a little bit to create a baij matrix with csr arrays.</div><div><br></div><div><div>MatCreate(comm,mat);</div><div>MatSetSizes(*mat,m,n,M,N);</div><div>MatSetType(*mat,MATMPIBAIJ);</div><div>MatMPIBAIJSetPreallocationCSR(*mat,bs,i,j,a);<br></div><div>MatSetOption(*mat,MAT_ROW_ORIENTED,PETSC_FALSE);</div></div><div>MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY);</div><div>MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY);</div><div><br></div><div>I just set the type to MATMPIBAIJ and delete the line MatSetOption before preallocation (otherwise I get error at runtime complaining using set options before preallocation) and it works fine. The only thing missing is that setting mat_row_oriented to be petsc_false has no effect on the final matrix, which I do not know how to fix.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Why not use MatCreate(), MatSetValuses() (set a block values at time) to create two MPIBAIJ matrices, then call MATAXPY. Since petsc MPIBAIJ matrix has different internal data structure than csr, </div><div>"The i, j, and a arrays ARE copied by MatCreateMPIBAIJWithArrays() into the internal format used by PETSc;", so this approach would give similar performance.</div></div></div></div></blockquote><div><br></div><div>I will try this option as well. Thanks for your suggestions.</div><div><br></div><div>Xiangdong </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-HOEnZb"><font color="#888888"><div><br></div><div>Hong</div></font></span></div><br></div></div>
</blockquote></div><br></div></div></div>