parallel programming must be deterministic by default
play

Parallel Programming Must Be Deterministic by Default Robert - PowerPoint PPT Presentation

Parallel Programming Must Be Deterministic by Default Robert Bocchino , Vikram Adve, Sarita Adve, and Marc Snir University of Illinois at Urbana-Champaign http://dpj.cs.uiuc.edu/ Parallel Programming Is Too Hard Too many nondeterministic


  1. Parallel Programming Must Be Deterministic by Default Robert Bocchino , Vikram Adve, Sarita Adve, and Marc Snir University of Illinois at Urbana-Champaign http://dpj.cs.uiuc.edu/

  2. Parallel Programming Is Too Hard Too many nondeterministic interleavings Hard to reason about correctness • Data races • Deadlock • Memory models Hard to get testing coverage • Must test multiple outputs per input • Easy to miss corner cases 2

  3. We Don’t Need All That Nondeterminism Many programs are (intended to be) deterministic • Non-interactive computation • Accept input, compute, produce output • Parallelism for performance , not part of specification Same input always produces same visible output 3

  4. We Don’t Need All That Nondeterminism Many programs are (intended to be) deterministic • Non-interactive computation • Accept input, compute, produce output • Parallelism for performance , not part of specification Same input always produces same visible output Parallel languages should be deterministic by default 3

  5. We Don’t Need All That Nondeterminism Many programs are (intended to be) deterministic • Non-interactive computation • Accept input, compute, produce output • Parallelism for performance , not part of specification Same input always produces same visible output Parallel languages should be deterministic by default Determinism should be guaranteed unless nondeterminism is explicitly requested 3

  6. Why Don’t We Already Do This? Some languages do guarantee determinism • Functional, SIMD, explicit dataflow But mainstream, general-purpose languages do not • Imperative, OO languages (Java, C++, C#) Expressive features obscure data flow • Pointers/references to mutable objects • Reference aliasing • Inheritance and polymorphism 4

  7. Our Proposed Research Goal Bring determinism by default to mainstream languages Benefits of achieving this goal: • Enable “almost sequential” reasoning • Avoid subtle parallelism bugs - No data races or deadlocks - No complex memory models • Simplify testing of parallel programs - Test one output per input and you are done • Simplify sequential to parallel porting • Simplify bug reproduction and debugging 5

  8. Our Proposed Research Agenda 1. How to guarantee determinism by default? 2. How to encapsulate nondeterministic behavior? 3. How to support explicit, controlled nondeterminism? 4. How to simplify development and porting? 6

  9. Guaranteeing Determinism: Approaches Language (type system) • Strengths : Programmer control and documentation, modularity • Weaknesses : Programmer effort ( perceived ), coarse granularity Compiler (auto parallelization) • Strengths : Less programmer effort • Weaknesses : Limited effectiveness, brittle, opaque performance Runtime (software and/or hardware) • Strengths : Exploit runtime information • Weaknesses : Overhead, complexity, opaque performance, weak guarantee 7

  10. Guaranteeing Determinism: Approaches Language (type system) Strong language • Strengths : Programmer control and mechanisms are documentation, modularity essential • Weaknesses : Programmer effort ( perceived ), coarse granularity Compiler (auto parallelization) • Strengths : Less programmer effort • Weaknesses : Limited effectiveness, brittle, opaque performance Runtime (software and/or hardware) • Strengths : Exploit runtime information • Weaknesses : Overhead, complexity, opaque performance, weak guarantee 7

  11. Guaranteeing Determinism: Approaches Language (type system) Strong language • Strengths : Programmer control and mechanisms are documentation, modularity essential • Weaknesses : Programmer effort ( perceived ), coarse granularity Compiler (auto parallelization) • Strengths : Less programmer effort Supplement with • Weaknesses : Limited effectiveness, brittle, compiler and runtime opaque performance techniques for greater expressivity Runtime (software and/or hardware) • Strengths : Exploit runtime information • Weaknesses : Overhead, complexity, opaque performance, weak guarantee 7

  12. Effect Systems class Tree<region P> { int data in P; region Left , Right , Links ; Tree< Left > leftChild in Links ; Tree< Right > rightChild in Links ; } 8

  13. Effect Systems Class region parameter P class Tree<region P> { int data in P; region Left , Right , Links ; Tree< Left > leftChild in Links ; Tree< Right > rightChild in Links ; } 8

  14. Effect Systems Class region parameter P class Tree<region P> { data declared in region P int data in P; region Left , Right , Links ; Tree< Left > leftChild in Links ; Tree< Right > rightChild in Links ; } 8

  15. Effect Systems Class region parameter P class Tree<region P> { data declared in region P int data in P; region Left , Right , Links ; Region names Left , Right , Links Tree< Left > leftChild in Links ; Tree< Right > rightChild in Links ; } 8

  16. Effect Systems Class region parameter P class Tree<region P> { data declared in region P int data in P; region Left , Right , Links ; Region names Left , Right , Links Tree< Left > leftChild in Links ; Field in Links points to Tree< Right > rightChild in Links ; Tree<Left> } 8

  17. Effect Systems Class region parameter P class Tree<region P> { data declared in region P int data in P; region Left , Right , Links ; Region names Left , Right , Links Tree< Left > leftChild in Links ; Field in Links points to Tree< Right > rightChild in Links ; Tree<Left> } Tree<P> int data P Tree< Left > leftChild Links Tree< Left > Tree< Right > Tree< Right > rightChild Links int data Left int data Right Tree< Left > leftChild Links Tree< Left > leftChild Links Tree< Right > rightChild Links Tree< Right > rightChild Links 8

  18. Deterministic Parallel Java (DPJ) Explicit type and effect system [see our Tech Reports] • Recursive parallelism on linked data structures • Array computations - Flat parallel traversals - Recursive partitioning (divide and conquer) • Support for object-oriented frameworks Runtime support [ongoing work] • Fine-grain synchronization • Fail-stop checks for greater expressivity http://dpj.cs.uiuc.edu/ 9

  19. Hidden Nondeterminism Programmer provides trusted annotation (e.g., library API) • class Set<E> { commutative void add(E e); // add commutes with itself... ... } Compiler uses annotation to prove determinism • foreach (int i in 0, n) { set.add(A[i]); // ...so this code is safe } 10

  20. Visible Nondeterminism Sometimes necessary for high performance • Example: Branch and bound, graph clustering Carefully controlled • Explicitly requested by programmer • Atomic and race free • Isolated: Nondeterministic and deterministic code do not interfere foreach_nd (...) { // Potentially nondeterministic code } 11

  21. Will a Language Solution Be Usable? Benefits outweigh the costs • Effect annotations aid reasoning the programmer must do anyway • Checkable contracts at interfaces enhance modularity Technical solutions can reduce the costs • Effect inference • Runtime checks • Integrated development environment 12

  22. Summary Guaranteed determinism can ease parallel programming For mainstream OO languages we need • Strong language solutions (type and effect) • Supplemented by runtime checks and tools Deterministic Parallel Java project at Illinois • Java-based • Applicable to other OO languages (C++, C#) http://dpj.cs.uiuc.edu/ 13

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend