On 6/7/06, <b class="gmail_sendername">Evrim Dizemen</b> <<a href="mailto:gudik@ae.metu.edu.tr">gudik@ae.metu.edu.tr</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all,<br><br>First thanks for your comments. I still have the same problem but i<br>agree with you all that reading a matrix from a file is not parallel<br>programming. So i wonder if you can recommend an efficient and faster
<br>way to read a 30000x30000 sparse matrix where i got those values from my<br>fortran code on aeroacoustics similation. I tried calling MatSetValues<br>as i attached below. I found that way from the ex11f.F in the matrix
<br>examples and not sure if it is appropriate for my situation.<br><br>! do, i=1,n<br>! do, j=1,n<br>! value=Aval(i,j)<br>! if(value .ne. 0)then<br>! l=i-1<br>! m=j-1<br>! call MatSetValues(A,1,l,1,m,value,INSERT_VALUES,ierr)
<br>! endif<br>! enddo<br>! enddo<br><br>Thanks soooooo much</blockquote><div><br>
1) You should set an entire row at a time at least, not a single value<br>
<br>
2) You need to preallocate the matrix for good performance:<br>
<br>
<a href="http://www-unix.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatMPIAIJSetPreallocation.html">http://www-unix.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatMPIAIJSetPreallocation.html
</a><br>
<br>
3) You are here setting all values from one process. You should do as Randy suggests and set only the values<br>
which are owned by each process.<br>
<br>
4) I would consult an example, such as:<br>
<br>
<a href="http://www-unix.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/src/ksp/ksp/examples/tutorials/ex2.c.html">http://www-unix.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/src/ksp/ksp/examples/tutorials/ex2.c.html
</a><br>
<br>
Matt<br>
</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">EVRIM<br>
</blockquote></div>-- <br>"Failure has a thousand explanations. Success doesn't need one" -- Sir Alec Guiness