Parallel Computation - Lecture Slides | COSC 4397, Study notes of Computer Science

Material Type: Notes; Class: Sel Top-Computer Science; Subject: (Computer Science); University: University of Houston; Term: Spring 2006;

Typology: Study notes

Pre 2010

Uploaded on 08/18/2009

koofers-user-wp7
koofers-user-wp7 🇺🇸

9 documents

1 / 22

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COSC 4397 – Parallel Computation
Edgar Gabriel
COSC 4397
Parallel Computation
Group management
Edgar Gabriel
Spring 2006
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Parallel Computation - Lecture Slides | COSC 4397 and more Study notes Computer Science in PDF only on Docsity!

COSC 4397 – Parallel ComputationEdgar Gabriel

COSC 4397

Parallel ComputationGroup management

Edgar GabrielSpring 2006

2

COSC 4397 – Parallel ComputationEdgar Gabriel

Terminology (I)

•^

an

MPI_Group

is the object describing the list of processes

forming a logical entity– a group has a size

MPI_Group_size

  • every process in the group has a unique rank between 0

and (size of group -1)

MPI_Group_rank

  • a group is a local object, and cannot be used for any

communication

4

COSC 4397 – Parallel ComputationEdgar Gabriel

Predefined communicators

• MPI_COMM_WORLD

  • contains all processes started with

mpirun/mpiexec

  • exist upon exiting

MPI_Init

  • can not be modified, freed etc.
    • MPI_COMM_SELF
      • contains just the local process itself, size is always 1– exist upon exiting

MPI_Init

  • can not be modified, freed etc.

5

COSC 4397 – Parallel ComputationEdgar Gabriel

Creating new communicators

-^

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

Example for MPI_Comm_split (I)

-^

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

Example for MPI_Comm_split (II)

•^

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

Modifying the group of processes

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

Extracting the group of processes

with

  • comm

: original communicator

  • group

: 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

Modifying groups (II)

•^

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

Creating a new communicator based on a

group

with

  • comm

: original communicator

  • group

: the group object describing the list of processes

for the new communicator

  • newcomm

: resulting communicator

Note:

  • newcomm

is always a subset of

comm

  • you can generate

one

communicator at a time (in contrary

to

MPI_Comm_split

)

  • list of arguments has to be identical on all processes of

comm

  • newcomm

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

Possibility 1: using MPI_Group_incl

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

Possibility 2: using MPI_Group_excl MPI_Comm newcomm;MPI_Group group, newgroup;int color, size, ranks[…], cnt;/*

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

What else is there?

•^

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

  • functions to determine the ranks of neighbor

processes in all dimensions available

  • e.g. extract the processes in a certain dimension of

the cartesian grid using

MPI_Cart_sub

  • e.g. generate a communicator, where the processes

are ordered logically as described by a directed graphusing

MPI_Graph_create

20

COSC 4397 – Parallel ComputationEdgar Gabriel

intra vs. inter-communicators (I)

•^

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

  • local and remote group have however separate

ranking scheme

Ä

you have two processes having the rank 0, one inthe local group and one in the remote group