Introduction So far, the communicator that you are familiar with is MPI COMM WORLD This is a communicator defined by MPI to permit all processes of your program to communicate with each other at run time, either between two processes( point to-point )or among all processes( collective For some applications however, communications among a selected subgroup of processes may be desirable or required In this section, you will learn how to create new communicators for these situations
Introduction • So far, the communicator that you are familiar with is MPI_COMM_WORLD. • This is a communicator defined by MPI to permit all processes of your program to communicate with each other at run time, either between two processes ( pointto-point ) or among all processes ( collective ). • For some applications however, communications among a selected subgroup of processes may be desirable or required. • In this section, you will learn how to create new communicators for these situations
Introduction Two types of communicators exist within MPI Intra-communicators Inter -communicators This chapter will focus on intra- communicators that deal with communications among processes within individual communicators Inter-communicators on the other hand deal with communications t between intra-communicators Essentially intra-communicators are subsets of processes of MPI COMM WORLD The need for these new communicators is often driven by the need to deal subblock f a mat These communicators are often used in conjunction with a virtual topology more often than not a Cartesian topology -to facilitate implementation of parallel operations Furthermore, the use of communicators, and quite frequently together with virtual topology, generally enhances the readability and maintainability of a program
Introduction • Two types of communicators exist within MPI: – Intra-communicators – Inter-communicators. • This chapter will focus on intra-communicators that deal with communications among processes within individual communicators. • Inter-communicators, on the other hand, deal with communications between intra-communicators. • Essentially, intra-communicators are subsets of processes of MPI_COMM_WORLD. • The need for these new communicators is often driven by the need to deal with, for instance, rows, columns or subblocks of a matrix. • These communicators are often used in conjunction with a virtual topology - - more often than not a Cartesian topology -- to facilitate implementation of parallel operations. • Furthermore, the use of communicators, and quite frequently together with virtual topology, generally enhances the readability and maintainability of a program
Introduction To this end, many routines are available in the mPi librar to perform various communication-related tasks. These are MPI COMM GROUP MPI GROUP NCL MPI GROUP EXCL MPI GROUP RANK MPI GROUP FREE MPI COMM CREATE MPI COMM SPLIT These routines are described in the following sections
Introduction • To this end, many routines are available in the MPI library to perform various communication-related tasks. These are – MPI_COMM_GROUP – MPI_GROUP_INCL – MPI_GROUP_EXCL – MPI_GROUP_RANK – MPI_GROUP_FREE – MPI_COMM_CREATE – MPI_COMM_SPLIT • These routines are described in the following sections
MPI COMM GROUP Definition of mPl comm group Used to return the group underlying the communicator,; you get a handle to the group of comm The MPl COMM GROUP routine determines the group handle of a communicator int MPl Comm group( MPl Comm comm, MPI Group * group The function returns an int error flag Variable Name C Type In/Out Description comm MPI Comm Input Communicator handle group MPL_Group* Output Group handle
MPI_COMM_GROUP • Definition of MPI_COMM_GROUP – Used to return the group underlying the communicator; you get a handle to the group of comm. • The MPI_COMM_GROUP routine determines the group handle of a communicator. int MPI_Comm_group( MPI_Comm comm, MPI_Group *group ) • The function returns an int error flag. Variable Name C Type In/Out Description comm MPI_Comm Input Communicator handle group MPI_Group * Output Group handle
MPI COMM GROUP EXample Include " mpi.h MPI Comm comm world MPI Group group world comm world MPI COMM WORLD MPI Comm group(comm world, &group world)
MPI_COMM_GROUP • Example #include "mpi.h" MPI_Comm comm_world; MPI_Group group_world; comm_world = MPI_COMM_WORLD; MPI_Comm_group(comm_world, &group_world);
MPI COMM GROUP Definition of mel comm world Default communicator consisting of all processes Definition of mel group incl Used to form a new group from the processes belonging to group within specified ranks Definition of mpl comm create Used to create a new intracommunicator from the processes listed in new group Definition of mpl group rank Used to return the rank of the calling process in group
MPI_COMM_GROUP • Definition of MPI_COMM_WORLD – Default communicator consisting of all processes. • Definition of MPI_GROUP_INCL – Used to form a new group from the processes belonging to group within specified ranks. • Definition of MPI_COMM_CREATE – Used to create a new intracommunicator from the processes listed in new_group. • Definition of MPI_GROUP_RANK – Used to return the rank of the calling process in group
MPI COMM GROUP Associated with a communicator is its group identity, or handle. In the above example, we used MPI COMM GROUP to obtain the group handle of the communicator mpi comm world. this handle can then be used as input to the routine MPl GROUP INCL to select among the processes of one group to form another(new) group MPI COMM CREaTE to create a new communicator whose members are those of the new group MPI GROUP RANK to find the current process rank's equivalent process rank in a group
MPI_COMM_GROUP • Associated with a communicator is its group identity, or handle. In the above example, we used MPI_COMM_GROUP to obtain the group handle of the communicator MPI_COMM_WORLD. This handle can then be used as input to the routine – MPI_GROUP_INCL to select among the processes of one group to form another (new) group; – MPI_COMM_CREATE to create a new communicator whose members are those of the new group; – MPI_GROUP_RANK to find the current process rank's equivalent process rank in a group