<div dir="ltr">Thanks for your explanation. <div><div><br></div><div>It seems that it is due to my calling of MatDiagonalSet() before MatAssemblyBegin(). My problem is resolved by putting MatDiagonalSet() after MatAssemblyBegin().</div><div><br></div><div>Much thanks for your help.</div><div><span style="color:rgb(32,33,36);font-family:arial,sans-serif;font-size:14px">Xi YUAN, PhD Solid Mechanics</span></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">2024年1月18日(木) 22:20 Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com">junchao.zhang@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 18, 2024 at 1:47 AM 袁煕 <<a href="mailto:yuanxi@advancesoft.jp" target="_blank">yuanxi@advancesoft.jp</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear PETSc Experts,<br><div><br></div><div>My FEM program works well generally, but in some specific cases with multiple CPUs are used, it freezes when calling MatAssemblyBegin where PMPI_Allreduce is called (see attached file).</div><div><br></div><div>After some investigation, I found that it is most probably due to</div><div><br></div><div>・ MatSetValue is not called from all CPUs before MatAssemblyBegin </div><div><br></div><div>For example, when 4 CPUs are used, if there are elements in CPU 0,1,2 but no elements in CPU 3, then all CPUs other than CPU 3 would call MatSetValue function. I want to know</div><div><br></div><div>1. If my <span style="color:rgb(32,33,36);font-family:arial,sans-serif;font-size:14px">conjecture could be right? And If so</span></div></div></blockquote><div>No. All processes do MPI_Allreduce to know if there are incoming values set by others. To know why hanging, you can attach gdb to all MPI processes to see where they are.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div> </div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><span style="color:rgb(32,33,36);font-family:arial,sans-serif;font-size:14px">2. Are there any convenient means to avoid this problem?</span></div><div><span style="color:rgb(32,33,36);font-family:arial,sans-serif;font-size:14px"><br></span></div><div><span style="color:rgb(32,33,36);font-family:arial,sans-serif;font-size:14px">Thanks,</span></div><div><span style="color:rgb(32,33,36);font-family:arial,sans-serif;font-size:14px">Xi YUAN, PhD Solid Mechanics</span></div></div>
</blockquote></div></div>
</blockquote></div>