Distributed VS Parallel implementations of graph algorithms Alexis - - PowerPoint PPT Presentation

distributed vs parallel implementations of graph
SMART_READER_LITE
LIVE PREVIEW

Distributed VS Parallel implementations of graph algorithms Alexis - - PowerPoint PPT Presentation

Distributed VS Parallel implementations of graph algorithms Alexis SIRETA,Lazar PETROV Outline About graph computing What is a graph ? edge A graph is a set of nodes connected to each other by edges node What kind of graphs ? Edges can


slide-1
SLIDE 1

Distributed VS Parallel implementations of graph algorithms

Alexis SIRETA,Lazar PETROV

slide-2
SLIDE 2

Outline

slide-3
SLIDE 3

About graph computing

slide-4
SLIDE 4

What is a graph ?

A graph is a set of nodes connected to each other by edges node edge

slide-5
SLIDE 5

What kind of graphs ?

Edges can be : Directed Undirected 5 5 Unweighted weighted

slide-6
SLIDE 6

Connected graph

A connected graph is a graph in which there is a path between every pair of nodes

slide-7
SLIDE 7

How to represent a graph ?

Adjacency matrix Node1 Node2 Node3 1 2 3 0 7 9 7 0 8 9 8 0 9 1 2 3 7 8

slide-8
SLIDE 8

How to represent a graph ?

Edge list Nodea Nodeb W Node1 Node2 7 Node1 Node3 9 Node2 Node3 8 Node2 Node1 7 Node3 Node1 9 Node3 Node2 8 9 1 2 7 8 3

slide-9
SLIDE 9

What are graphs used for ?

Data representation of a wide range problems : Finding shortest path from A to B Representing database Find related topics ...and plenty more !

slide-10
SLIDE 10

Problem !

Graphs are getting VERY big : Example : Directed network of hyper links between the articles of the Chinese online encyclopedia Baidu. 17 643 697 edges

source : http://konect.uni-koblenz.de/networks/zhishi-baidu-internallink

slide-11
SLIDE 11

Solution !

Use Parallel or Distributed systems

slide-12
SLIDE 12

Distributed and Parallel systems

slide-13
SLIDE 13

Parallel System

cache cache cache Main memory

slide-14
SLIDE 14

Distributed System

cache Main memory cache Main memory cache Main memory Network

slide-15
SLIDE 15

Our Research Project

slide-16
SLIDE 16

Goal and Questions

Compare the performances of parallel and distributed implementations of a graph algorithm Questions: Can we really compare algorithms running on difgerent architectures ? How do the algorithms scale ? How do they adapt to other architectures ?

slide-17
SLIDE 17

Hypothesis

Hypothesis: Distributed will run slower than parallel for small graphs because of communication latency but will run faster for big graphs because of memory access time

slide-18
SLIDE 18

Procedure

Choose two implementations of one graph algorithm Build a theoretical model of the execution time Run the algorithms on the Uva cluster Explain the results and adapt the theoretical model if needed

slide-19
SLIDE 19

Minimum Spanning Tree

slide-20
SLIDE 20

What is it ?

9 1 2 7 8 3 4 1 3 4 1 3 2 1 3 7 Is relevant for connected undirected graphs

slide-21
SLIDE 21

Which algorithm choose ?

Several classical algorithms : Prim, Kruskal, Boruvka Boruvka : This is the most used for parallel and distributed implementations, therefore this is the one we chose Parallel implementation : Bor-el, described in the paper “ Fast shared-memory algorithms for computing the minimum spanning forest of sparse graphs” by David A. Bader and Guojing Cong Distributed implementation : GHS, described in “A distributed algorithm for minimum weight spanning trees” by R. G. Gallager, P. A. Humblet and P. M. Spira

slide-22
SLIDE 22

Sequential algorithm

slide-23
SLIDE 23

Example Graph

A B D F E C G 7 11 5 10 9 4 6 15 8 12 13

slide-24
SLIDE 24

Initialize components

A B D F E C G 7 11 5 10 9 4 6 15 8 12 13

slide-25
SLIDE 25

Finding MWOE

A B D F E C G 7 11 5 10 9 4 6 15 8 12 13

slide-26
SLIDE 26

Creating new components

A B D F E C G 7 11 5 10 9 4 6 15 8 12 13

slide-27
SLIDE 27

Finding MWOE

A B D F E C G 7 11 5 10 9 4 6 15 8 12 13

slide-28
SLIDE 28

Creating new component

A B D F E C G 7 11 5 10 9 4 6 15 8 12 13

slide-29
SLIDE 29

Here is the Minimum spanning tree

A B D F E C G 7 5 10 4 6 8

slide-30
SLIDE 30

Bor-el algorithm (Parallel)

slide-31
SLIDE 31

Example Graph

A B D F E C G 7 11 5 10 9 4 6 15 8 12 13

slide-32
SLIDE 32

Edge list representation

A B 7 A D 4 B A 7 B C 11 B D 9 B E 10 C B 11 C E 5 D A 4 D B 9 D E 15 D F 6 E B 10 E C 5 E D 15 E F 12 E G 8 F D 6 F E 12 F G 13 G E 8 G F 13 MST

slide-33
SLIDE 33

Select MWOE

A B 7 A D 4 B A 7 B C 11 B D 9 B E 10 C B 11 C E 5 D A 4 D B 9 D E 15 D F 6 E B 10 E C 5 E D 15 E F 12 E G 8 F D 6 F E 12 F G 13 G E 8 G F 13 A D 4 B A 7 C E 5 D A 4 E C 5 F D 6 MST

slide-34
SLIDE 34

These are the edges we selected

A B D F E C G 7 5 4 6 8

slide-35
SLIDE 35

These are the edges we selected

A B D F E C G 7 5 4 6 8 root C root

slide-36
SLIDE 36

Pointer jumping example

E D C B A E D C B A E D C B A

slide-37
SLIDE 37

Pointer jumping

A B D F E C G 7 5 4 6 8 C

slide-38
SLIDE 38

Pointer jumping

A B D F E C G 7 5 4 6 8 C

slide-39
SLIDE 39

Pointer jumping

A B D F E C G 7 5 4 6 8 C

slide-40
SLIDE 40

Create supervertex

A A A A C C C 7 5 4 6 8 C

slide-41
SLIDE 41

In the edge list

A B 7 A D 4 B A 7 B C 11 B D 9 B E 10 C B 11 C E 5 D A 4 D B 9 D E 15 D F 6 E B 10 E C 5 E D 15 E F 12 E G 8 F D 6 F E 12 F G 13 G E 8 G F 13 A D 4 B A 7 C E 5 D A 4 E C 5 F D 6 MST

slide-42
SLIDE 42

In the edge list

A A 7 A A 4 A A 7 A C 11 A A 9 A C 10 C A 11 C C 5 A A 4 A A 9 A C 15 A A 6 C A 10 C C 5 C A 15 C A 12 C C 8 A A 6 A C 12 A C 13 C C 8 C A 13 A D 4 B A 7 C E 5 D A 4 E C 5 F D 6 MST

slide-43
SLIDE 43

Compact

A C 11 A C 10 C A 11 A C 15 C A 10 C A 15 C A 12 A C 12 A C 13 C A 13 A D 4 B A 7 C E 5 D A 4 E C 5 F D 6 MST

slide-44
SLIDE 44

Find Mwoe

A C 11 A C 10 C A 11 A C 15 C A 10 C A 15 C A 12 A C 12 A C 13 C A 13 A D 4 B A 7 C E 5 D A 4 E C 5 F D 6 B E 10 MST

slide-45
SLIDE 45

Found Spanning tree

A D 4 B A 7 C E 5 D A 4 E C 5 F D 6 B E 10

slide-46
SLIDE 46

Theoretical analysis of Bor-el

slide-47
SLIDE 47

Size of graph in memory

2 times each edge 2 nodes id per edge Number of edges N : number of nodes log(N) size of one node in memory Number of processors Size of weights in memory

slide-48
SLIDE 48

Average number of edges

E decreases of at least N/2 each

  • iteration. Lets say E = kN
slide-49
SLIDE 49

Memory access time

cache1 Main memory cache2 cache1 cache1 cache2 cache2 1 CC 10 CC 100 CC

slide-50
SLIDE 50

Memory access time

Size of graph in memory Size of cache 1 Size of cache 2

slide-51
SLIDE 51

Memory access time

N CC 200

k=N s1=16 kb s2 = 4 Mb p=2

slide-52
SLIDE 52

Number of memory accesses

N C is an unknown constant : using their experimental results we fount it is around 3.21 Formula given by the paper on bor-el

slide-53
SLIDE 53

Computation complexity

N Formula given by the paper on bor-el

slide-54
SLIDE 54

Plot execution time

S

k=N s1=16 kb s2 = 4 Mb p=2-10

N

slide-55
SLIDE 55

Plot execution time

N p=2 p=10 N S

slide-56
SLIDE 56

Analysis

Plot does not vary with p because time highly dominated by memory access for very big graphs

slide-57
SLIDE 57

GHS algorithm (Distributed)

slide-58
SLIDE 58

Example graph

A B D F E C G 7 11 5 10 9 4 6 15 8 12 13

slide-59
SLIDE 59

State of each edge

Branch edges are those that have already been determined to be part of the MST. Rejected edges are those that have already been determined not to be part of the MST. Basic edges are neither branch edges nor rejected edges.

slide-60
SLIDE 60

State of each edge

Each processor stores: The state of any of its incident edges, which can be either of {basic, branch, reject} Identity of its fragment (the weigth of a core edge – for single-node fragments, the proc. id ) Local MWOE MWOE for each branching-out edge Parent channel (route towards the root) MWOE channel (route towards the MWOE of its appended subfragment)

slide-61
SLIDE 61

Type of messages

New fragment(identity): coordination message sent by the root at the end of a phase Test(identity): for checking the status of a basic edge Reject, Accept: response to Test Report(weight): for reporting to the parent node the MWOE of the appended subfragment Merge: sent by the root to the node incident to the MWOE to activate union of fragments Connect(My Id): sent by the node incident to the MWOE to perform the union

slide-62
SLIDE 62

Phase 0 : Every node is a fragment

A B D F E C G 7 11 5 10 9 4 6 15 8 12 13 ...And every node is the root of its fragment

slide-63
SLIDE 63

Phase 1 : Find MWOE

A B D F E C G 7 11 5 10 9 4 6 15 8 12 13

slide-64
SLIDE 64

Phase 1 : select new root

A B D F E C G 7 11 5 10 9 4 6 15 8 12 13

slide-65
SLIDE 65

Phase 1 : root broadcast new identity

4 4 4 4 5 5 5 7 11 5 10 9 4 6 15 8 12 13 new_fragment(4)

Phase 1 : root broadcast new identity

new_fragment(4) new_fragment(5) new_fragment(5)

slide-66
SLIDE 66

Phase 1 : Find MWOE

4 4 4 4 5 5 5 7 11 5 10 9 4 6 15 8 12 13 test accept reject test

slide-67
SLIDE 67

Phase 1 : Find MWOE

4 4 4 4 5 5 5 7 11 5 10 9 4 6 15 8 12 13

slide-68
SLIDE 68

Phase 1 : Report to root

4 4 4 4 5 5 5 7 11 5 10 9 4 6 15 8 12 13 10 12 12

slide-69
SLIDE 69

Phase 1 :Send connect

4 4 4 4 5 5 5 7 11 5 10 9 4 6 15 8 12 13

slide-70
SLIDE 70

Phase 1 :New root

4 4 4 4 5 5 5 7 11 5 10 9 4 6 15 8 12 13

slide-71
SLIDE 71

Phase 1 :Broadcast ID

5 5 5 5 5 5 5 7 11 5 10 9 4 6 15 8 12 13

slide-72
SLIDE 72

Phase 1 :MST !

5 5 5 5 5 5 5 7 11 5 10 9 4 6 15 8 12 13

slide-73
SLIDE 73

Theoretical analysis of GHS

slide-74
SLIDE 74

Theoretical execution time

(2E + 5N(log(N) -1) + 3N)/N Number of messages sent per node: Max size of messages sent: log(E)+log(8N) Speed of connection: 1 Gb/s

slide-75
SLIDE 75

Plot

slide-76
SLIDE 76

Analysis

Theoretically the distributed algorithm is ALWAYS way faster than the parallel one This is true with our hypothesis of a network without latencies and one host per node

slide-77
SLIDE 77

Experiments

slide-78
SLIDE 78

The Uva cluster

18 nodes with 16 cores each Max graph size = 82656 edges

slide-79
SLIDE 79

Ghs implementation : Python

Initially chose a python implementation : Did not run properly on the cluster Ran N times ( in parallel ) the whole algorithm

slide-80
SLIDE 80

Ghs implementation : C with MPI

Then chose a C implementation using MPI (Message Passing Interface) to communicate between processes Did not run the algorithm until the end

slide-81
SLIDE 81

Making it work

The C algorithm worked for a specifjc type of graphs 0 1 2 3 1 0 4 5 2 4 0 6 3 5 6 0

slide-82
SLIDE 82

Results

slide-83
SLIDE 83

Reasons for such difgerent results

Very badly written algorithm

Message queues Communication latency

slide-84
SLIDE 84

Check if algorithm does not send too many messages

Number of nodes

Theoretical value (msg sent) Experimental value (msg sent)

224 128 64 32 110410 37100 10250 2710 216712 56717 8200 1573

slide-85
SLIDE 85

Check if not a queuing problem

Number of nodes

Number of cores Time (s)

2 8 16 4 3.153 3.583

slide-86
SLIDE 86

Communication latency

Add a latency every time a process sends a message Theoretical latency needed : 0.1 s Empirical latency found : 0.025 s Don't forget that the implementation sends twice the theoretical amount of messages !

slide-87
SLIDE 87

Communication latency

Add a latency every time a process sends a message Theoretical latency needed : 0.1 s Empirical latency found (between two nodes) : 0.025 s Don't forget that the implementation sends twice the theoretical amount of messages !

slide-88
SLIDE 88

Communication latency

There is no latency if we run the algorithm on one node Possibly if we run the algorithm on a N core node we match the theoretical speed

slide-89
SLIDE 89

Further work

Investigate the other factors that caused the bad performance Investigate the best architectures to run the distributed algorithm

slide-90
SLIDE 90

Conclusion

Parallel algorithm way faster than the distributed one Causes of bad performances of GHS is communication latency caused by MPI and bad implementation of the algorithm Uva cluster is not optimized for algorithms that require a lot of communication Nevertheless it is possible to fjnd implementations and architectures that will make GHS outperform bor-el and this should be investigated