<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 28 Apr 2020, at 10:30, Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" class="">pierre.jolivet@enseeiht.fr</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 14 Apr 2020, at 2:36 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<div dir="ltr" class="">On Tue, Apr 14, 2020 at 6:36 AM Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" class="">pierre.jolivet@enseeiht.fr</a>> wrote:<br class="">
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
Hello,<br class="">
I’d like to call DMPlexInterpolate after DMPlexDistribute and not the other way around for performance reasons (please stop me here if this is equivalent).<br class="">
When there is no overlap in DMPlexDistribute, it goes through fine.<br class="">
If there is overlap, I run into an error.<br class="">
Is this the expected behavior?</blockquote>
</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Sorry for taking so long to get back at this.</div>
<div class="">I thought I got everything setup, but when looking at the performance, I’m quite surprised.</div>
<div class="">I rewound and looked at src/dm/impls/plex/tutorials/ex2.c by just adding the DMPlexDistribute step. I guess this is equivalent to your steps #1 and #2.</div>
<div class="">
<div class="">diff --git a/src/dm/impls/plex/tutorials/ex2.c b/src/dm/impls/plex/tutorials/ex2.c</div>
<div class="">index a069d922b2..5e5c4fb584 100644</div>
<div class="">--- a/src/dm/impls/plex/tutorials/ex2.c</div>
<div class="">+++ b/src/dm/impls/plex/tutorials/ex2.c</div>
<div class="">@@ -65,2 +65,5 @@ static PetscErrorCode CreateMesh(MPI_Comm comm, AppCtx *user, DM *dm)</div>
<div class="">     ierr = DMPlexCreateFromFile(comm, user->filename, user->interpolate, dm);CHKERRQ(ierr);</div>
<div class="">+    DM dmParallel;</div>
<div class="">+    ierr = DMPlexDistribute(*dm, 0, NULL, &dmParallel);CHKERRQ(ierr);</div>
<div class="">+    ierr = DMDestroy(&dmParallel);CHKERRQ(ierr);</div>
<div class="">   }</div>
<div class=""><br class="">
</div>
<div class="">With a cube of 741000 nodes 4574068 elements.</div>
<div class="">$ cat untitled.geo && ~/gmsh-4.5.4-Linux64/bin/gmsh untitled.geo -bin -3</div>
<div class="">//+</div>
<div class="">SetFactory("OpenCASCADE");</div>
<div class="">Box(1) = {-0.5, -0.5, 0, 1, 1, 1};</div>
<div class="">Characteristic Length {:} = 0.01;</div>
<div class=""><br class="">
</div>
<div class="">I get the following timings (optimized build, scalar-type=real, 64-bit-indices=false, SKL cluster).</div>
<div class="">$ mpirun  -n 120 ./ex2 -filename untitled.msh -log_view -interpolate true</div>
<div class="">DMPlexInterp           1 1.0 1.0444e+02 1.0 0.00e+00 0.0 0.0e+00 0.0e+00 3.0e+00 73  0  0  0  5  73  0  0  0  6     0</div>
<div class="">
<div class="">DMPlexDistribute       1 1.0 2.8793e+01 1.0 0.00e+00 0.0 3.6e+03 6.2e+05 3.3e+01 21  0100100 60  21  0100100 69     0</div>
<div class="">$ mpirun  -n 120 ./ex2 -filename untitled.msh -log_view -interpolate false</div>
<div class="">DMPlexDistribute       1 1.0 7.0265e+02 1.0 0.00e+00 0.0 3.1e+03 2.0e+05 2.6e+01 99  0100100 58  99  0100100 68     0</div>
</div>
<div class=""><br class="">
</div>
</div>
<div class="">Do you think I messed up something else?</div>
<div class="">Our legacy implementation, on the same mesh, takes around 20 seconds (accounting for the ParMETIS call) to partition and distribute the mesh and generate the underlying structures for our FEM kernels (kd tree, distributed numbering, so on and
 so forth).</div>
<div class="">Of course, DMPlex is much more versatile and generic, so I’d understand if it’s a little bit slower, but that’s quite a lot slower right now.</div>
<div class="">Are there any option I could try to play with to speed things up?</div>
</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div><br class="">
</div>
<div>Hi Pierre,</div>
<div><br class="">
</div>
<div>sorry, I got this thread delayed because our spam filter caught it all.</div>
<div><br class="">
</div>
<div>From just looking at your excerpt, I think the difference could be that we are loading HDF5/XDMF in parallel so DMPlexInterpolate() within DMPlexCreateFromFile() is also done in parallel.</div>
<div><br class="">
</div>
<div>However, if you load GMSH, I think it's loaded in serial, and then DMPlexInterpolate() is also serial if you just pass interpolate=PETSC_TRUE to DMPlexCreateFromFile().</div>
<div><br class="">
</div>
<div>So I would try</div>
<div>ierr = DMPlexCreateFromFile(comm, user->filename, PETSC_FALSE, dm);CHKERRQ(ierr);</div>
<div>ierr = DMPlexDistribute(*dm, 0, NULL, &dmParallel);CHKERRQ(ierr);</div>
<div>ierr = DMDestroy(dm);CHKERRQ(ierr);</div>
<div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">ierr = DMPlexInterpolate(dmParallel,dm);CHKERRQ(ierr);</span></div>
<div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""><br class="">
</span></div>
<div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">Obviously, the API should be improved somehow to avoid these issues.</span></font></div>
<div><a href="https://gitlab.com/petsc/petsc/-/issues/615" class="">https://gitlab.com/petsc/petsc/-/issues/615</a></div>
<div><br class="">
</div>
<div>Cheers,</div>
<div>Vaclav</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class="">
<div class=""><br class="">
</div>
<div class="">Thanks in advance for your help,</div>
<div class="">Pierre</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<div class="gmail_quote">
<div class="">Yes. What we want you to do is:</div>
<div class=""><br class="">
</div>
<div class="">1) Load/generate mesh</div>
<div class=""><br class="">
</div>
<div class="">2) Distribute (this can be done at the same time as load with parallel load)</div>
<div class=""><br class="">
</div>
<div class="">3) Interpolate (this is also an option from parallel load)</div>
<div class=""><br class="">
</div>
<div class="">4) If necessary, redistribute for load balance</div>
<div class=""><br class="">
</div>
<div class="">5) Construct overlap</div>
<div class=""><br class="">
</div>
<div class="">    When you pass '1' below to DMDistribute(), it distributes as normal and then calls</div>
<div class=""><br class="">
</div>
<div class="">      <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMPLEX/DMPlexDistributeOverlap.html" class="">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMPLEX/DMPlexDistributeOverlap.html</a></div>
<div class=""><br class="">
</div>
<div class="">    at the end. So you just postpone calling that until you have interpolated.</div>
<div class=""><br class="">
</div>
<div class="">  Thanks,</div>
<div class=""><br class="">
</div>
<div class="">    Matt</div>
<div class=""> </div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
Here is a MWE.<br class="">
$ patch -p1 < patch.txt<br class="">
$ cd src/dm/impls/plex/tests/<br class="">
$ make ex18<br class="">
$ mpirun -n 2 ./ex18 -distribute -interpolate after_distribute<br class="">
[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br class="">
[0]PETSC ERROR: Petsc has generated inconsistent data<br class="">
[0]PETSC ERROR: Point SF contains 1 which is a cell<br class="">
<br class="">
Thanks,<br class="">
Pierre<br class="">
<br class="">
diff --git a/src/dm/impls/plex/tests/ex18.c b/src/dm/impls/plex/tests/ex18.c<br class="">
index 07421b3522..dd62be58e5 100644<br class="">
--- a/src/dm/impls/plex/tests/ex18.c<br class="">
+++ b/src/dm/impls/plex/tests/ex18.c<br class="">
@@ -806 +806 @@ static PetscErrorCode CreateMesh(MPI_Comm comm, AppCtx *user, DM *dm)<br class="">
-    ierr = DMPlexDistribute(*dm, 0, NULL, &pdm);CHKERRQ(ierr);<br class="">
+    ierr = DMPlexDistribute(*dm, 1, NULL, &pdm);CHKERRQ(ierr);</blockquote>
</div>
<br clear="all" class="">
<div class=""><br class="">
</div>
--<span class="Apple-converted-space"> </span><br class="">
<div dir="ltr" class="gmail_signature">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">
-- Norbert Wiener</div>
<div class=""><br class="">
</div>
<div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</body>
</html>