On 6/7/06, <b class="gmail_sendername">Evrim Dizemen</b> &lt;<a href="mailto:gudik@ae.metu.edu.tr">gudik@ae.metu.edu.tr</a>&gt; 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>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do, i=1,n<br>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do, j=1,n<br>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value=Aval(i,j)<br>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(value .ne. 0)then<br>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; l=i-1<br>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m=j-1<br>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;call MatSetValues(A,1,l,1,m,value,INSERT_VALUES,ierr)
<br>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endif<br>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enddo<br>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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>
&nbsp; <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>
&nbsp;&nbsp;&nbsp;&nbsp; which are owned by each process.<br>
<br>
4) I would consult an example, such as:<br>
<br>
&nbsp; <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>
&nbsp;<br>
&nbsp;&nbsp;&nbsp; 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>&quot;Failure has a thousand explanations. Success doesn't need one&quot; -- Sir Alec Guiness