feat: parallelize apply_patch & apply_channels#240
Conversation
|
@SorooshMani-NOAA @felicio93 I've opened this PR as a draft for now, so you can review the pool solution(You can find that in last 3 commits here) , if it's fine then adding tests should be remaining. I followed the same solution implemented in _apply_contours() passing the shared pool. If you can confirm that so I can work on providing suitable tests. |
|
The Each MPI rank owns its own independent Pool — ranks never share pools with each other, so no cross-rank conflicts. Within a rank, the shared pool goes strictly downward through the call chain, never sideways or nested. This guarantees exactly one level of multiprocessing per rank: In Phase 2, Rank 0 acts as coordinator: it owns Inside each worker rank, the shared-pool infrastructure from this PR is what runs. When a worker rank processes its tile, it calls I also found this resource
Another good points I found for Phase 2For additional MPI safety, two runtime considerations apply: First, Finally, I came into something while searching: how heavy it is to create and destroy a Pool in our code. While it's safe (they never overlap), it can be optimized. Currently a single The [NERSC Parallel Python guide](https://docs.nersc.gov/development/languages/python/parallel-python/) explicitly warns: "Creating and destroying Pool objects repeatedly is expensive. Create a single Pool at the start and reuse it." A future optimization would lift the Pool to the |
|
Thanks @anas-ibrahem it was a very good explainer. In the end we'll have pool of tasks that are limited to MPI rank's cores, we have to find a way to optimize it from the top when running, e.g. in collector, etc. But at least we can be assured that it's contained within the rank. I totally agree with the point on creating one pool at the top. add_pool_args addresses this to some degree, but we need to make sure we make full use of it. |
I agree, so I will continue on our approach to comeplete this PR then. |
|
Hey @anas-ibrahem , here is how you can test it and what to expect:
|



No description provided.