salvus.mesh.algorithms.distributed_mesh.mpi_communication
salvus.mesh.algorithms.distributed_mesh.mpi_communication salvus mesh algorithms distributed_mesh mpi_communication MPI broadcast and scatter utilities for Salvus meshes.
Functions
broadcast_mesh()
broadcast_mesh()def broadcast_mesh(mesh: Mesh | None, comm: int, root: int) -> Mesh: ...Broadcast a Mesh from the root rank to all other ranks.
This function broadcasts a Salvus Mesh efficiently by transferring each numpy array individually, avoiding memory duplication on the root rank that would occur with full serialization. Scalar values and non-array objects are serialized using dill.
meshMesh | None — The Mesh to broadcast. Only needs to be valid on the root rank; can be None on other ranks.commint — MPI communicator handle.rootint — The rank that holds the mesh to broadcast.
scatter_meshes()
scatter_meshes()def scatter_meshes(
meshes: list[Mesh] | None, comm: int, root: int
) -> Mesh: ...Scatter a list of Meshes from the root rank, one mesh per rank.
On the root rank, meshes must be a list of length comm_size; rank
i receives meshes[i]. The meshes may have completely different
structure (different number of blocks, different field keys, different
array shapes).
The implementation uses point-to-point send/recv rather than
bindings.mpi.scatter. This will cause an efficient transfer of numpy
arrays but it is a manual loop over ranks instead of a built-in MPI
scatter.
mesheslist[Mesh] | None — On the root rank, a list of meshes of length equal to the communicator size; ignored on other ranks.commint — MPI communicator handle.rootint — The rank that holds the list of meshes to scatter.