














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: Sel Top-Computer Science; Subject: (Computer Science); University: University of Houston; Term: Spring 2006;
Typology: Study notes
1 / 22
This page cannot be seen from the preview
Don't miss anything!















COSC 4397 – Parallel ComputationEdgar Gabriel
Edgar GabrielSpring 2006
2
COSC 4397 – Parallel ComputationEdgar Gabriel
an
MPI_Group
is the object describing the list of processes
forming a logical entity– a group has a size
MPI_Group_size
and (size of group -1)
MPI_Group_rank
communication
4
COSC 4397 – Parallel ComputationEdgar Gabriel
mpirun/mpiexec
MPI_Init
MPI_Init
5
COSC 4397 – Parallel ComputationEdgar Gabriel
-^
All communicators in MPI-1 are derived from MPI_COMM_WORLD
and
MPI_COMM_SELF
-^
Creating a freeing a communicator is a
collective
operation
Ä
all processes of the participating original communicator have to call the function with the same arguments
-^
Methods to create new communicators– splitting the original communicator into n-parts– creating subgroups of the original communicator– re-ordering of processes based on topology information– spawn new processes– connect two applications and merge their
communicators
7
COSC 4397 – Parallel ComputationEdgar Gabriel
-^
odd/even splitting of processes
-^
a process– can just be part of
one
of the generated communicators
MPI_Comm newcomm;int color, rank;MPI_Comm_rank (MPI_COMM_WORLD, &rank);color = rank%2;MPI_Comm_split (MPI_COMM_WORLD,– can not “see” the other communicators– can not “see” how many communicators have been created
color, rank, &newcomm);
MPI_Comm_size (newcomm, &size);MPI_Comm_rank (newcomm, &rank);
8
COSC 4397 – Parallel ComputationEdgar Gabriel
rank and size of the new communicator
MPI_COMM_WORLDnewcomm,
color=0,
size
=
4
0
1
2
3
4
5
6
0
1
2
3
0
1
2
newcomm,
color=1,
size
=
3
10
COSC 4397 – Parallel ComputationEdgar Gabriel
comm
MPI_Comm_group() MPI_Group_incl/excl()
MPI_Comm_create()
newcomm
original communicatorExtract the group of processesfrom the original communicatorModify the groupCreate new communicator basedon the modified groupnew communicator
11
COSC 4397 – Parallel ComputationEdgar Gabriel
with
: original communicator
: the group object describing the list of
participating processes in
comm
MPI_Comm_group (MPI_Comm comm, MPI_Group *group);
13
COSC 4397 – Parallel ComputationEdgar Gabriel
for more group-constructors, see also^ – MPI_Group_range_incl– MPI_Group_range_excl– MPI_Group_difference– MPI_Group_intersection– MPI_Group_union
14
COSC 4397 – Parallel ComputationEdgar Gabriel
with
: original communicator
: the group object describing the list of processes
for the new communicator
: resulting communicator
Note:
is always a subset of
comm
one
communicator at a time (in contrary
to
MPI_Comm_split
)
comm
will be
MPI_COMM_NULL
for processes which
have been excluded/not included in
newgroup
MPI_Comm_create ( MPI_Comm comm, MPI_Group newgroup,
MPI_Comm *newcomm);
16
COSC 4397 – Parallel ComputationEdgar Gabriel
MPI_Comm newcomm;MPI_Group group, newgroup;int color, size, ranks[5], cnt;MPI_Comm_size (MPI_COMM_WORLD, &size);cnt = 5;ranks[0] = 0; ranks[1] = 1; ranks[2] = 2; ranks[3] = 3;ranks[4] = size-1MPI_Comm_group (MPI_COMM_WORLD, &group);MPI_Group_incl (group,
cnt, ranks, &newgroup)
MPI_Comm_create (comm,
newgroup, &newcomm);
if ( newcomm != MPI_COMM_NULL ) {
MPI_Comm_rank (newcomm, &nrank);MPI_Comm_free (&newcomm);MPI_Group_free (&newgroup);
} MPI_Group_free (&group);
17
COSC 4397 – Parallel ComputationEdgar Gabriel
NOTE:
Assuming
that
size
5,
ranks
is
large
enough
etc.
*/
MPI_Comm_size (MPI_COMM_WORLD, &size);cnt = 0;for ( i=4; i<(size-1); i++) {
ranks[cnt++] = I; } MPI_Comm_group (MPI_COMM_WORLD, &group);MPI_Group_excl (group,
cnt-1, ranks, &newgroup)
MPI_Comm_create (comm, newgroup, &newcomm);if ( newcomm != MPI_COMM_NULL ) {
MPI_Comm_rank (newcomm, &nrank);MPI_Comm_free (&newcomm);MPI_Group_free (&newgroup);
} MPI_Group_free (&group);
19
COSC 4397 – Parallel ComputationEdgar Gabriel
Creating a communicator using topology information– e.g. generate a communicator, where the processes
form a 2-D/3-D logical cartesian grid with MPI_Cart_create
processes in all dimensions available
the cartesian grid using
MPI_Cart_sub
are ordered logically as described by a directed graphusing
MPI_Graph_create
20
COSC 4397 – Parallel ComputationEdgar Gabriel
An intra-communicator contains of a single group ofprocesses– all processes have a unique rank in the group
-^
An inter-communicator contains of two groups– a local group and a remote group– a process is always part of a local group, e.g. has a
unique rank in the local group
ranking scheme
you have two processes having the rank 0, one inthe local group and one in the remote group