+ All Categories
Home > Documents > 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.”...

1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.”...

Date post: 15-Jan-2016
Category:
View: 215 times
Download: 0 times
Share this document with a friend
Popular Tags:
52
1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” - Parkinson’s 1st Law
Transcript
Page 1: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

1

Friday, October 20, 2006

“Work expands to fill the time available for its

completion.”

- Parkinson’s 1st Law

Page 2: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

2

MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int

tag, MPI_Comm comm, MPI_Status *status)

MPI_Get_count(MPI_Status *status, MPI_Datatype datatypeint *count_recvd)

Returns number of entries received in count_recvd variable.

Page 3: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

3

Matrix Vector Multiplicationn x n matrix AVector bx=Abp processing elementsSuppose A is distributed row-wise (n/p

rows per process)Each process computes different portion

of x

Page 4: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

4

Matrix Vector Multiplication (Initial distribution. Colors represent data distributed on different processes)

n/p rows

A b x

Page 5: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

5

Matrix Vector Multiplication (Colors represent that all parts of b are required by each process)

n/p rows

A b x

Page 6: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

6

Matrix Vector Multiplication (All parts of b are required by each process)

Which collective operation can we use?

Page 7: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

7

Matrix Vector Multiplication (All parts of b are required by each process)

Page 8: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

8

Collective communication

Page 9: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

9

Matrix Vector Multiplicationn x n matrix AVector bx=Abp processing elementsSuppose A is distributed column-wise

(n/p columns per process)Each process computes different portion

of x.

Page 10: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

10

Matrix Vector Multiplication (initial distribution. Colors represent data distributed on different processes)n/p cols

A b x

Page 11: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

11

partial x0

partial x0

partial x0

partial x0

partial x1

partial x1

partial x1

partial x1

partial x2

partial x2

partial x2

partial x2

partial x3

partial x3

partial x3

partial x3

A b

x0

x1

x2

x3

x

Partial sums calculated by each process

partial x0

n/p cols

Page 12: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

12

Page 13: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

13

1

2

3

4

3

4

5

6

2

3

4

5

4

5

6

7

Task 0 Task 1 Task 2 Task 3

10

14

18

22

Task 1

MPI_Reduce

Element wise reduction can be done.

count=4

dest=1

Page 14: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

14

Page 15: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

15

Page 16: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

16

Row-wise requires one MPI_Allgather operation.

Column-wise requires MPI_Reduce and MPI_Scatter operations.

Page 17: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

17

Matrix Matrix Multiplication

A and B are nxn matricesp is the number of processing elementsThe matrices are partitioned into blocks of

size n/√p x n/√p

Page 18: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

18

A B C

16 processes each represented by a different color. Different portions of the nxn matrices are divided among these processes.

Page 19: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

19

A B C

16 processes each represented by a different color. Different portions of the nxn matrices are divided among these processes.

BUT! To compute Ci,j we need all sub-matrices Ai,k and Bk,j for 0<=k<√p

Page 20: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

20

To compute Ci,j we need all sub-matrices Ai,k and Bk,j for 0<=k<√p

All to all broadcast of matrix A’s blocks in each row

All to all broadcast of matrix B’s blocks in each column

Page 21: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

21

Canon’s Algorithm

Memory efficient version of the previous algorithm.

Each process in ith row requires all √p sub-matrices Ai,k 0<=k<√p

Schedule computation so that computation of √p processes in ith row use diferent Ai,k at any given time

Page 22: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

22

A B

16 processes each represented by a different color. Different portions of the nxn matrices are divided among these processes.

Page 23: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

23

A00 A01 A02 A03

A10 A11 A12 A13

A20 A21 A22 A23

A30 A31 A32 A33

A B C

B00 B01 B02 B03

B10 B11 B12 B13

B20 B21 B22 B23

B30 B31 B32 B33

Page 24: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

24

A00 A01 A02 A03

A B C

Canon’s Algorithm

B00

B10

B20

B30

To compute C0,0 we need all sub-matrices A0,k and Bk,0 for 0<=k<√p

Page 25: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

25

A01 A02 A03 A00

A B C

Canon’s Algorithm

B10

B20

B30

B00

Shift left Shift up

Page 26: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

26

A02 A03 A00 A01

A B C

Canon’s Algorithm

B20

B30

B00

B10

Shift left Shift up

Page 27: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

27

A03 A00 A01 A02

A B

C00

C

Canon’s Algorithm

B30

B00

B10

B20

Shift left Shift up

Sequence of √p sub-matrix multiplications done.

Page 28: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

28

A00 A01 A02 A03

A10 A11 A12 A13

A20 A21 A22 A23

A30 A31 A32 A33

A B C

B00 B01 B02 B03

B10 B11 B12 B13

B20 B21 B22 B23

B30 B31 B32 B33

Page 29: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

29

A00 A01 A02 A03

A10 A11 A12 A13

A20 A21 A22 A23

A30 A31 A32 A33

A B C

B00 B01 B02 B03

B10 B11 B12 B13

B20 B21 B22 B23

B30 B31 B32 B33

A01 and B01 should not be multiplied!

Page 30: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

30

A00 A01 A02 A03

A10 A11 A12 A13

A20 A21 A22 A23

A30 A31 A32 A33

A B C

B00 B01 B02 B03

B10 B11 B12 B13

B20 B21 B22 B23

B30 B31 B32 B33

Some initial alignment required!

Page 31: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

31

A00 A01 A02 A03

A10 A11 A12 A13

A20 A21 A22 A23

A30 A31 A32 A33

A B C

B00 B01 B02 B03

B10 B11 B12 B13

B20 B21 B22 B23

B30 B31 B32 B33

Shift all sub-matrices Ai,j to the left (with wraparound) by i steps

Shift all sub-matrices Bi,j up (with wraparound) by j steps

After circular shift operations, Pij has submatrices Ai,

(j+i)mod√p and B(i+j)mod√p, j

Page 32: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

32

A00 A01 A02 A03

A11 A12 A13 A10

A22 A23 A20 A21

A33 A30 A31 A32

B00 B11 B22 B33

B10 B21 B32 B03

B20 B31 B02 B13

B30 B01 B12 B23

A B

After initial alignment:

Page 33: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

33

Topologies

Many computational science and engineering problems use a series of matrix or grid operations.

The dimensions of the matrices or grids are often determined by the physical problems.

Frequently in multiprocessing, these matrices or grids are partitioned, or domain-decomposed, so that each partition is assigned to a process.

Page 34: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

34

Topologies

MPI uses linear ordering and views processes in 1-D topology.

Although it is still possible to refer to each of the partitions by a linear rank number, a mapping of the linear process rank to a higher dimensional virtual rank numbering would facilitate a much clearer and natural computational representation.

Page 35: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

35

Topologies

To address the needs of this MPI library provides topology routines.

Interacting processes would be identified by coordinates in that topology.

Page 36: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

36

TopologiesEach MPI process would be mapped in

the higher dimensional topology.

Different ways to map a set of processes to a two-dimensionalgrid. (a) and (b) show a row- and column-wise mapping of these

processes, (c) shows a mapping that follows a space-filling curve

(dotted line), and (d) shows a mapping in which neighboringprocesses are directly connected in a hypercube.

Page 37: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

37

Topologies Ideally, mapping would be determined by

interaction among processes and connectivity of physical processors.

However, mechanism for assigning ranks to MPI does not use information about interconnection network.

Reason: Architecture independent advantages of MPI (otherwise different mappings would have to be specified for different interconnection networks)

Left to MPI library to find appropriate mapping that reduces cost of sending and receiving messages.

Page 38: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

38

MPI allows specification of virtual process topologies of in terms of a graph

Each node in graph corresponds to a process and edge exists between two nodes if they communicate with each other.

Most common topologies are Cartesian topologies (one, two or higher grids)

Page 39: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

39

Creating and Using Cartesian Topologies

We can create Cartesian topologies using the function:

int MPI_Cart_create( MPI_Comm comm_old, int ndims,

int *dims, int *periods, int reorder, MPI_Comm

*comm_cart)

Page 40: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

40

Page 41: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

41

Page 42: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

42

With processes renamed in a 2D grid topology, we are able to assign or distribute work, or distinguish among the processes by their grid topology rather than by theirlinear process ranks.

Page 43: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

43

MPI_CART_CREATE is a collective communication function. It must be called by all processes in the group.

Page 44: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

44

Creating and Using Cartesian Topologies Since sending and receiving messages still require (one-

dimensional) ranks, MPI provides routines to convert ranks to Cartesian coordinates and vice-versa.

int MPI_Cart_coord(MPI_Comm comm_cart, int rank, int maxdims, int *coords)

int MPI_Cart_rank(MPI_Comm comm_cart, int *coords, int *rank)

Page 45: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

45

Creating and Using Cartesian Topologies The most common operation on Cartesian topologies is a

shifting data along a dimension of the topology.

int MPI_Cart_shift(MPI_Comm comm_cart, int dir, int s_step, int *rank_source, int *rank_dest)

MPI_CART_SHIFT is used to find two "nearby" neighbors of the calling process along a specific direction of an N-dimensional Cartesian topology.

This direction is specified by the input argument, direction, to MPI_CART_SHIFT.

The two neighbors are called "source" and "destination" ranks.

Page 46: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

46

Page 47: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

47

Page 48: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

48

Page 49: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

49

Page 50: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

50

Page 51: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

51

Matrix Vector Multiplication (block distribution. Colors represent data distributed on different processes)

A b x

Page 52: 1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.

52

Matrix Vector Multiplication (Colors represent parts of b are required by each process)

A b x


Recommended