On Fri, Jun 15, 2012 at 11:18 AM, w_ang_temp <span dir="ltr"><<a href="mailto:w_ang_temp@163.com" target="_blank">w_ang_temp@163.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="line-height:1.7;font-size:14px;font-family:arial"><div>Hello, Matt<br> <br> After my careful testing, I get some findings.</div>
<div> </div>
<div> Firstly, considering the approach of setting one row at a time. I change my codes<br>from setting one data per time to one row per time (codes attached). I find that both<br>of the times are almost equal and cannot be ignored . In my opinion, the latter should<br>
take less time than the former. the codes have been proved to have the right results<br>and I think my testing datas are enough to show that they almost have the same time<br>for setting the matrix.</div></div></blockquote>
<div><br></div><div>I do not believe you analysis. Send the output of -log_summary -info to <a href="mailto:petsc-maint@mcs.anl.gov">petsc-maint@mcs.anl.gov</a></div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="line-height:1.7;font-size:14px;font-family:arial"><div><span style="line-height:1.7"> </span></div>
<div> Secondly, as you said in a previous post('CSR Sparse Matrix Query', 2007), there<br>is no Fortran interface for the function 'MatCreateMPIAIJWithArrays'. I am not sure<br>if it is true now because the docs do not specify this and I connot compile with<br>
it atfer a simple test. In my opinion, you prefer to do the thing of setting values from<br>CSR format using the way of setting values with MatSetValus for each row rather than<br>using MatCreateMPIAIJWithArrays. am I right?</div>
<div> </div>
<div> Thanks again.</div>
<div> Jim</div>
<div>-----coding:per row(you can compare it with the first page int this post of one data per time )-----<br> <br> !NROWIN,NNZIJ,values:the CSR variables of the main function<br> !NROWIN,NNZIJ:one-based,so get zero-based variables rowIndex,columns</div>
<div> do 10,II=Istart+1,Iend<br> !no-zero numbers of this row<br> rowNum=NROWIN(II+1)-NROWIN(II)<br> <br> allocate(nColPerRow(rowNum))<br> allocate(valuePerRow(rowNum))<br> <br>
kValStart=NROWIN(II)+1-1<br> kValEnd=NROWIN(II)+rowNum-1<br> <br> !column index<br> nColPerRow=NNZIJ(kValStart:kValEnd)-1<br> valuePerRow=values(kValStart:kValEnd)<br> nRow=II-1<br>
call MatSetValues(A,ione,nRow,rowNum,nColPerRow,valuePerRow,<br> & INSERT_VALUES,ierr)<br> deallocate(nColPerRow)<br> deallocate(valuePerRow) <br> 10 continue<br>---------------------coding-----------------------------<br>
<br></div>
<div></div>
<div></div>
<div><br></div>>在 2012-06-10 20:49:13,"Matthew Knepley" <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> 写道:<br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex">>On Sun, Jun 10, 2012 at 4:48 PM, w_ang_temp <span dir="ltr"><<a href="mailto:w_ang_temp@163.com" target="_blank">w_ang_temp@163.com</a>></span> wrote:<br>
<div class="gmail_quote">
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
<div style="LINE-HEIGHT:1.7;FONT-FAMILY:arial;FONT-SIZE:14px">
<div>>Hello, Barry<br> <br>> I try to use MatCreateSeqAIJWithArrays to deal with my problem. Since <br>>there is no example in the doc, I find some examples in the web and use it.<br>>And I get some errors.</div>
<div> </div>
<div>> When the processor is 1(mpiexec -n 1 ./ex4f), the results are ok. While<br>>it is more than one, I get the errors. So I think I miss some piece of<br>>information about MatCreateSeqAIJWithArrays.</div>
</div></blockquote>
<div><br></div>
<div>>1) Check the error codes. Always!</div>
<div> </div>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
<div style="LINE-HEIGHT:1.7;FONT-FAMILY:arial;FONT-SIZE:14px">
<div>> Thanks. <br>> Jim</div>
<div> </div>
<div>>----------------------------code-------------------------------------------<br>> call MatCreate(PETSC_COMM_WORLD,A,ierr)<br>> call MatSetType(A,MATAIJ,ierr)<br>> call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,m,n,ierr)<br>
> call MatSetFromOptions(A,ierr)<br>> call MatGetOwnershipRange(A,Istart,Iend,ierr)</div></div></blockquote>
<div> </div>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
<div style="LINE-HEIGHT:1.7;FONT-FAMILY:arial;FONT-SIZE:14px">
<div>> !NROWIN,NNZIJ,values:the CSR variables of the main function<br>> !NROWIN,NNZIJ:one-based,so get zero-based variables rowIndex,columns<br>> allocate(rowIndex(JFLNG+1))<br>> allocate(columns(MAXNNZ))<br>
> rowIndex=NROWIN-1<br>> columns=NNZIJ-1<br> <br>> call MatCreateSeqAIJWithArrays(MPI_COMM_WORLD,m,n,rowIndex,columns,<br>> & values,A, ierr)</div></div></blockquote>
<div><br></div>
<div>>2) This can only be called in serial. In parallel, you need MatCreateMPIAIJWithArrays()</div>
<div><br></div>
<div>>3) I still believe you are really doing the wrong thing. The right solution is to set one row at</div>
<div>> a time. I will bet dollars to doughnuts that the assembly time is not noticeable in your program.</div>
<div><br></div>
<div>> Matt</div>
<div> </div>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
<div style="LINE-HEIGHT:1.7;FONT-FAMILY:arial;FONT-SIZE:14px">
<div><br>> call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)<br>> call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr)<br>>----------------------------code-------------------------------------------</div>
<div> </div>
<div>>----------------------------Error Message----------------------------------</div>
<div>>.........<br></div></div></blockquote></div></blockquote></div><br><br><span title="neteasefooter"><span></span></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>