<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div dir="ltr">
<div>Try this to see if it helps:</div>
<div><br>
</div>
diff --git a/src/sys/utils/sorti.c b/src/sys/utils/sorti.c<br>
index 1b07205a..90779891 100644<br>
--- a/src/sys/utils/sorti.c<br>
+++ b/src/sys/utils/sorti.c<br>
@@ -294,7 +294,8 @@ static PetscErrorCode PetscSortIntWithArrayPair_Private(PetscInt *L,PetscInt *J,<br>
}<br>
PetscFunctionReturn(0);<br>
}<br>
- SWAP3(L[0],L[right/2],J[0],J[right/2],K[0],K[right/2],tmp);<br>
+ i = MEDIAN(L,right);<br>
+ SWAP3(L[0],L[i],J[0],J[i],K[0],K[i],tmp);<br>
vl = L[0];<br>
last = 0;<br>
for (i=1; i<=right; i++) {<br>
<br>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, Jul 2, 2019 at 12:14 PM Fande Kong via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov">petsc-dev@mcs.anl.gov</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">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">BTW,
<div><br>
</div>
<div>PetscSortIntWithArrayPair is used in MatStashSortCompress_Private.<br>
</div>
<div><br>
</div>
<div>Any way to avoid to use PetscSortIntWithArrayPair in MatStashSortCompress_Private? </div>
<div><br>
</div>
<div>Fande,</div>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, Jul 2, 2019 at 11:09 AM Fande Kong <<a href="mailto:fdkong.jd@gmail.com" target="_blank">fdkong.jd@gmail.com</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">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">Hi Developers,<br>
<div><br>
</div>
<div>John just noticed that the matrix assembly was slow when having sufficient amount of off-diagonal entries. It was not a MPI issue since I was able to reproduce the issue using two cores on my desktop, that is, "mpirun -n 2".</div>
<div><br>
</div>
<div>I turned on a profiling, and 99.99% of the time was spent on PetscSortIntWithArrayPair (recursively calling). It took THREE MINUTES to get the assembly done. And then changed to use the option "-matstash_legacy" to restore </div>
<div>the code to the old assembly routine, and the same code took ONE SECOND to get the matrix assembly done. </div>
<div><br>
</div>
<div>Should write any better sorting algorithms?</div>
<div><br>
</div>
<div><br>
</div>
<div>Fande,</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
</body>
</html>