<div class="gmail_quote">2011/3/23 Alejandro Marcos Aragón <span dir="ltr">&lt;<a href="mailto:alejandro.aragon@gmail.com">alejandro.aragon@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":1py">My code uses a custom sparse matrix format that uses a hashed container for the entries of the matrix. The interface can then create a matrix in compressed row (or compressed column) storage format. That is, it can give me the three arrays needed to represent the sparse matrix in these formats. I would like to use the PETSc parallel solver, so then I thought that it would be good to try the MatCreateMPIAIJWithSplitArrays function so that I don&#39;t have to copy the values to the PETSc matrix again.<br>
</div></blockquote><div><br></div><div>Have your hashed format generate CSR rows and insert those one row at a time using MatSetValues(). It will be very fast and avoid the copy of using MatCreateMPIAIJWithArrays.</div><div>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div id=":1py">
<br>
Now my question to you is that I really don&#39;t get the point of having a diagonal and off-diagonal blocks of the sparse matrix.</div></blockquote><div><br></div><div>Storing the diagonal and off-diagonal part separately makes MatMult more tolerant to network latency and permits block Jacobi preconditioning without needing to copy out the local blocks.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div id=":1py"> In the compressed row storage format, there is no distinction between these two blocks. Besides, I don&#39;t think there is a clear way to determine which is the boundary between these two blocks. Can someone point me how I should use this function, or if there is a better function that can take the three arrays that I have at this point?<br>

<br>
Also, since the sparse matrix in each process is the result of a finite element assembly routine, some rows are overlapped among the processes (there are several finite element nodes shared among the processes). At this point using the MatSetValues with the ADD_VALUES flag works fine, but I want to make sure that if I use the MatCreateMPIAIJWithSplitArrays (where I need to set the number of local rows) I can still get this behavior. In other words, if I sum the number of local rows in each process, I get a total number of rows that is greater than the number of global rows because of superposition.</div>
</blockquote></div><br><div>Just use MatSetValues(), it will take care of parallel assembly.</div>