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

parallel programming must be deterministic by default
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 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/

slide-2
SLIDE 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

slide-3
SLIDE 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

slide-4
SLIDE 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

3

Parallel languages should be deterministic by default

slide-5
SLIDE 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

3

Parallel languages should be deterministic by default Determinism should be guaranteed unless nondeterminism is explicitly requested

slide-6
SLIDE 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

slide-7
SLIDE 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

slide-8
SLIDE 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

slide-9
SLIDE 9

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,
  • paque performance

Runtime (software and/or hardware)

  • Strengths: Exploit runtime information
  • Weaknesses: Overhead, complexity, opaque

performance, weak guarantee

7

Guaranteeing Determinism: Approaches

slide-10
SLIDE 10

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,
  • paque performance

Runtime (software and/or hardware)

  • Strengths: Exploit runtime information
  • Weaknesses: Overhead, complexity, opaque

performance, weak guarantee

7

Guaranteeing Determinism: Approaches

Strong language mechanisms are essential

slide-11
SLIDE 11

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,
  • paque performance

Runtime (software and/or hardware)

  • Strengths: Exploit runtime information
  • Weaknesses: Overhead, complexity, opaque

performance, weak guarantee

7

Guaranteeing Determinism: Approaches

Strong language mechanisms are essential Supplement with compiler and runtime techniques for greater expressivity

slide-12
SLIDE 12

Effect Systems

8

class Tree<region P> { int data in P; region Left, Right, Links; Tree<Left> leftChild in Links; Tree<Right> rightChild in Links; }

slide-13
SLIDE 13

Effect Systems

8

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

slide-14
SLIDE 14

Effect Systems

8

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

slide-15
SLIDE 15

Effect Systems

8

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

slide-16
SLIDE 16

Effect Systems

8

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

slide-17
SLIDE 17

Effect Systems

8

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

Tree<P> int data P Tree<Left> leftChild Links Tree<Right> rightChild Links Tree<Left> int data Left Tree<Left> leftChild Links Tree<Right> rightChild Links Tree<Right> int data Right Tree<Left> leftChild Links Tree<Right> rightChild Links

slide-18
SLIDE 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

9

http://dpj.cs.uiuc.edu/

slide-19
SLIDE 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

slide-20
SLIDE 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

11

foreach_nd (...) { // Potentially nondeterministic code }

slide-21
SLIDE 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

slide-22
SLIDE 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#)

13

http://dpj.cs.uiuc.edu/