Speculative N-Way Barriers - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Speculative N-Way Barriers

Description:

Threads operate over local heaps. Easier to reason about speculation. Heaps merged at join points (barriers) N-way barriers server as a communication medium ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 22
Provided by: lukasz1
Category:

less

Transcript and Presenter's Notes

Title: Speculative N-Way Barriers


1
Speculative N-Way Barriers
  • Lukasz Ziarek, Suresh Jagannathan
  • Purdue University
  • Mathew Fluet, Umut Acar
  • TTI Chicago

2
Speculation
  • Performance
  • Tool for better utilization of multi-core
    processors
  • Highly constrained
  • Short lived
  • Isolated
  • Few side effects, if any
  • Rarely formalized
  • Can we safely relax these limitations?

3
Programming Model
  • Higher Order Concurrent Language
  • References
  • N-way barriers
  • Synchronization point of n interacting threads
  • Fork/Join execution model
  • Threads operate over local heaps
  • Easier to reason about speculation
  • Heaps merged at join points (barriers)
  • N-way barriers server as a communication medium

4
Motivating Example All Pairs Shortest Path
  • Utilizes a matrix representation for a DAG
  • Partitions the matrix into smaller units
  • Each worker thread operates on disjoint
    partitions
  • All workers synchronize on an n-way barrier

5
Motivating Example All Pairs Shortest Path
2nd iteration
1st iteration
T1
T2
T1 dependant on T2,T3,T4
T3
T4
6
Motivating Example All Pairs Shortest Path
  • Observation
  • Each thread is only dependant on the work done by
    a fix number of threads in a previous iteration
  • Solution 1
  • Rewrite the algorithm
  • Algorithmic Complexity
  • Specialized Barriers and Counters
  • Results in 6x more code

7
Solution 2 Optimistic Concurrency
  • Utilize Speculation
  • Requires no change to the underlying core
    algorithm
  • Allows for the extraction of additional
    concurrency
  • Challenges
  • Maintaining a consistent view of memory
  • Interacting speculations

8
Representing N-Way Barriers
match(P) gt e
  • Patterns (P)
  • Rd(l) read of location l
  • Wr(l) write of location l
  • Wr(l, v) write of v to l
  • Wr?(l, v) write of v to l
  • if l does not already contain v

9
Representing N-Way Barriers
match(P) gt e
  • Barriers (match())
  • Each thread that matches a base pattern blocks
    until the entire pattern is satisfied
  • Thread which creates the barrier does not block
  • Guarded Expressions (e)
  • e delayed until completion of pattern
  • Executed in separate thread of control
  • can be utilized to encode spawn
  • match() gt e spawn (e)

10
Speculative Execution Model
  • Allow Speculation Past Barriers
  • Execute guarded expression speculatively
  • Participating threads proceed
  • Speculate a thread local store
  • Validate When Last Thread Participates in the
    Barrier
  • Confirm thread local store

11
Example Program
T1 match(wr(x) wr(y)) gt !x !y !z
T2 x 1 T3 z
3 y 2 y 42
12
Synchronous Execution
T1
T2
T3
z3
BLOCKED
T4
y2
Satisfied
!x 1 !y 2 !z 3
y42
13
Speculative Execution
T1
T2
T3
sx-gt1, y-gt2, z-gt3
z3
!x 1 !y 2 !z 3
y2
T4
Validate
y42
14
Speculative Execution Requiring Rollback
T1
T2
T3
sx-gt1, y-gt2, z-gt3
z3 y2
!x 1 !y 2 !z 3
y42
T4
Validate
15
Potential for Self Satisfying Code
T1
match(wr(x) wr(y))gt !xy2!z
T2
!x y 2 !z
x1
Validate
16
Time Travel
T3
T1
T2
match(wr(x) wr(y))
x2
match(wr(x) wr(y))
y4
Validate
!x y 2 !z
x1
T4
17
So how DO we choose a store?
  • Observation 1
  • Only need to estimate what we need and what has
    changed
  • Observation 2
  • Each thread participating in the pattern
    contributes at least 1 value
  • Observation 3
  • Patterns which specify a value for a location
    guide our choice
  • Observation 4
  • The more threads blocked on a barrier the more we
    know about the speculation context

18
Formalization
  • Synchronous Semantics
  • Speculative Semantics
  • Trace
  • Allows for the bridging of the speculative and
    synchronous semantics
  • Speculative Semantics composed of a committed
    trace and a speculative trace
  • Validated speculative actions are committed
  • Validation is done one thread at a time

19
Related Work
  • Compiler/Architecture Driven Speculation
  • Safe Futures
  • Software Transactions
  • Join Calculus
  • Fork/Join parallelism (Cilk)

20
Conclusion
  • Provided a Formal Definition of Unconstrained
    Speculation in a Multithreaded Context
  • Proved Speculative Semantics Adhere to
    Synchronous Semantics

21
Questions?
Write a Comment
User Comments (0)
About PowerShow.com