15
Parallelizing Edmonds’ Blossom Algorithm Eric Chang and Rutwik Parikh

Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

Embed Size (px)

Citation preview

Page 1: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

Parallelizing Edmonds’ Blossom

AlgorithmEric Chang and Rutwik Parikh

Page 2: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge.

Maximal Matching Problem

No blue edges share a vertex, so they form a matching. This matching happens to be maximal.

Page 3: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

An alternating path P is a set of edges from an exposed vertex to another exposed vertex where every other edge is in the matching, M. Augmenting a path exchanges membership of P in M, increasing the size of the matching by one edge.

Augmenting Paths

Page 4: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

A blossom is an odd-length cycle of vertices with alternating edges. A contracted blossom acts exactly as a node.

Blossom Contraction

Page 5: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

1. Begin with an edge-less forest of only exposed vertices which act as the roots of trees that we build.

2. Add matched edge (pairs of vertices) until we connect two trees.

3. If a blossom is found (connection from tree to itself), we contract the blossom and continue adding matched edges.

4. When an alternating path is found (completing one iteration step), we augment it and begin from Step 1.

5. If no more alternating paths exist, we have found a maximal matching in the graph.

Edmonds’ Blossom Algorithm

Page 6: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

Summary of Algorithm

We conclude each iteration step when an augmenting path is found.

Graph is permanently shrunk whenever we discover a blossom.

Forest must be reconstructed for every iteration step.

Page 7: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

We used OpenMP on a Gates 3000 cluster machine to obtain a parallel solution using shared memory.

These machines use 6 physical cores with hyper-threading.

Our Parallel Approach

Page 8: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

Our solution involves simply parallelizing over the vertices during forest construction in every step using dynamic scheduling.

In order to maintain correctness as we modify the forest by adding edges and contracting blossoms, we assign each vertex a lock.

Our Parallel Approach

Page 9: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

When a matched edge is added to the graph, the lock of the lower-numbered node is required.

If Thread 0 wins node 8’s lock, edge 4-8 is added.

If Thread 1 wins node 8’s lock, edge 5-13 is added.

Locking – Adding Matched Edges

Page 10: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

We first acquire all locks in the blossom/path, then check if it is still valid, and release locks as we modify the nodes. Below is an example of deadlock.

Thread 0 holds node 4’s lock and tries to get node 8’s lock.

Thread 1 holds node 8’s lock and tries to get node 4’s lock.

Locking – Blossoms and Paths

Page 11: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

If there is a conflict when acquiring locks, the higher thread number stalls while the lower thread number aborts.

Thread 0 relinquishes all locks in its partial blossom.

Thread 1 finishes acquiring all nodes of the alternating path.

Locking – Blossoms and Paths

Page 12: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge
Page 13: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

Explanation of Results

Contention vs. Locality◦ Many “for” loops make simple padding

ineffective.◦ Shared cache in hyperthreading.

Stragglers◦ Iteration loops conclude when an alternating

path is found.◦ Other threads continue to finish what they’re

working on. Blossom/Path Invalidation

◦ Occurs while waiting for lock acquisition.◦ Wasted work.

Page 14: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

Institute of Mathematical Sciences:http://www.imsc.res.in/~meena/matching/edmonds.pdf

Lucidchart:https://www.lucidchart.com/

Wikipedia:http://en.wikipedia.org/wiki/Edmonds%27s_matching_algorithm

Wolfram|Alpha:http://demonstrations.wolfram.com/TheBlossomAlgorithmForMaximumMatching/

Resources

Page 15: Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge

Thank You!