Defining a Cartesian Topology
The routine MPI_Cart_create creates a Cartesian decomposition of the processes, with the number of dimensions given by the ndim argument. It returns a new communicator (in comm2d in example below) with the same processes as in the input communicator, but different topology.
dims[0] = 3; dims[1] = 4;
periods[0] = 0; periods[1] = 0; // periodic is false
reorder = 1; // reordering is true
ierr = MPI_Cart_create (MPI_COMM_WORLD, ndim,
dims, periods, reorder, &comm2d);
- where reorder specifies that it’s o.k. to reorder the default process rank in order to achieve a good embedding (with good communication times between neighbors).