type systems for distributed data structures
play

Type Systems For Distributed Data Structures Ben Liblit & - PowerPoint PPT Presentation

Type Systems For Distributed Data Structures Ben Liblit & Alexander Aiken University of California, Berkeley Underlying Memory Model Multiple machines, each with local memory Global memory is union of local memories


  1. Type Systems For Distributed Data Structures Ben Liblit & Alexander Aiken University of California, Berkeley

  2. Underlying Memory Model • Multiple machines, each with local memory • Global memory is union of local memories • Distinguish two types of pointers: – Local Local points to local memory only – – Global Global points anywhere: 〈 machine, address 〉 – – Different representations & operations

  3. Language Design Options • Make everything global? � Conservatively sound � Easy to use � Hides program structure � Needlessly slow

  4. Language Design Options • Expose local/global to programmer? � Explicit cost model � Faster execution � Naïve designs are unsound (as we will show) � Code becomes difficult to write and maintain � Conversion of sequential code is problematic

  5. A (Possibly) Gratuitous Global A (Potentially) Unsound Local 7 8 5

  6. Understand It First, Then Fix It • Study local/global in a simpler context – Design a sound type system for a tiny language • Move from type checking to type inference – Programmers see as much detail as they want • Apply findings to design of real languages – Type system detects & forbids “bad things” – Local qualification inference as optimization

  7. Type Grammar :: local global ω = :: int boxed τ = ω τ τ × τ • Boxed and unboxed values • Integers, pointers, and pairs – Pairs are not assumed boxed • References to boxes are either local or global

  8. Global Dereferencing: Standard Approach Unsound : boxed global τ x , where boxed local int τ = : ↓ τ x x = ↓ x = 5

  9. Global Dereferencing: Sound With Type Expansion : boxed global τ x : expand( ) ↓ τ x x = ↓ x = 5

  10. Global Dereferencing: Tuple Expansion • Type expansion for tuple components? • No: would change representation of tuple 8 x = ↓ x = 8 5

  11. Global Dereferencing: Tuple Expansion • Solution: Invalidate local pointers in tuples • Other components remain valid, usable 8 x = ↓ x = 8 5

  12. Global Tuple Selection • Starting at x , can we reach 5? • Yes, with a proper selection operator 8 x = 5

  13. Global Tuple Selection • Selection offsets pointer within tuple 8 x = @2 x = 5

  14. Global Tuple Selection • Selection offsets pointer within tuple • Global-to-local pointer works just as before 8 x = @2 x = 5 ↓ @2 x =

  15. Extended Type Grammar :: local global ω = :: valid invalid ρ = :: int boxed τ = ω ρ τ τ × τ • Allow subtyping on validity qualifiers boxed valid boxed invalid ω τ ≤ ω τ τ × τ ≤ τ × τ ⇔ τ ≤ τ ∧ τ ≤ τ 1 2 3 4 1 3 2 4

  16. Global Assignment : boxed valid global τ x : τ y : : = τ x y x = 3 5 y =

  17. Global Assignment : boxed valid global τ x : expand ( ) τ τ = τ y : : = τ x y x = 3 5 y =

  18. Type Qualifier Inference • Efficiently infer qualifiers in two passes: 1. Maximize number of “invalid” qualifiers 2. Maximize number of “local” qualifiers • Allows for a range of language designs – Complete inference – Allow explicit declarations as needed • On large codes, does better than humans!

  19. Titanium Implementation • Titanium = Java + SPMD parallelism – Focus is on scientific codes • Global is assumed; local is explicit – E.g., “Object local” or “double [] local [] local” • Local qualification inference in compiler – Conservative for valid/invalid qualifiers – Monomorphic

  20. Titanium Benchmarks: Speed 56% 60% Reduction in Execution Time 50% 42% 40% 27% 30% 20% 12% 6% 10% 2% 1% 0% lu-fact lu-fact cannon cannon sample gsrb pps manual auto manual auto

  21. Titanium Benchmarks: Code Size 60% 50% 49% Reduction in Code Size 46% 50% 45% 43% 43% 40% 35% 30% 20% 10% 0% lu-fact lu-fact cannon cannon sample gsrb pps manual auto manual auto

  22. Summary and Conclusions • For top performance, local/global must be dealt with • Soundness issues are subtle, but tractable – Analysis core is surprisingly simple • Type qualifier inference is a double win: – Programming is easier – Optimized code is faster, smaller

Recommend


More recommend