210 likes | 422 Views
Enabling MPI Interoperability Through Flexible Communication Endpoints. James Dinan , Pavan Balaji , David Goodell , Douglas Miller , Marc Snir , and Rajeev Thakur. Mapping of Ranks to Processes in MPI. Conventional Communicator. MPI provides a 1-to-1 mapping of ranks to processes
E N D
Enabling MPI Interoperability Through Flexible Communication Endpoints James Dinan, PavanBalaji, David Goodell,Douglas Miller, Marc Snir, and Rajeev Thakur
Mapping of Ranks to Processes in MPI Conventional Communicator • MPI provides a 1-to-1 mapping of ranks to processes • This was good in the past, but usage models have evolved • Programmers use many-to-one mapping of threads to processes • E.g. Hybrid parallel programming with OpenMP/threads • Other programming models also use many-to-one mapping • Interoperability is a key objective, e.g. with Charm++, etc… Process Process Rank Rank … T T T T T
Current Approaches to Hybrid MPI+Threads • MPI message matching space: <communicator, sender, tag> • Two approaches to using THREAD_MULTIPLE • Match specific thread using the tag: • Partition the tag space to address individual threads • Limitations: • Collectives – Multiple threads at a process can’t participate concurrently • Wildcards – Multiple threads concurrently requires care • Match specific thread using the communicator: • Split threads across different communicators (e.g. Dup and assign) • Can use wildcards and collectives • However, limits connectivity of threads with each other
Impact of Light Cores and Threads on Message Rate • Shamelessly stolen from Brian Barrett, et al. [EuroMPI ‘13] • Threads sharing a rank increase posted receive queue depth (x-axis) • Solution: More ranks! • Adding more MPI processes fragments the node • Can’t do shared memory programming across the whole node
Endpoints: Flexible Mapping of Ranks to Processes Endpoints Communicator • Provide a many-to-one mapping of ranks to processes • Allows threads to act as first-class participants in MPI operations • Improve programmability of MPI + node-level and MPI + system-level models • Potential for improving performance of hybrid MPI + X • A rank represents a communication “endpoint” • Set of resources that supports the independent execution of MPI communications • Note: Figure demonstrates many usages, some may impact performance Process Process Process Rank Rank Rank Rank Rank Rank … T T T T T T T
Impact on MPI Implementations Process • Two implementation strategies • Each rank is a distinct network endpoint • Ranks are multiplexed on endpoints • Effectively adds destination rank tothe matching criteria • Currently rank is not included,because there is one per process • Combination of the above • Potential to reduce threading overheads • Separate resources per thread • Rank can represent distinct network resources • Increase HFI/NIC concurrency • Separate software state per thread • Per-endpoint message queues/matching • Split up progress across threads, increase progress engine concurrency • Enable per-communicator threading levels • COMM_WORLD = THREAD_MULTIPLE, my_comm = THREAD_FUNNELED Rank Rank Rank T T T
The Endpoints Programming Interface • Interface choices impact performance and usability • Key parameter, creation of Endpoints: • Static interface • Endpoints fixed for entire execution • Pro: Allows simpler implementation • Con: Interface is restrictive, not usable with libraries • Proposed for, but not included in MPI 3.0 • Dynamicinterface • Additional endpoints can be added dynamically • Pro: More expressive interface • Con: Implementation is not as simple • Proposed for MPI <next> • Association of endpoints with threads • Explicit attach/detach or implicit • Goal: Avoid dependence on particular threading packages
Static Endpoint Creation 012 3 4 MPI_COMM_ENDPOINTS • MPI_COMM_ENDPOINTS defined statically • New MPI_INIT_ENDPOINTS function • “mpiexec --num_ep XX”, requires calling Init for each EP, OOB num_ep • E.g. for (ep = 0; ep < my_num_ep) MPI_Init(); • Allows simple resource management • Creation/freeing/mapping of network endpoints at startup/exit • Interface is inflexible • Not easy for libraries and apps to both use static endpoints 0 1 MPI_COMM_WORLD Process Process Rank Rank Rank Rank Rank T T T
Dynamic Endpoint Creation 0 1 MPI_COMM_WORLD • Endpoints communicator is created dynamically • Through new MPI_COMM_CREATE_ENDPOINTS operation • More expressive interface • Allows libraries and apps equal access to endpoints • Dynamic resource management • Endpoints are added/removed dynamically • More sophisticated implementation required (Option #2 or #3) 012 3 4 my_ep_comm Process Process Rank Rank Rank Rank Rank T T T
Representation of Endpoints (Static/Dynamic) • One handle: MPI_COMM_EP / my_ep_comm • Single communicator handle given to parent process • How to identify desired endpoints in MPI calls? • Threads/processes must attach/detach prior to making an MPI call • Endpoint I am using is cached in per-thread state • Requires MPI to use thread-local storage (TLS) • Adds a TLS lookup on the critical path for every operation • N handles: MPI_COMM_EP[MY_EP] / my_ep_comm[MY_EP] • Multiple communicator handles, one per endpoint • Attach/detach is not needed (but could be helpful) • MPI does not need to use TLS • Improves interoperability with threading packages
Putting It All Together: Proposed Interface intMPI_Comm_create_endpoints( MPI_Commparent_comm, int my_num_ep, MPI_Infoinfo, MPI_Comm*out_comm_hdls[]) • Each rank in parent_comm gets my_num_ep ranks in out_comm • My_num_ep can be different at each process • Rank order: process 0’s ranks, process 1’s ranks, etc. • Output is an array of communicator handles • ithhandle corresponds to ithendpoint create by parent process • To use that endpoint, use the corresponding handle 0 1 2 0 1 2 3 4
Collectives and Endpoints • Endpoints have exactly thesame semantics as MPI processes • Collective routines must be calledby all ranks in the communicator concurrently • MPI_THREAD_MULTIPLE required for collectives to be used with endpoints • Exception: Freeing the communicator • Want to avoid requiring MPI_THREAD_MULTIPLE • Allow usages where endpoints are used with MPI_THREAD_FUNNELED • The implementation must allow a single thread to free the communicator by calling MPI_COMM_FREE once per endpoint 0 1 2 0 1 2 3 4
Usage Models are Many… • Intranode parallel programming with MPI • Spawn endpoints off MPI_COMM_SELF • Allow true thread multiple, with each thread addressable • Spawn endpoints off MPI_COMM_WORLD • Obtain better performance • Partition threads into groups and assign a rank to each group • Performance benefits without partitioning shared memory programming model • Interoperability • Examples: OpenMP and UPC
Enabling OpenMP Threads in MPI Collectives • Hybrid MPI+OpenMP code • Endpoints are used to enable OpenMP threads to fully utilize MPI
Enabling UPC+MPI Interoperability: User Code • UPC runtime may be using threads within the node • UPC compiler substitutes its own world communicator for MPI_COMM_WORLD • Can use the PMPI interface, if needed • Compiler generates MPI calls needed to give a rank to each UPC thread
Flexible Computation Mapping MPI Process MPI Process MPI Process • Ranks correspond to work units, e.g., mesh tiles • Data exchange between work units maps to communication between ranks • Periodic load balancing redistributes work (i.e. ranks) • Communication is preserved, because it follows the ranks COMM_WORLD 0 1 2 work_comm 0 1 2 3 4 5 6 6 3 5 5 4 5 6 balanced_comm
Thank you and Acknowledgements • We thank the many members of the MPI community and MPI forum who contributed to this work! • Review the formal proposal: • https://svn.mpi-forum.org/trac/mpi-forum-web/ticket/380 • Send comments to MPI Forum’s hybrid working group or james.dinan@intel.com Disclaimer: This presentation represents the views of the authors, and does not necessarily represent the views of Intel.
Endpoints Proposal, Prototype intMPI_Comm_create_endpoints(MPI_Comm parent_comm,intmy_num_ep, MPI_Infoinfo, MPI_Comm *out_comm_hdls[]) MPI_Comm_create_endpoints(parent_comm, my_num_ep, info,out_comm_hdls) BIND(C) Type(MPI_Comm), INTENT(IN) :: parent_comm INTEGER, INTENT(IN) :: my_num_ep TYPE(MPI_Info), INTENT(IN) :: info Type(MPI_Comm), INTENT(OUT) :: out_comm_hdls(my_num_ep) INTEGER, OPTIONAL, INTENT(OUT) :: ierror MPI_COMM_CREATE_ENDPOINTS(PARENT_COMM, MY_NUM_EP, INFO, OUT_COMM_HDLS, IERROR) INTEGER PARENT_COMM, MY_NUM_EP, INFO, OUT_COMM_HDLS(*), IERROR
Endpoints Proposal, Text Part 1 This function creates a new communicator from an existing communicator, parent_comm, where my_num_epranks in the output communicator are associated with a single calling rank in parent_comm. This function is collective on parent_comm. Distinct handles for each associated rank in the output communicator are returned in the new_comm_hdls array at the corresponding rank in parent_comm. Ranks associated with a process in parent_comm are numbered contiguously in the output communicator, and the starting rank is defined by the order of the associated rank in the parent communicator. If parent_comm is an intracommunicator, this function returns a new intracommunicator new_comm with a communication group of size equal to the sum of the values of my_num_ep on all calling processes. No cached information propagates from parent_comm to new_comm. Each process in parent_comm must call MPI_COMM_CREATE_ENDPOINTS with a my_num_ep argument that ranges from 0 to the value of the MPI_COMM_MAX_ENDPOINTS attribute on parent_comm. Each process may specify a different value for the my_num_epargument. When my_num_ep is 0, no output communicator is returned. If parent_comm is an intercommunicator, then the output communicator is also an intercommunicator where the local group consists of endpoint ranks associated with ranks in the local group of parent_comm and the remote group consists of endpoint ranks associated with ranks in the remote group of parent_comm. If either the local or remote group is empty, MPI_COMM_NULL is returned in all entries of new_comm_hdls.
Endpoints Proposal, Text Part 2 Ranks in new_comm behave as MPI processes. For example, a collective function on new_comm must be called concurrently on every rank in this communicator. An exception to this rule is made for MPI_COMM_FREE, which must be called for every rank in new_comm, but must permit a single thread to perform these calls serially. Rationale: The concurrency exception for MPI_COMM_FREE is made to enable MPI_COMM_CREATE_ENDPOINTS to be used when the MPI library has not been initialized with MPI_THREAD_MULTIPLE, or when the threading package cannot satisfy the concurrency requirement for collective operations. Advice to Users: Although threads can acquire individual ranks through the MPI_COMM_CREATE_ENDPOINTS function, they still share an instance of the MPI library. Users must ensure that the threading level with which MPI was initialized is maintained. Some operations, such as collective operations, cannot be used by multiple threads sharing an instance of the MPI library, when MPI was initialized with MPI_THREAD_MULTIPLE. Proposed New Error Classes MPI_ERR_ENDPOINTS -- The requested number of endpoints could not be provided. Proposed New Info Keys same_num_ep-- All processes will provide the same my_num_ep argument to MPI_COMM_CREATE_ENDPOINTS.