Optimizing communication

An interesting feature that is provided by MPI regards virtual topologies. As already noted, all the communication functions (point-to-point or collective) refer to a group of processes. We have always used the MPI_COMM_WORLD group that includes all processes. It assigns a rank of 0 to n-1 for each process that belongs to a communicator of the size n.

However, MPI allows us to assign a virtual topology to a communicator. It defines an assignment of labels to the different processes: by building a virtual topology, each node will communicate only with its virtual neighbor, improving performance because it reduces execution times.

For example, if the rank was randomly assigned, then a message could be forced to pass to many other nodes before it reaches the destination. Beyond the question of performance, a virtual topology makes sure that the code is clearer and more readable.

MPI provides two building topologies. The first construct creates Cartesian topologies, while the latter creates any kind of topologies. Specifically, in the second case, we must supply the adjacency matrix of the graph that you want to build. We will only deal with Cartesian topologies, through which it is possible to build several structures that are widely used, such as mesh, ring, and toroid.

The mpi4py function used to create a Cartesian topology is as follows:

comm.Create_cart((number_of_rows,number_of_columns))

Here, number_of_rows and number_of_columns specify the rows and columns of the grid that is to be made.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.150.89