25 Parallel Part 3

# 25 Parallel Part 3 - Parallel Algorithms, Part 3 15-211:...

This preview shows pages 1–12. Sign up to view the full content.

Parallel Algorithms, Part 3 15-211: Fundamental Data Structures and Algorithms Margaret Reid-Miller 22 April 2010

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 Announcements HW6 Theory, due Tuesday 27 in class Quiz 7: Wednesday, 28 April in recitation HW6 Chess, due Wednesday Final Exam Review Session: WH 7500 Sunday, May 2, 2:00-4:00 pm Final Exam: UC McConomy Tuesday, May 4, 1:00-4:00 pm
Parallel algorithm design Techniques: D&C Contraction Randomization Symmetry breaking Short-cutting Oversampling 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 Linked Lists Linked lists seem inherently sequential: Start at the head of the list and work your way down the list. How can we use linked lists in parallel? We need a way to access different parts of the list simultaneously. Therefore, we assume that the list, (or trees and graphs) are mapped from or stored in contiguous memory. They do not need to be in order.
Pointer sequence Each element is a pointer to another element in the sequence. Eg, [1, 6, 2, 6, 2, 1, 6, 2, 5] 2 trees Eg, [1, 6, 5, 2, 0, 7, 4, 8, 3] 2 cycles 5 0 1 2 3 4 5 6 7 8

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 Parallel Technique: Pointer Jumping An important technique for computing over all the nodes in a pointer-based object quickly is pointer jumping . For example, label all the nodes in a list with a value assigned at the last node. The basic operation is simple: Replace pointer P[i] at node i with its parent pointer P[P[i]]. Often, the tail of the list or root of a tree is a represented as a self loop, so pointer jumping has no effect.
Two rounds of pointer jumping on a list. 7 Pointer Jumping (aka short cutting) After log n rounds every node points to the end of the list

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
8 Pointer Jumping PointToRoot( P ) for (j=0; j < ceil(log 2 |P|); j++) for (i in 0. .|P| in parallel) P[i] = P[P[i]] W(n) = D(n) = Is it work-efficient? O(n log n) O(log n) No
Cycle detection After calling jumpToRoot, what do trees(lists) vs cycles look like? detectCycle( P ) hasCycle = false jumpToRoot( P ) for (i in 1. .|X| in parallel) if (P[i] != i && !root P[P[i]] != P[i]) !child of root hasCycle = true return hasCycle 9

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
10 List Ranking Suffix sums problem is similar to prefix sum but from the other direction s[i] = a i a i+1 a i+2 a n-1 List ranking is the same problem but on values of the nodes a linked list. The name List Ranking refers to the special case where the values are all 1 except the last which has value 0. The suffix sum is the rank of each node; its distance to the end of the linked list.
11 List Ranking Applications As with prefix sum, list ranking has many similar applications. Also, used to convert a linked list to an

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This document was uploaded on 05/10/2011.

### Page1 / 41

25 Parallel Part 3 - Parallel Algorithms, Part 3 15-211:...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online