Download presentation
Presentation is loading. Please wait.
Published byTamsyn Patrick Modified over 9 years ago
1
ROBERT BOCCHINO, ET AL. UNIVERSAL PARALLEL COMPUTING RESEARCH CENTER UNIVERSITY OF ILLINOIS A Type and Effect System for Deterministic Parallel Java *Based on OOPSLA-2009 conference presentation by Robert Bocchino Presented by Thawan Kooburat Computer Science Department University of Wisconsin - Madison
2
Outline Prologue Introduction Deterministic Parallel Java (DPJ) Usage Patterns Implementation Evaluation 2
3
Prologue ParallelArray (Java 7 – java.util.concurrent) Slice up data into blocks Perform operation on all data concurrently 3
4
Prologue ParallelArray of distinct objects Framework cannot prevent programmer from writing code will break the semantic Access global variables Time 4
5
Introduction Deterministic Execution Same input always produce same output Many computational algorithms are deterministic Many programs use parallel execution in order to gain performance, but it is not part of the specification. 5
6
Deterministic-by-default Guaranteed deterministic execution by default Nondeterministic behavior must be explicitly requested. foreach Iterating over independent objects foreach_nd Iterating over overlapping objects R. Bocchino, V. Adve, S. Adve, and M. Snir, “Parallel Programming Must Be Deterministic by Default” 6
7
Benefits Can reason sequentially No hidden parallel bugs Testing based on input No need to test all interleaving combinations Parallelize incrementally Easier to compose 7
8
Deterministic Parallel Java (DPJ) Based on Java language Fork/Join parallelism Cobegin Foreach Type and effect system Expose noninterference (Soundness) Field-level granularity Differentiate between readers and writers Guarantee deterministic execution at compile time 8
9
Regions and Effects Regions Divide memory location into regions Can be formed into a tree class TreeNode { region L, R, V; int value in V; TreeNode left = new TreeNode (); TreeNode right = new TreeNode (); } Parameterized by region 9
10
Regions Root Root:L Root:R Root:L:L Root:L:R Root:R:L Root:R:R 10
11
Effects Read or write operations on data Programmer specify effect summary for each method class TreeNode {... TreeNode left = new TreeNode (); TreeNode right = new TreeNode (); void updateChildren() writes L, R { cobegin { left.data = 0; /* writes L */ right.data = 1; /* writes R */ } Method effect summary Compiler inferred from type Non interference 11
12
Usage Patterns Region path lists (RPLs) Updating nested data structure with field-granularity Index-parameterized array Updating an array of objects Subarray Partition array for divide and conquer pattern. Commutativity Declare effect summary based on operation’s semantic 12
13
Region Path Lists (RPLs) class Tree { region L, R; int value in P; Tree left = new Tree (); Tree right = new Tree (); } P= Root valueRoot leftRoot:L rightRoot:R P=Root:L valueRoot:L leftRoot:L:L rightRoot:L:R P=Root:R valueRoot:R leftRoot:R:L rightRoot:R:R 13
14
Region Path Lists (RPLs) class Tree {... int increment() writes P:* { value++; /* writes P */ cobegin { /* writes P:L:* */ if (left != null) left.increment(); /* writes P:R:* */ if (right != null) right.increment(); } P:L:* ⊆ P:* P:R:* ⊆ P:* P:L:* ⊆ P:* P:R:* ⊆ P:* Inclusion (Method effect) Inclusion (Method effect) Disjointness (Cobegin body) Disjointness (Cobegin body) P:L:* ∩ P:R:* = ∅ Method effect summary Effect inferred from type and summary 14
15
Index-parameterized Array Enforce disjointness of array’s element (reference) Syntax:C []#i 12341234 a[i]b[i] C 1234 c[i] 15
16
Index-parameterized Array final Body [] bodies = new Body [N] ; foreach (int i in 0, N) { /* writes [i] */ bodies[i] = new Body (); } foreach (int i in 0, N) { /* reads [i], Link, *:M writes [i]:F */ bodies[i].computeForce(); class Body { double mass in P:M; double force in P:F; Body link in Link; void computeForce() reads Link, *:M writes P:F {..} } Write to each element is distinct Read does not interfere write Objects are parameterlized by index region Operations in foreach block is noninterference 16
17
Subarray Mechanisms: DPJ Libraries DPJArray:Wrapper class for Java array DPJPartition:Collections of disjoint DPJArray Divide and Conquer usage pattern Initialize an array using DPJArray Recursively partition original array using DPJPartition Each partition is a disjoint subset of original array Create a tree of partition based on flat array 17
18
Subarray static void quicksort(DPJArray A) writes R:* { int p = quicksortPartition(A); /* Chop array into two disjoint pieces */ final DPJPartition segs = new DPJPartition (A, p, OPEN); cobegin { /* write segs:[0]:* */ quicksort(segs.get(0)); /* write segs:[1]:* */ quicksort(segs.get(1)); } Use local variable to represent regions R R DPJArray segs[0] segs[1] p p DPJPartition 18
19
Commutativity Method annotation Allow programmers to override effect system Compiler will not check inside the method This allows cobegin { add(e1); add(e2); } Any order of operations is equivalent Operation is atomic interface Set { commutative void add(T e) writes R; } 19
20
Commutativity Method invocation foreach (int i in 0, n) { /* invokes Set.add with writes R */ set.add(A[i]); } cobegin { /* invokes Set.add with writes R */ set.add(A); /* invokes Set.size with read R */ set.size(); } 20
21
Implementation Extend Sun’s javac compiler Covert DPJ into normal Java source Compile to ForkJoinTask Framework (Java7) Similar to Cilk DPJ translates foreach and cobegin to tasks 21
22
Evaluation Benchmarks 22
23
Performance 4 8 12 16 20 24 4812162024 Speedup Number of cores Barnes-Hut Mergesort IDEA K-Means Collision Tree Monte Carlo 23
24
Q/A 24
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.