Clean up library context management.
Reconcile discrepancies MPI vs. tMPI initialization, acquisition, and finalization. Unify other similar resource management, such as GPU device contexts, thread pool, cpuset, etc.
Follow up from #3644
Relates to #3650
- [ ] Merge `gmxapi::MpiContextManager` and `gmx::init`/`gmx::finalize`
- [ ] Improve RAII semantics for "MpiContext". Either find a way to join the initialization of thread-MPI context with its acquisition or consider alternatives to using such an object in the corresponding tMPI program scope.
- [ ] Clarify the `SimulationContext` invariant(s). Encode the invariant(s) with strong typing to improve readability across tMPI vs. MPI builds.
- [ ] Encapsulate the `libraryCommunicator` from the MPI `SimulationContext` into a PhysicalNodeCommunicator. (tMPI can have an unset `std::optional` or similar if such resources cannot be provided through SimulationContext on this code path.)
- [x] Python bindings for `gmxapi::ResourceAssignment`; Allow gmxapi to re-wrap an mpi4py communicator for `gmxapi::createContext()` (#4422)
# Still deferred
#3644 notes that multisim is reasonably a higher-level detail that can be separated into layers, such that `SimultionContext` can abstractly present the simulator with a single communicator or abstract communication resources. We should reserve such discussions for separately tracked issues.
issue