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

type systems for distributed data structures
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Type Systems For Distributed Data Structures

Ben Liblit & Alexander Aiken University of California, Berkeley

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

slide-3
SLIDE 3

Language Design Options

  • Make everything global?

Conservatively sound Easy to use Hides program structure Needlessly slow

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

slide-5
SLIDE 5

A (Possibly) Gratuitous Global A (Potentially) Unsound Local

5 7 8

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

slide-7
SLIDE 7

Type Grammar

τ τ τ ω τ ω × = = boxed int :: global local ::

  • Boxed and unboxed values
  • Integers, pointers, and pairs

– Pairs are not assumed boxed

  • References to boxes are either local or global
slide-8
SLIDE 8

Global Dereferencing: Standard Approach Unsound

5

int local boxed where , : global boxed : = ↓ τ τ τ x x

x = ↓x =

slide-9
SLIDE 9

Global Dereferencing: Sound With Type Expansion

5

) expand( : global boxed : τ τ x x ↓

x = ↓x =

slide-10
SLIDE 10

Global Dereferencing: Tuple Expansion

  • Type expansion for tuple components?
  • No: would change representation of tuple

5 8 8

x = ↓x =

slide-11
SLIDE 11

Global Dereferencing: Tuple Expansion

  • Solution: Invalidate local pointers in tuples
  • Other components remain valid, usable

5 8 8

x = ↓x =

slide-12
SLIDE 12

Global Tuple Selection

  • Starting at x, can we reach 5?
  • Yes, with a proper selection operator

5 8

x =

slide-13
SLIDE 13

Global Tuple Selection

  • Selection offsets pointer within tuple

5 8

x = @2 x =

slide-14
SLIDE 14

Global Tuple Selection

  • Selection offsets pointer within tuple
  • Global-to-local pointer works just as before

5 8

x = ↓ @2 x = @2 x =

slide-15
SLIDE 15

Extended Type Grammar

τ τ τ ρ ω τ ρ ω × = = = boxed int :: invalid valid :: global local ::

  • Allow subtyping on validity qualifiers

4 2 3 1 4 3 2 1

invalid boxed valid boxed τ τ τ τ τ τ τ τ τ ω τ ω ≤ ∧ ≤ ⇔ × ≤ × ≤

slide-16
SLIDE 16

3

Global Assignment

5

τ τ τ : : : global valid boxed : y x y x =

x = y =

slide-17
SLIDE 17

3

Global Assignment

5

τ τ τ τ τ : : ) ( expand : global valid boxed : y x y x = =

x = y =

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

slide-20
SLIDE 20

Titanium Benchmarks: Speed

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

slide-21
SLIDE 21

Titanium Benchmarks: Code Size

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

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

slide-23
SLIDE 23