1 / 21

Speculative N-Way Barriers

Speculative N-Way Barriers. Lukasz Ziarek, Suresh Jagannathan Purdue University Mathew Fluet, Umut Acar TTI Chicago. Speculation. Performance Tool for better utilization of multi-core processors Highly constrained Short lived Isolated Few side effects, if any Rarely formalized

harva
Download Presentation

Speculative N-Way Barriers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 • Patterns (P) • Rd(l) : read of location l • Wr(l) : write of location l • Wr(l, v) : write ofvto l • Wr?(l, v) : write of v to l if l does not already contain v match(P) => e

  9. Representing N-Way Barriers • 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() => e : spawn (e) match(P) => 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)) => !x; !y; !z; … T2 = … x := 1; … T3 = … z := 3; y := 2; y := 42;

  12. match(wr(x)^wr(y)) => !x;!y;!z x:=1; Synchronous Execution T1 T2 T3 z:=3; BLOCKED T4 y:=2; Satisfied !x; 1 !y; 2 !z; 3 y:=42;

  13. match(wr(x)^wr(y))=> !x;!y;!z x:=1; Speculative Execution T1 T2 T3 σ[x->1, y->2, z->3 ] z:=3; !x; 1 !y; 2 !z; 3 y:=2; T4 Validate y:=42;

  14. match(wr(x)^wr(y))=> !x;!y;!z x:=1; Speculative Execution Requiring Rollback T1 T2 T3 σ[x->1, y->2, z->3 ] z:=3; y:=2; !x; 1 !y; 2 !z; 3 y:=42; T4 Validate

  15. Potential for Self Satisfying Code T1 match(wr(x) ^ wr(y))=> !x;y:=2;!z T2 !x; y:= 2; !z; x:=1; Validate

  16. Time Travel T3 T1 T2 match(wr(x) ^ wr(y)) x:=2; match(wr(x) ^ wr(y)) y:=4; Validate !x; y:= 2; !z; x:=1; 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?

More Related