<div><br></div><div><br><div class="gmail_quote"><div dir="ltr">On Thu 21. May 2020 at 10:49, Yang Bo (Asst Prof) <<a href="mailto:yang.bo@ntu.edu.sg">yang.bo@ntu.edu.sg</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div style="word-wrap:break-word;line-break:after-white-space">
Hi Dave,
<div><br>
</div>
<div>Thank you very much for your reply. That is indeed the problem. I have been working with matrices in Slepc but I don’t really understand it. I tried to preallocate but it still does not work. </div></div></blockquote><div dir="auto"><br></div><div dir="auto">Meaning the number of reported mallocs is still non-zero?</div><div dir="auto">Is the number reported with you preallocation calls lower than what you originally saw?</div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div>If you look at my code below:</div>
<div><br>
</div>
<div>
<div>ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr);</div>
<div>ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,h_dim,h_dim);<span style="white-space:pre-wrap">
</span>                     // h_dim is the dimension of the square matrix A</div>
<div>ierr = MatSetFromOptions(A);CHKERRQ(ierr);</div>
<div>ierr = MatSetUp(A);CHKERRQ(ierr);</div>
<div>ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr);</div>
<div><br>
</div>
<div>MatSeqAIJSetPreallocation(A,0,nnz);                                      
<span style="white-space:pre-wrap"></span>// I try to preallocate here, where nnz is the array containing the number of non-zero entries each row</div>
<div><br>
</div>
<div>for (int i=0;i<row.size();i++) {</div>
<div><span style="white-space:pre-wrap"></span>MatSetValue(A,row[i],column[i],h[i],INSERT_VALUES);</div>
<div>}</div>
</div>
<div><br>
</div>
<div>I am not sure what other information I need to give for the pre-allocation…</div>
<div></div></div></blockquote><div dir="auto"><br></div><div dir="auto">This looks fine. However MatSeqAIJSetPreallocation() has no effect if the Mat type is not SEQAIJ.</div><div dir="auto"><br></div><div dir="auto">Are you running in parallel? If yes then the Mat type will be MATMPIAIJ and you either have to call the MPI specific preallocator or use the generic one I pointed you too.</div><div dir="auto"><br></div><div dir="auto">Thanks</div><div dir="auto">Dave</div><div dir="auto"><br></div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><br>
</div>
<div>Cheers,</div>
<div><br>
</div>
<div>Yang Bo</div>
<div><br>
</div>
<div><br>
<div><br>
<blockquote type="cite">
<div>On 21 May 2020, at 4:08 PM, Dave May <<a href="mailto:dave.mayhem23@gmail.com" target="_blank">dave.mayhem23@gmail.com</a>> wrote:</div>
<br>
<div><b style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">-info
 | grep malloc</b></div>
</blockquote>
</div>
<br>
</div></div><div style="word-wrap:break-word;line-break:after-white-space">
<hr>
<p style="font-size:10pt;color:#808080;font-family:'Arial'">CONFIDENTIALITY: This email is intended solely for the person(s) named and may be confidential and/or privileged. If you are not the intended recipient, please delete it, notify us and do not copy,
 use, or disclose its contents. <br>
Towards a sustainable earth: Print only when necessary. Thank you. </p>
</div>

</blockquote></div></div>