Virtual Topologies
Definition
A virtual topology is a mechanism for naming the processes in a
communicator in a way that fits the communication pattern better.
Advantages
- The main goal is to make programming simpler.
- It may also provide hints to the run-time system which allow
it to optimize communication.
- For example: if your processes will communicate mainly with the
nearest neighbors (see the 2-D grid in the figure below), you could
create a topology to reflect this.
- The following 2-D grid is a virtual topology of 12 processes. The
lines denote the main communication patterns, namely between
neighbors. The grid actually has a cyclic boundary condition in one
direction, e.g. process 0 and 9 are "connected". The top numbers
represent the ranks in the new communicator and the conceptual
coordinates mapped to the ranks.
- What this buys is access to convenient routines which, for
example, compute the ranks of your nearest neighbor given its
coordinates in the grid. When doing this one needs to pay attention
to the boundary conditions, i.e. returning MPI_NULL_PROC if you
go outside the grid.
- Although the main communication patterns are highlighted by
"connection lines", any process within the communicator can still
communicate with any other.