DECS: A Dynamic Elimination-Combining Stack Algorithm
description
Transcript of DECS: A Dynamic Elimination-Combining Stack Algorithm
![Page 1: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/1.jpg)
1
DECS: A Dynamic Elimination-
Combining Stack Algorithm
Gal Bar-Nissan,Danny Hendler,
Adi Suissa
OPODIS 2011
![Page 2: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/2.jpg)
2
Stack data-structureWe focus on the stack data-structure
which supports two operations:◦push(v) – adds a new element (with
value v) to the top of the stack◦pop – removes the top element from
the stack and returns it
![Page 3: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/3.jpg)
3
Previous work – IBM/Treiber algorithm [1986]
Linked-list basedShared top pointer
next
next
top
nextnew
old
top
new
top
push operation
pop operation
Non-blocking algorithm Poor scalability (essentially sequential)
![Page 4: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/4.jpg)
4
Previous work – Flat-combining [Hendler, Incze, Shavit, Tzafrir, 2010]
A list of operations to be performed
Each thread adds its operation to the listOne of the threads acquires a global lock
and performs the combined operationOther threads spin and wait for their
operation to be performed
push
pop push
push
pop push
Minimizes synchronization
Blocking algorithm Limited scalability (essentially sequential)
![Page 5: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/5.jpg)
5
Previous work – Elimination Backoff (HSY) [Hendler, Shavit, Yerushalmi, 2004]
Eliminating reverse semantics operations
A thread attempts its operation:1. On the central stack (IBM/Treiber algorithm)2. Elimination Backoff – Eliminate with another
threadT1
T2
T3
pop
push( )
pop
T1
Central Stack
Non-blocking algorithm Provides parallelism – if workloads are symmetric
![Page 6: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/6.jpg)
6
Our contributionsDECS – A Dynamic Elimination-
Combining Stack algorithm
Dynamically employs either of two techniques:1. Elimination2. Combining
A non-blocking version (NB-DECS)
![Page 7: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/7.jpg)
7
DECS – Dynamic Elimination-Combining StackEmploys IMB/Treiber’s algorithm as a
central stack
A thread attempts its operation:1. On the central stack2. Elimination-Combining Backoff – Eliminate or
Combine with another thread
![Page 8: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/8.jpg)
8
Elimination-Combining layer
A thread attempts its operation on the central
stack
1T1
Central Stack
op1
If that fails, it registers itself in a publication array
2
T1
It then chooses a random index from the publication array, and looks for another
thread
3
If no other thread is found, the thread waits
![Page 9: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/9.jpg)
9
Elimination-Combining layer (cont'd)
4T2
Central Stack
op2
T1 T2
If it finds another thread with a reverse semantics
operation, the operations are eliminated
5
op1 != op2
Another thread that fails operating on the central
stack also registers in the array and tries to find
Another thread
![Page 10: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/10.jpg)
10
If both threads have identical operation
semantics, one thread delegates its operation to
the other thread
6T2
Central Stack
op2
T1 T2
op1 == op2
T1
Elimination-Combining layer (cont'd)
delegate thread
![Page 11: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/11.jpg)
11
Multi-PushT1
Central Stack
push
T1 Ta Tb
![Page 12: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/12.jpg)
12
Multi-PopT1
Central Stack
pop
T1 Ta Tb Tc
M
M = min{stack_size, multi_op_size}
![Page 13: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/13.jpg)
13
Multi-Eliminate
T1
pushT1 Ta Tb
T2 Tc Td TeT2
pop
Retry!
![Page 14: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/14.jpg)
14
Data-structures
![Page 15: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/15.jpg)
Push & Pop operations
![Page 16: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/16.jpg)
MultiPop function
![Page 17: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/17.jpg)
17
Collide function
![Page 18: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/18.jpg)
18
ActiveCollide, Combine functions
![Page 19: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/19.jpg)
19
MultiEliminate function
![Page 20: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/20.jpg)
20
PassiveCollide
![Page 21: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/21.jpg)
21
Experimental EvaluationEvaluated on an UltraSPARC T2+ –
8 cores CPU (each with 8 hardware threads) 64 hardware threads
Compared DECS with:◦ Treiber (with exponential backoff)◦ HSY (elimination backoff) algorithm◦ Flat-Combining (FC) stack
![Page 22: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/22.jpg)
22
Symmetric workload50% push – 50% pop
Threads
Thro
ughp
ut
![Page 23: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/23.jpg)
23
Moderately Asymmetric75% push – 25% pop
Threads
Thro
ughp
ut
![Page 24: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/24.jpg)
24
Fully Asymmetric100% push – 0% pop
Threads
Thro
ughp
ut
![Page 25: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/25.jpg)
25
DECS summary Scalable
Provides parallelism even for asymmetric workloads
Blocking
![Page 26: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/26.jpg)
26
Non-blocking DECSA non-blocking algorithm is more
robust to thread failures
Similar to DECS, but threads that delegate an operation do not wait indefinitely
A thread stops waiting by signaling its delegate thread
![Page 27: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/27.jpg)
27
NB-DECS - exampleA thread may stop waiting
after some timeoutT1
Central Stack
push
T1 Ta TbX
X
![Page 28: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/28.jpg)
28
NB-DECS - overhead1. Test-and-set validation of each
popped element from the central stack
2. Elements must be popped from the central stack one-by-one
3. Test-and-set validation on eliminated operations
![Page 29: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/29.jpg)
29
Symmetric workload50% push – 50% pop
Threads
Thro
ughp
ut
![Page 30: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/30.jpg)
30
Moderately Asymmetric75% push – 25% pop
Threads
Thro
ughp
ut
![Page 31: DECS: A Dynamic Elimination-Combining Stack Algorithm](https://reader036.fdocuments.net/reader036/viewer/2022062315/56816369550346895dd4423b/html5/thumbnails/31.jpg)
31
Moderately Asymmetric25% push – 75% pop
Threads
Thro
ughp
ut