Repository navigation
Make the isotropic metric on every rank in step (#975) - #1287
Conversation
When the indicator is not the mesh's first field, PETSc's DMPlexMetricCreateIsotropic projects it onto the metric's P1 space on the indicator vector's own DM. The projection needs that DM's coordinate field, which PETSc creates lazily, only on ranks holding cells. Each object created on the communicator takes a tag from it, so a rank with no cells fell one tag behind, and the next two-sided exchange (a later distribute) hung. adaptivity._isotropic_metric creates the coordinate field on the indicator's DM first, on every rank, then makes the metric. Mesh.remesh and mesh_adapt_meshVar both use it; the TODO(BUG) in remesh goes. Underworld development team with AI support from Claude Code
|
Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)) Review of #1287 at 6f42ac3Verdict at 6f42ac3: ready to merge on green from this review. The fix does what it says. On development, with one rank holding no cells and the indicator as field 1 or 2, the empty rank's next tag on COMM_WORLD is one behind the others after the isotropic metric is made, and the next distribute hangs. This is true at np 3, 4 and 5, through both library routes ( Method
1. Tag probe, triangle fixture with an empty rank ("lib" route)
In every hang, the supervisor's stacks match the issue's. Every rank is in the next On the branch at field 1, every rank ends on the tag that development's ranks with cells reach (536870582 at np 3). So the forced field is the object the empty rank was missing, and no other tag is taken. At field 0, the branch takes one tag more than development on every rank. That is the forced field, which the copy path does not otherwise make. It is the same on every rank, so it does no harm. Control: the plain 2. The two library routesThis PETSc has no metric remesher (
A grep of 3. Repeated callThe metric was made twice on the same indicator DM, and then
On development the drift of 1 stays after the second call and the distribute hangs. 4. AnswersThe metric vector was gathered on each rank, branch against development, at fields 0, 1 and 2:
5. CostThe time to make the metric (largest over the ranks) was 0.40-0.57 ms on both branch and development in every run, np 1 to 5. The differences are within run-to-run noise. The forced field is made once per indicator DM. 6. The new test
Development fails at the tag assertion, before the distribute, so the test fails fast rather than hanging. The remesher skip is reached only when 7. Neighbouring tests, branch vs developmentSerial (4 xdist workers): test_0810, test_0830, test_0834, Parallel, np 2 and np 3:
Every (file, np) pair has the same outcome on branch and development. 8. Reading the diff
Findings
What was run and not runRun: the probes above at np 1, 2, 3, 4 and 5 (np 5 oversubscribed on 4 cores), branch and development; the new test at np 2-5; the serial and parallel neighbours listed above. Not run:
Other jobs on the machine were running at the same time on other cores. Timings are indicative only. Logs kept by the reviewer. Underworld development team with AI support from Claude Code |
Fixes #975. Review: H1, the session that reviews pull requests and runs the parallel tests on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH).
The cause
This is the mechanism of #1271, at another site:
DMPlexMetricCreateIsotropicprojects it onto the metric's P1 space withDMProjectFieldLocalon the indicator vector's own DM. That DM is the variable's one-field DM, notmesh.dm.distribute, then pairs messages under different tags and hangs.Measured with the reproducer on the issue (cells 8 / 8 / 0 at np 3, the indicator as field 1), the next tag on
COMM_WORLDafter the call was:A gdb comparison of every tag-taking object creation on the ranks has exactly one difference: a coordinate
DMField(DMCreateCoordinateField_Plex) made on the ranks with cells and not on the empty rank. With the indicator as field 0, PETSc copies instead of projecting, so the tags agree. That is why H1's probe needed a second field.The change
adaptivity._isotropic_metric(dm, indicator_vec, field_id)creates the coordinate field on the indicator vector's DM, on every rank, with the existingdm_force_coordinate_field, and then callsmetricCreateIsotropic.Mesh.remeshandadaptivity.mesh_adapt_meshVarboth use it.TODO(BUG)inremeshgoes.This was the issue's suggested direction. Option 1 there, building the metric on a DM where the indicator is field 0, is not needed once the field exists on every rank.
Test
tests/parallel/test_0975_metric_on_an_empty_rank_parallel.pyuses the empty-rank right triangle (empty_rank_fixtures), with the indicator as the second field.remeshandmesh_adapt_meshVar. This PETSc has no metric remesher, so both stop atadaptMetricwith their plain error, after the metric is made. The test skips if a remesher is present.COMM_WORLDis the same on every rank, then that a new mesh distributes.Regression
scripts/check_test_coverage.py: OK.Follow-ups from #1271's review (other clone and sub-DM sites, probed one by one) come in a separate PR.
Underworld development team with AI support from Claude Code