Parallel mesh assignment also in single-node case
Change the strategy used when interpolating the gpart
onto the gravity mesh. Each thread (aka. top-level cell) constructs a local patch of the mesh and assigns its particles to it. When done, the patch is written to the global mesh using atomics. This is now similar to what is done in the distributed MPI case.
This strategy seems to be beneficial when there are lots of particles in only a few cells, for instance in a zoom run. It seems to not be slower in other cases either.
The behaviour can be controlled by a runtime parameter (Gravity:mesh_uses_local_patches
defaults to 1
) if one wants to roll back to the "old" per-particle atomic assignment.
Merge request reports
Activity
added SPH performance labels
@jch if you could check whether the way I am using the mesh patches here in the non-MPI case makes sense that would be much appreciated.
added 18 commits
-
a1d35e17...accda3a4 - 17 commits from branch
master
- 5831b52b - Merge branch 'master' into parallel_mesh_assignment
-
a1d35e17...accda3a4 - 17 commits from branch
requested review from @jch
assigned to @matthieu
assigned to @bvandenbroucke and unassigned @matthieu
Each mesh patch contains an array that needs to be allocated. That happens in pm_mesh_patch_init(), which is called from accumulate_cell_to_local_patch(). I don't think the patches allocated in cell_gpart_to_mesh_CIC_mapper() get freed at the moment. We need a pm_mesh_patch_clean() at the end of the loop.
In cell_gpart_to_mesh_CIC_mapper() I think we'll need to skip cells with no gparts, if that can happen. accumulate_cell_to_local_patch() just returns without allocating the patch in that case.
Edited by John Helly- Resolved by Matthieu Schaller
added 33 commits
-
5831b52b...49c26843 - 32 commits from branch
master
- f2d31f13 - Merge branch 'master' into parallel_mesh_assignment
-
5831b52b...49c26843 - 32 commits from branch
added 1 commit
- e1c9d96f - Make sure the local patches are freed after use in cell_gpart_to_mesh_CIC_mapper()
added 1 commit
- 8b1086d5 - Also escape empty cells in the MPI version of the cell->patch interpolation mapper
added 1 commit
- 51cff14a - Make the option to use local patches instead of direct atomic writes a...
@dc-rope1 any final thoughts?
mentioned in commit 1501b338