Message Passing Architecture
Message Passing Architecture
Message Passing Architecture
External
channel
Node
Fat-Node
Node -powerful processor
-large memory
-many chips
Node-processor -costly/node
-moderate parallelism
Processor +
Local memory + ....
Thin-Node
Internal
channel(s) -small processor
Router
External -small memory
Communication channel -one-few chips
-cheap/node
Processor + -high parallelism
External Switch unit+ ....
channel
External
channel
Generic Organization Model
Switching network
P+M P+M
CP CP
(b) Centralized
(a) Decentralized
Message Passing Properties
• Absolute majority of existing message-passing code is written using one of the libraries
• We outline MPI
• Standardised in 1995 as MPI 1.1
• Widely implemented in compliance with the standard
• all hardware vendors offer MPI
• Free high-quality MPI implementations (LAM MPI, MPICH)
• Supports parallel programming in C and Fortran on all MPP
architectures
• including Unix and Windows NT platforms
16
Message-Passing Libraries
Parallel Computing 17
MPI
• An MPI program
• A fixed number of processes
• Executing their own code in their own address space
• The codes need not be identical
• Communicating via calls to MPI communication primitives
• Does not specify
• The number of processes
• The allocation of the processes to physical processors
• Such mechanisms are external to the MPI program
• must be provided by particular MPI implementations
• Uses calls to MPI inquiring operations to determine their
total number and identify themselves in the program
Parallel Computing 18
MPI (ctd)
• Two types of communication operation
• Point-to-point
• Involves two processes, one of which sends a message and other
receives the message
• Collective
• Involves a group of processes
• barrier synchronisation, broadcast, etc
Parallel Computing 19
MPI (ctd)
• Process group
• An ordered collection of processes, each with a rank
• Defines the scope of collective communication operations
• No unnecessarily synchronizing uninvolved processes
• Defines a scope for process names in point-to-point
communication operations
• Participating processes are specified by their rank in the same process
group
• Cannot be build from scratch
• Only from other, previously defined groups
• By subsetting and supersetting existing groups
• The base group of all processes available after MPI is initialised
MPI (ctd)
• Communicators
• Mechanism to safely separate messages
• Which don’t have to be logically mixed, even when the messages are transferred
between processes of the same group
• A separate communication layer associated with a group of processes
• There may be several communicators associated with the same group, providing
non-intersecting communication layers
• Communication operations explicitly specify the communicator
• Messages transmitted over different communicators cannot be mixed (a message
sent through a communicator is never received by a process not communicating
over the communicator)
MPI (ctd)
• Communicators (ctd)
• Technically, a communicator is implemented as
follows
• A unique tag is generated at runtime
• shared by all processes of the group, with which the
communicator is associated
• attached to all messages sent through the communicator
• used by the processes to filter incoming messages
• Communicators make MPI suitable for writing parallel
libraries
MPI (ctd)
• MPI vs PVM
• PVM can’t be used for implementation of parallel
libraries
• No means to have separate safe communication layers
• All communication attributes, which could be used to
separate messages, such as groups and tags, are user-defined
• The attributes do not have to be unique at runtime
• Especially if different modules of the program are written
by different programmers
MPI (ctd)
• Example 1. The pseudo-code of a PVM application
extern Proc();
if(my process ID is A)
Send message M with tag T to process B
Proc();
if(my process ID is B)
Receive a message with tag T from process A
• Does not guarantee that message M will not be intercepted inside the library
procedure Proc
• In this procedure, process A may send a message to process B
• The programmer, who coded this procedure, could attach tag T to the message
Parallel Computing 24
MPI (ctd)
• Example 2. MPI solves the problem as follows
extern Proc();
Create communicator C for a group including
processes A and B
if(my process ID is A)
Send message M to process B through
communicator C
Proc();
if(my process ID is B)
Receive a message from process A through
communicator C
• A unique tag attached to any message sent over the communicator C
prevents the interception of the message inside the procedure Proc
Groups and Communicators
• A group is an ordered set of processes
• Each process in a group is associated with an integer rank
• Ranks are contiguous and start from zero
• Groups are represented by opaque group objects of the type MPI_Group
• hence cannot be directly transferred from one process to another
• A context is a unique, system-generated tag
• That differentiates messages
• The MPI system manages this differentiation process
Groups and Communicators (ctd)
• Communicator
• Brings together the concepts of group and context
• Used in communication operations to determine the scope and
the “communication universe” in which an operation is to
operate
• Contains
• an instance of a group
• a context for point-to-point communication
• a context for collective communication
• Represented by opaque communicator objects of the type
MPI_Comm
Groups and Communicators (ctd)
• We described intra-communicators
• This type of communicators is used
• for point-to-point communication between processes of the same group
• for collective communication
• MPI also introduces inter-communicators
• Used specifically for point-to-point communication between processes of
different groups
• We do not consider inter-communicators
Groups and Communicators (ctd)
• An initial pre-defined communicator MPI_COMM_WORLD
• A communicator of all processes making up the MPI program
• Has the same value in all processes
• The group associated with MPI_COMM_WORLD
• The base group, upon which all other groups are defined
• Does not appear as a pre-defined constant
• Can be accessed using the function
int MPI_Comm_group(MPI_Comm comm, MPI_Group *group)
Groups and Communicators (ctd)
• Other group constructors
• Explicitly list the processes of an existing group, which make up a new
group, or
• Do set-like binary operations on existing groups to construct a new group
• Union
• Intersection
• Difference