A parallel pebble game with applications to expression evaluation Lecture 11.
-
Upload
adrian-robertson -
Category
Documents
-
view
213 -
download
0
Transcript of A parallel pebble game with applications to expression evaluation Lecture 11.
![Page 1: A parallel pebble game with applications to expression evaluation Lecture 11.](https://reader035.fdocuments.net/reader035/viewer/2022072005/56649ccd5503460f949981da/html5/thumbnails/1.jpg)
A parallel pebble game with applications to expression evaluation
Lecture 11
![Page 2: A parallel pebble game with applications to expression evaluation Lecture 11.](https://reader035.fdocuments.net/reader035/viewer/2022072005/56649ccd5503460f949981da/html5/thumbnails/2.jpg)
Parallel pebble game on binary tree
Within the game each node v of the tree has associated with it similar node denoted by cond(v). At the outset of the game cond(v)=v, for all v During the game the pairs (v,cond(v)) can be thought of as additional edges
Node v is ”active” if and only if cond(v)v
![Page 3: A parallel pebble game with applications to expression evaluation Lecture 11.](https://reader035.fdocuments.net/reader035/viewer/2022072005/56649ccd5503460f949981da/html5/thumbnails/3.jpg)
Pebbling
Pebbling a node denotes the fact that in the current state of the game the processor associated with that node has sufficient information to evaluate the subtree rooted here
![Page 4: A parallel pebble game with applications to expression evaluation Lecture 11.](https://reader035.fdocuments.net/reader035/viewer/2022072005/56649ccd5503460f949981da/html5/thumbnails/4.jpg)
Three operationsactive, square and pebble
Activate for all non-leaf nodes v in parallel do
if v is not active and precisely one of its sons is pebbled thencond(v) becomes the other son
if v is not active and both sons are pebbled thencond(v) becomes one of the sons arbitrarily
Square
for all nodes v in parallel do cond(v) cond(cond(v)) Pebble for all nodes v in parallel do
if cond(v) is pebbled then pebble v
![Page 5: A parallel pebble game with applications to expression evaluation Lecture 11.](https://reader035.fdocuments.net/reader035/viewer/2022072005/56649ccd5503460f949981da/html5/thumbnails/5.jpg)
Key result
At the outset of the game only the leaves of the tree are pebbled. One composite move of the pebbling game is the sequence of individual operations
(activate, square, square, pebble)Theorem
Let T be a binary tree with n leaves. If initially only the leaves are pebbled then after log2n moves of the pebbling game the root of T becomes pebbled.
![Page 6: A parallel pebble game with applications to expression evaluation Lecture 11.](https://reader035.fdocuments.net/reader035/viewer/2022072005/56649ccd5503460f949981da/html5/thumbnails/6.jpg)
Example
activate
square
square pebbling
![Page 7: A parallel pebble game with applications to expression evaluation Lecture 11.](https://reader035.fdocuments.net/reader035/viewer/2022072005/56649ccd5503460f949981da/html5/thumbnails/7.jpg)
The application of the pebbling game
Consider the arithmetic expression ((3+(2*2))*3+5)We assign a processor to each non-leaf node of the tree.+
5*
+
3*
2 2
3
![Page 8: A parallel pebble game with applications to expression evaluation Lecture 11.](https://reader035.fdocuments.net/reader035/viewer/2022072005/56649ccd5503460f949981da/html5/thumbnails/8.jpg)
+
5*
+
3*
2 2
3
+
5*
+
3*
2 2
3
+
5*
+
3*
2 2
3
+
5*
+
3*
2 2
3
X*2
X+3
X*3X+5
3x+5
3x+92x+
3
2x
3(2x+3)+53(2x)+9
2x+3
2x
![Page 9: A parallel pebble game with applications to expression evaluation Lecture 11.](https://reader035.fdocuments.net/reader035/viewer/2022072005/56649ccd5503460f949981da/html5/thumbnails/9.jpg)
Evaluation of arithmetic expressions
Arithmetic expressions can be evaluated on a PRAM in O(log n) time using O(n) processors.