Tree Decomposition Maren Kaluza HELMHOLTZ CENTRE FOR - - PowerPoint PPT Presentation

tree decomposition
SMART_READER_LITE
LIVE PREVIEW

Tree Decomposition Maren Kaluza HELMHOLTZ CENTRE FOR - - PowerPoint PPT Presentation

Tree Decomposition Maren Kaluza HELMHOLTZ CENTRE FOR ENVIRONMENTAL November 2018 RESEARCH - UFZ UFZ Table Of Contents Introduction Parallelization Graphs, Trees rivernetwork (Hydrology) Tree Decomposition Goal Tree Data Structure Cut


slide-1
SLIDE 1

HELMHOLTZ CENTRE FOR ENVIRONMENTAL RESEARCH - UFZ

Tree Decomposition

Maren Kaluza November 2018

slide-2
SLIDE 2

UFZ

slide-3
SLIDE 3

Table Of Contents

Introduction Parallelization Graphs, Trees rivernetwork (Hydrology) Tree Decomposition Goal Tree Data Structure Cut Of A Subtree Tree Decomposition The Subtree Data Structure MPI Data Exchange Between Computing Nodes OpenMP

slide-4
SLIDE 4

Introduction

UFZ

slide-5
SLIDE 5

Parallelization

Distribution of calculations onto multiple computational units, so parts of the calculations can be done simultaneously.

UFZ

slide-6
SLIDE 6

Parallelization

Distribution of calculations onto multiple computational units, so parts of the calculations can be done simultaneously. 1 2 3 5 8 13 1 2 3 5 8 13 + 1 2 3 5 8 13 1 2 3 5 8 13 +

UFZ

slide-7
SLIDE 7

Parallelization

Distribution of calculations onto multiple computational units, so parts of the calculations can be done simultaneously. 1 2 3 5 8 13 1 2 3 5 8 13 + 14 1 2 3 5 8 13 1 2 3 5 8 13 + 14

UFZ

slide-8
SLIDE 8

Parallelization

Distribution of calculations onto multiple computational units, so parts of the calculations can be done simultaneously. 1 2 3 5 8 13 1 2 3 5 8 13 + 14 10 1 2 3 5 8 13 1 2 3 5 8 13 + 14 10

UFZ

slide-9
SLIDE 9

Parallelization

Distribution of calculations onto multiple computational units, so parts of the calculations can be done simultaneously. 1 2 3 5 8 13 1 2 3 5 8 13 + 14 10 8 1 2 3 5 8 13 1 2 3 5 8 13 + 14 10 8

UFZ

slide-10
SLIDE 10

Parallelization

Distribution of calculations onto multiple computational units, so parts of the calculations can be done simultaneously. 1 2 3 5 8 13 1 2 3 5 8 13 + 14 10 8 8 1 2 3 5 8 13 1 2 3 5 8 13 + 14 10 8 8

UFZ

slide-11
SLIDE 11

Parallelization

Distribution of calculations onto multiple computational units, so parts of the calculations can be done simultaneously. 1 2 3 5 8 13 1 2 3 5 8 13 + 14 10 8 8 10 1 2 3 5 8 13 1 2 3 5 8 13 + 14 10 8 8 10

UFZ

slide-12
SLIDE 12

Parallelization

Distribution of calculations onto multiple computational units, so parts of the calculations can be done simultaneously. 1 2 3 5 8 13 1 2 3 5 8 13 + 14 10 8 8 10 14 1 2 3 5 8 13 1 2 3 5 8 13 + 14 10 8 8 10 14

UFZ

slide-13
SLIDE 13

Parallelization

Distribution of calculations onto multiple computational units, so parts of the calculations can be done simultaneously. 1 2 3 5 8 13 1 2 3 5 8 13 + 1 2 3 5 8 13 1 2 3 5 8 13 +

UFZ

slide-14
SLIDE 14

Parallelization

Distribution of calculations onto multiple computational units, so parts of the calculations can be done simultaneously. 1 2 3 5 8 13 1 2 3 5 8 13 + 1 2 3 5 8 13 1 2 3 5 8 13 + 14 8 10

UFZ

slide-15
SLIDE 15

Parallelization

Distribution of calculations onto multiple computational units, so parts of the calculations can be done simultaneously. 1 2 3 5 8 13 1 2 3 5 8 13 + 1 2 3 5 8 13 1 2 3 5 8 13 + 14 10 8 8 10 14

UFZ

slide-16
SLIDE 16

Parallelization

Distribution of calculations onto multiple computational units, so parts of the calculations can be done simultaneously. 1 2 3 5 8 13 1 2 3 5 8 13 + 1 2 3 5 8 13 1 2 3 5 8 13 + 10 8 14 Profit: in the optimal case the new calculation time is the serial time by the number of computational units.

UFZ

slide-17
SLIDE 17

Parallelization

A cheese cake needs about 18 hours for baking. How much time is needed to bake the cheese cake with the same result if there where 6 ovens available?

UFZ

slide-18
SLIDE 18

Parallelization

1 2 3 5 8 13

UFZ

slide-19
SLIDE 19

Parallelization

Fibonacci sequene (shifted by 1) 1 2 3 5 8 13

UFZ

slide-20
SLIDE 20

Parallelization

Fibonacci sequene (shifted by 1) 1 2 3 5 8 13 21

UFZ

slide-21
SLIDE 21

Parallelization

Fibonacci sequene (shifted by 1) 1 2 3 5 8 13 21 34

UFZ

slide-22
SLIDE 22

Parallelization

Fibonacci sequene (shifted by 1) 1 2 3 5 8 13 21 34 +

UFZ

slide-23
SLIDE 23

Parallelization

Fibonacci sequene (shifted by 1) 1 2 3 5 8 13 21 34 + +

UFZ

slide-24
SLIDE 24

Parallelization

Fibonacci sequene (shifted by 1) 1 2 3 5 8 13 21 34 + + +

UFZ

slide-25
SLIDE 25

Parallelization

Pascal triangle

UFZ

slide-26
SLIDE 26

Parallelization

Pascal triangle 1 1 1 1 1 1 1 1 1 1 1

UFZ

slide-27
SLIDE 27

Parallelization

Pascal triangle 1 1 1 1 1 1 1 1 1 1 1 2 +

UFZ

slide-28
SLIDE 28

Parallelization

Pascal triangle 1 1 1 1 1 1 1 1 1 1 1 2 3 +

UFZ

slide-29
SLIDE 29

Parallelization

Pascal triangle 1 1 1 1 1 1 1 1 1 1 1 2 3 3 +

UFZ

slide-30
SLIDE 30

Parallelization

Pascal triangle 1 1 1 1 1 1 1 1 1 1 1 2 3 3

UFZ

slide-31
SLIDE 31

Parallelization

Pascal triangle 1 1 1 1 1 1 1 1 1 1 1 2 3 3

UFZ

slide-32
SLIDE 32

Parallelization

Pascal triangle 1 1 1 1 1 1 1 1 1 1 1 2 3 3

UFZ

slide-33
SLIDE 33

Parallelization

Pascal triangle 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 3 3 3 3

UFZ

slide-34
SLIDE 34

Parallelization

Pascal triangle 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 3 3 3 3 4 + 4 +

UFZ

slide-35
SLIDE 35

Parallelization

Pascal triangle 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 3 3 3 3 4 4 6 +

UFZ

slide-36
SLIDE 36

Parallelization

Pascal triangle 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 3 3 3 3 4 4 6 4 send/share

UFZ

slide-37
SLIDE 37

Parallelization

Pascal triangle 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 3 3 3 3 4 4 6 4

UFZ

slide-38
SLIDE 38

Graphs

1 vertex graph

UFZ

slide-39
SLIDE 39

Graphs

1 2 edge Graph

UFZ

slide-40
SLIDE 40

Graphs

1 2 3 4 5 6 Cycle (nevertheless a graph)

UFZ

slide-41
SLIDE 41

Graphs

1 2 3 4 5 6 7 8 no cycle, but a connected graph

UFZ

slide-42
SLIDE 42

Graphs

1 2 3 4 5 6 7 8 9 an unconnected graph

UFZ

slide-43
SLIDE 43

Trees

A tree is acyclic connected graph

UFZ

slide-44
SLIDE 44

Trees

A tree is acyclic connected graph 2 3 4 5 6 7 8

UFZ

slide-45
SLIDE 45

Trees

A tree is acyclic connected graph 2 3 4 5 6 7 8 3

UFZ

slide-46
SLIDE 46

Trees

A tree is acyclic connected graph 3 2 4 5 6 7 8

UFZ

slide-47
SLIDE 47

Trees

A tree is acyclic connected graph 3 2 4 5 6 7 8

UFZ

slide-48
SLIDE 48

Trees

A tree is acyclic connected graph 3 2 4 5 6 7 8 gewurzelter Baum, Out-tree

UFZ

slide-49
SLIDE 49

Trees

A tree is acyclic connected graph 3 2 4 5 6 7 8 gewurzelter Baum, In-tree

UFZ

slide-50
SLIDE 50

rivernetwork (Hydrology)

UFZ

slide-51
SLIDE 51
slide-52
SLIDE 52
slide-53
SLIDE 53
slide-54
SLIDE 54
slide-55
SLIDE 55
slide-56
SLIDE 56
slide-57
SLIDE 57
slide-58
SLIDE 58
slide-59
SLIDE 59
slide-60
SLIDE 60
slide-61
SLIDE 61
slide-62
SLIDE 62
slide-63
SLIDE 63
slide-64
SLIDE 64

Tree Decomposition

UFZ

slide-65
SLIDE 65

Tree Decomposition

The idea is to decompose the tree into subtrees and distribute these onto computing nodes. the case of dynamic distribution of subtrees onto the nodes has been studied [Li et al., 2011] we discuss a static distribution

UFZ

slide-66
SLIDE 66

Tree Decomposition

Example: Testbasin

As test basin we use the Moselle with 34 cells.

UFZ

slide-67
SLIDE 67

Tree Decomposition

Example: Testbasin

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 As test basin we use the Moselle with 34 cells.

UFZ

slide-68
SLIDE 68

Tree Decomposition

Example: Testbasin

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 As test basin we use the Moselle with 34 cells.

UFZ

slide-69
SLIDE 69

Tree Decomposition

Goal

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 Cut of subtrees with nice sizes recursively and distribute them onto the computing nodes:

  • 1. choose a size range (lowBound)
  • 2. search the smallest subtree larger than

lowBound in the tree

  • 3. cut of that subtree, store it somewhere
  • 4. start from step 2
  • 5. schedule independend subtrees on

different nodes

  • 6. establish communication between nodes

as far as necessary

UFZ

slide-70
SLIDE 70

Tree Decomposition

Goal

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 example: lowBound= 3

UFZ

slide-71
SLIDE 71

Tree Decomposition

Goal

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 example: lowBound= 3

UFZ

slide-72
SLIDE 72

Tree Decomposition

Goal

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 example: lowBound= 3

UFZ

slide-73
SLIDE 73

Tree Decomposition

Goal

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34

example: lowBound= 3

UFZ

slide-74
SLIDE 74

Tree Decomposition

Goal

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34

1 2 3 5 6 4 7 8 9 10 11 example: lowBound= 3

UFZ

slide-75
SLIDE 75

Tree Decomposition

Goal

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34

1 2 3 5 6 4 7 8 9 10 11 example: lowBound= 3 timeslots process 1: 1 4 7 8 9 10 11 process 2: 2 5 process 3: 3 6

UFZ

slide-76
SLIDE 76

Tree Decomposition

Goal

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34

1 2 3 5 6 4 7 8 9 10 11 example: lowBound= 3 timeslots process 1: 1 4 7 8 9 10 11 process 2: 2 5 process 3: 3 6 This is the shortest schedule, we can get with this subtrees: The tree depth is 7, we can not have a schedule shorter than the tree depth

UFZ

slide-77
SLIDE 77

Tree Decomposition

Tree data structure: basic info

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 A classical tree data structure contains: post: a pointer to the parent tree node Nprae: the number of children prae: an array of pointers to the children (note: each node is also a tree)

UFZ

slide-78
SLIDE 78

Tree Decomposition

Tree data structure: specific for tree decomposition

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 Specific data for the tree decomposition siz: the size of the tree sizUp: the size of the smallest subtree larger than lowBound ST: a pointer to metadata, if the tree node is the root node of a subtree

UFZ

slide-79
SLIDE 79

Tree Decomposition

Tree data structure: derived type

type ptrTreeNode type(treeNode), pointer :: tN end type ptrTreeNode type treeNode type(ptrTreeNode) :: post integer(i4) :: Nprae type(ptrTreeNode),dimension(:),allocatable :: prae integer(i4) :: siz integer(i4) :: sizUp type(subtreeNode), pointer :: ST end type treeNode

UFZ

slide-80
SLIDE 80

Tree Decomposition

Tree data structure: Set siz for each node

34 1 32 33 25 23 1 19 2 1 13 2 1 10 5 1 4 5 2 1 2 1 3 2 1 3 2 1 3 2 1 3 2 1 initialize siz with 1 for each tree node run though tree in routing order for each tree node:

◮ for all its children add the value of siz of each child to own value of siz

UFZ

slide-81
SLIDE 81

Tree Decomposition

Tree data structure: Set sizUp for each node

2 1 3 3 3 3 1 3 1 1 3 1 1 3 3 2 3 5 1 1 1 1 3 1 1 3 1 1 3 1 1 3 1 1 initialize sizeUp with 1 for each tree node run though tree in routing order for each tree node:

◮ for all its children check, if sizUp has already been set for at least one child ◮ if so, set sizUp of current tree node to the smallest of that values of its children ◮ if not, check if siz≥sizUp ◮ if so, set sizUp=siz ◮ else sizUp=1 (this has to be set, so the subroutine can update the tree after a subtree gets cut of)

UFZ

slide-82
SLIDE 82

Tree Decomposition

Cut Of A Subtree

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 cut of a subtree in sublinear time (depth of tree) Main idea, follow the branch with the smallest subtree (find_branch) [Thomas H. Cormen, 2009, Harder, 2018] start as root:

  • 1. if one of the children of the current tree

node has sizUp> 1

  • 2. then switch to the child with the smallest

value for sizUp, go to step 1

  • 3. else cut of subtree at that node

UFZ

slide-83
SLIDE 83

Tree Decomposition

Cut Of A Subtree

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 2 find_branch example:

  • 1. tree node 2 has one child 6
  • 2. 6 has sizUp> 1 therefore we move to 6

UFZ

slide-84
SLIDE 84

Tree Decomposition

Cut Of A Subtree

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 6 find_branch example:

  • 1. tree node 6 has one child 5
  • 2. 5 has sizUp> 1 therefore we move to 5

UFZ

slide-85
SLIDE 85

Tree Decomposition

Cut Of A Subtree

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 5 find_branch example:

  • 1. tree node 5 has three childen 1, 4, 9
  • 2. 1 has sizUp=1 (means not set), 4 has

sizUp= 5, 9 has sizUp= 3, therefore we move to 9

UFZ

slide-86
SLIDE 86

Tree Decomposition

Cut Of A Subtree

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 9 find_branch example:

  • 1. tree node 9 has two childen 10, 12
  • 2. 10 has sizUp=1 (means not set), 12 has

sizUp= 3, therefore we move to 12

UFZ

slide-87
SLIDE 87

Tree Decomposition

Cut Of A Subtree

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 12 find_branch example:

  • 1. tree node 12 has two childen 13, 17
  • 2. 13 and 17 both have sizUp= 3, therefore

we move to 13

UFZ

slide-88
SLIDE 88

Tree Decomposition

Cut Of A Subtree

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 13 find_branch example:

  • 1. tree node 13 has one child 14
  • 2. sizUp values of all children of 13 are

unset, therefore we cut of 13

UFZ

slide-89
SLIDE 89

Tree Decomposition

Cut Of A Subtree

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 13 cut of a subtree return a pointer to the subtree root (13) update_sizes initiate_subtreetreenode in the parent node:

◮ switch the cut of child with the last child in the prae array ◮ reduce Nprae by one

update_tree

UFZ

slide-90
SLIDE 90

Tree Decomposition

Cut Of A Subtree

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 13 update_sizes: for the cut of subtree (13) with size redSize (3)

  • 1. if not root, move to parent
  • 2. reduce siz of curret node by redSiz, go

to 1

UFZ

slide-91
SLIDE 91

Tree Decomposition

Cut Of A Subtree

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 13 initiate_subtreetreenode: associate and allocate pointer ST of tree node set size of subtreetreenode to current size

  • f tree node (after updating the tree

structure, it is the correct size of the subtree) initialize other meta data with 0 and nullpointers

UFZ

slide-92
SLIDE 92

Tree Decomposition

Cut Of A Subtree

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 13 update_tree: start at cut of tree node

  • 1. update sizUp (as it was done before)
  • 2. if not root, go to parent, go to step 1

UFZ

slide-93
SLIDE 93

Tree Decomposition

Cut Of A Subtree

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34 13 Special cases in the procesess of cutting of subtrees: root has no parent to be updated, so it has to be handled separately if one of its children has sizeUp> 1, follow branch as usual else, cut of root

UFZ

slide-94
SLIDE 94

Tree Decomposition

Tree Decomposition

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34

4 3 2 1 9 5 6 7 8 10 11 decompose as long as the last cut of subtree is not root

◮ find and cut of subtree, return pointer to subtree ◮ write pointer into an array

UFZ

slide-95
SLIDE 95

Tree Decomposition

Tree Decomposition

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34

4 3 2 1 9 5 6 7 8 10 11 decompose as long as the last cut of subtree is not root

◮ find and cut of subtree, return pointer to subtree ◮ write pointer into an array

set metadata of subtree nodes appropriately (set pointer to parents and children)

UFZ

slide-96
SLIDE 96

Tree Decomposition

The Subtree Data Structure

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34

4 3 2 1 9 5 6 7 8 10 11 each subtreetree node has an associated pointer to derived type subtreeNode with classical tree data structure... postST: a pointer to the parent tree node (points to tree node) NpraeST: number of (subtreetree) children praeST: array of pointers to the (subtreetree) children

UFZ

slide-97
SLIDE 97

Tree Decomposition

The Subtree Data Structure

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34

4 3 2 1 9 5 6 7 8 10 11 ...and specific information for scheduling levelST: an array saving the distance to the root node and the distance to the farthest leaf in the subtreetree structure for scheduling purposes

UFZ

slide-98
SLIDE 98

Tree Decomposition

Tree data structure: derived type

type treeNode ... (s.o.) type(subtreeNode), pointer :: ST end type treeNode type subtreeNode type(ptrTreeNode) :: postST integer(i4) :: NpraeST type(ptrTreeNode),dimension(:),allocatable :: praeST integer(i4) :: sizST integer(i4), dimension(2) :: levelST end type subtreeNode

UFZ

slide-99
SLIDE 99

Tree Decomposition

Tree decomposition: scheduling

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34

4 3 2 1 9 5 6 7 8 10 11 difference between two scheduling methods: round robin timeslots process 1: 1 4 7 10 process 2: 2 5 8 11 process 3: 3 6 9

UFZ

slide-100
SLIDE 100

Tree Decomposition

Tree decomposition: scheduling

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34

1 2 3 5 6 4 7 8 9 10 11 difference between two scheduling methods: Hu’s algorithm[Hu, 1961, Cheng and Sin, 1990] timeslots process 1: 1 4 7 8 9 10 11 process 2: 2 5 process 3: 3 6

UFZ

slide-101
SLIDE 101

MPI

UFZ

slide-102
SLIDE 102

MPI

MPI

n processes run the program each process knows its own rank and the number of processes in our case, process with rank 0 is the master process and cooridnates each process has its own memory, data has to be exchanged via message sending interface (MPI)

UFZ

slide-103
SLIDE 103

Tree Decomposition

Data Exchange Between Computing Nodes: Another Data Structure

2 1 5 6 9 12 10 17 16 21 22 26 30 23 24 25 27 4 3 7 8 11 13 14 15 18 19 20 28 29 33 31 32 34

1 2 3 5 6 4 7 8 9 10 11 tree data structures mainly constist of pointers that refer to physical memory

  • adresses. Sending this data across nodes does

not help. Solution: save the inices of the grid cells into an array in routing order, where the subtrees lay together save a toNode array for the links/edges

UFZ

slide-104
SLIDE 104

MPI

basic structure

if process has rank 0: decompose tree prepare array in routing order and toNode array send subarrays and corresponding toNodes to the other processes send indices of leaves which are connected to subtree roots to processes

◮ collect data from root nodes of the subtrees and send it to corresponding leaf nodes of adjacent subtree

in the end: recollect subarrays else: receive subarray, toNodes, and node indices of corresponding subtrees

◮ collect input data for some leaves ◮ do routing ◮ send root output data to master

in the end: send subarray back

UFZ

slide-105
SLIDE 105

MPI

Does It Work?

No, not that easily. Communication needs more time than routing through arrays of size 10000. A representative basin, Donau, has 26507 cells. Ideas: do routing several times in a subtree, send array of data instead of one value

  • r parallelize only independent trees with MPI

We are lucky: the first idea works

UFZ

slide-106
SLIDE 106

MPI

Times

30 60 90 120 150 180 5 10 15 20 Size of subtrees [-] Time [s] 3 5 7 9 11 13 15 17 19 21 the basin tested, is the donau with 26507 cells collect arrays of 1000 data points before sending time is measured every 1000 steps (so 1000×1000 routing per time measurement)

UFZ

slide-107
SLIDE 107

MPI

Times

30 60 90 120 150 180 5 10 15 20 Size of subtrees [-] Time [s] 3 5 7 9 11 13 15 17 19 21 cutting into subtrees with sizes smaller than 50 results in communication

  • verhead, means

communication between the nodes takes more time than routing 1000 times through a subtree

UFZ

slide-108
SLIDE 108

MPI

Times

1 5 9 13 17 21 4 8 12 16 Number of Processes p [-]

  • Proc. Time Tp [s]

for each number of procsesses the y-value is the minimum of the curves above more processors still make it faster but it does not tend to zero

UFZ

slide-109
SLIDE 109

OpenMP

UFZ

slide-110
SLIDE 110

OpenMP

differences to MPI

arrays are not send over the network, but exchanged via shared memory

◮ we have to handle data race problems

sorting of subtrees to threads is not done by us but dynamically:

◮ the routing through a subtree is assigned to a task ◮ a waiting CPU gets a task/subtree when available

UFZ

slide-111
SLIDE 111

OpenMP

some code

!$OMP parallel private(rank) shared(testarray) !$OMP single call routing(root,testarray) !$OMP end single !$OMP barrier !$OMP end parallel

UFZ

slide-112
SLIDE 112

recursive subroutine routing(root,array) ... do jj=1,root%tN%Nprae !$OMP task shared(root,array) call routing(root%tN%ST%prae(jj),array) !$OMP end task end do !$OMP taskwait if (associated(root%tN%post%tN)) then tNode=root%tN%post%tN%ind !$OMP critical array(tNode)=array(tNode)+array(root%tN%ind) !$OMP end critical end if end subroutine routing

slide-113
SLIDE 113

OpenMP

Times

30 60 90 120 150 180 10 20 30 40 50 Size of subtrees [-] Time [s] the basin tested, is again the donau with > 22000 cells collect arrays of 1000 data points before writing into shared array time is measured every 1000 steps (so 1000×1000 routing per time measurement)

UFZ

slide-114
SLIDE 114

OpenMP

Times

1 5 9 13 17 21 10 20 30 Number of Processes p [-]

  • Proc. Time Tp [s]

OpenMP MPI for each number of processes the y-value is the minimum over lowBound

UFZ

slide-115
SLIDE 115

OpenMP

Times, reasons MPI is faster

code with OpenMP tasks compiles poorly with gnu, intel is better Tasks are not sorted by priority. The tree is not a binary tree and it is

  • unbalanced. (Approach: Use newer version of OpenMP, currently reading

more literature)

UFZ

slide-116
SLIDE 116

OpenMP

Times, compiled with Intel

30 60 90 120 150 180 5 10 15 20 Size of subtrees [-] Time [s] the basin tested, is again the donau with > 22000 cells collect arrays of 1000 data points before writing into shared array time is measured every 1000 steps (so 1000×1000 routing per time measurement)

UFZ

slide-117
SLIDE 117

OpenMP

Times

1 5 9 13 17 21 4 8 12 16 20 24 28 32 Number of Processes p [-]

  • Proc. Time Tp [s]

OpenMP OpenMP with intel MPI for each number of processes the y-value is the minimum over lowBound

UFZ

slide-118
SLIDE 118

OpenMP

Times

1 5 9 13 17 21 1 2 3 4 5 6 Number of Processes p [-] Speedup T1

Tp [-]

OpenMP with intel MPI Speedup is the sequentual time devided by the processing time with p processors T1

Tp .

Best case szenario is T1

Tp = p

We will never reach this because

  • f the lower bound given by the

tree depth

UFZ

slide-119
SLIDE 119

Cheng, T. and Sin, C. (1990). A state-of-the-art review of parallel-machine scheduling research. European Journal of Operational Research, 47(3):271–292. Harder, J. (2018). Discussions. Hu, T. C. (1961). Parallel sequencing and assembly line problems. Operations research, 9(6):841–848. Li, T., Wang, G., Chen, J., and Wang, H. (2011). Dynamic parallelization of hydrological model simulations. Environmental Modelling & Software, 26(12):1736–1746. Thomas H. Cormen, Charles E. Leiserson, R. L. R. C. S. (2009). Introduction to Algorithms. MIT Press, 3rd edition.

UFZ