I have read the definitions of these terms and my interpretation is that there is a one to one relation between a group and a communicator. A group is a set of processes which wish 开发者_高级运维to communicate with each other and a communicator is an implementation for a group.
Is this correct? Why have two different terms if this is so?
A group is an ordered set of process identifiers (MPI 2.2 spec, sec 6.2.1). The ordering is given by associating with each process identifier a unique rank from 0 to group.size - 1.
A communicator encapsulates all communication among a set of processes. An intra-communicator is associated with a group as well as contexts of communication for both point-to-point and collective communication and possibly other context information such as virtual topologies (spec, 6.1.2). An inter-communicator is associated with two non-overlapping groups.
I (probably very loosely) think of a communicator's group as its symbol table.
A group may contain process identifiers from several communicators.
Finally, construction of and operations on groups are local to the process, and do not involve interprocess communication. This is not, in general, true for communicators (by their very nature).
There are a lot of differences between communicators and groups as I found out after reading the MPI Specification.
Edit: Groups are objects that represent groups of processes.
Communicator is a set of processes that may communicate with each other and may consist of processes from a single group or from multiple groups.
Thus they are completely different entities. They should not be confused with each other.
A communicator contains group(s) while a group is just a collection of processes.
If a communicator contains just one group, it is called an intracommunicator (the communicator, MPI_COMM_WORLD is one such which refers to one group which includes all the ranks).
If it contains two groups, it is called in intercommunicator (there are none created by default for you).
Take a look at https://computing.llnl.gov/tutorials/mpi_advanced/DavidCronkSlides.pdf where he gives a very good pictorial explanation of how a communicator is a container for one or two groups.
A group in MPI corresponds to the mathematical concept "set", which is introduced in MPI to facilitate organizing processes and creating new communications. For example you can use the union and intersection operations on sets to create new sets so that you can use them to create new communicators.
A group has nothing to do with communications although a group can be used to create a communicator (a communicator is a group plus a context).
A group can also be used as an ID in distributing task/data among different processes. For instance, we can test whether a process is in a group to determine whether it should do something.
A communicator is an object describing a group of processes. In many applications all processes work together closely coupled, and the only communicator you need is MPI_COMM_WORLD .
group describing all processes that your job starts with.
精彩评论