Top Banner
Type Systems For Distributed Data Structures Ben Liblit & Alexander Aiken University of California, Berkeley
23

Type Systems For Distributed Data Structures

Dec 31, 2015

Download

Documents

raven-good

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 Distinguish two types of pointers: Local points to local memory only - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Type Systems For Distributed Data Structures

Type Systems ForDistributed Data Structures

Ben Liblit & Alexander Aiken

University of California, Berkeley

Page 2: Type Systems For Distributed Data Structures

Underlying Memory Model

• Multiple machines, each with local memory

• Global memory is union of local memories

• Distinguish two types of pointers:– LocalLocal points to local memory only– GlobalGlobal points anywhere: machine, address– Different representations & operations

Page 3: Type Systems For Distributed Data Structures

Language Design Options

• Make everything global?Conservatively soundEasy to useHides program structureNeedlessly slow

Page 4: Type Systems For Distributed Data Structures

Language Design Options

• Expose local/global to programmer?Explicit cost modelFaster executionNaïve designs are unsound (as we will show)Code becomes difficult to write and maintainConversion of sequential code is problematic

Page 5: Type Systems For Distributed Data Structures

A (Possibly) Gratuitous GlobalA (Potentially) Unsound Local

5

7

8

Page 6: Type Systems For Distributed Data Structures

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

Page 7: Type Systems For Distributed Data Structures

Type Grammar

boxedint::

globallocal::

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

– Pairs are not assumed boxed

• References to boxes are either local or global

Page 8: Type Systems For Distributed Data Structures

Global Dereferencing:Standard Approach Unsound

5

int local boxed where,:

global boxed:

x

x

x =

x =

Page 9: Type Systems For Distributed Data Structures

Global Dereferencing:Sound With Type Expansion

5

)expand(:

global boxed:

x

x

x =

x =

Page 10: Type Systems For Distributed Data Structures

Global Dereferencing:Tuple Expansion

• Type expansion for tuple components?

• No: would change representation of tuple

5

8

8

x =

x =

Page 11: Type Systems For Distributed Data Structures

Global Dereferencing:Tuple Expansion

• Solution: Invalidate local pointers in tuples

• Other components remain valid, usable

5

8

8

x =

x =

Page 12: Type Systems For Distributed Data Structures

Global Tuple Selection

• Starting at x, can we reach 5?

• Yes, with a proper selection operator

5

8x =

Page 13: Type Systems For Distributed Data Structures

Global Tuple Selection

• Selection offsets pointer within tuple

5

8x =

@2 x =

Page 14: Type Systems For Distributed Data Structures

Global Tuple Selection

• Selection offsets pointer within tuple

• Global-to-local pointer works just as before

5

8x =

@2 x =

@2 x =

Page 15: Type Systems For Distributed Data Structures

Extended Type Grammar

boxedint::

invalidvalid::

globallocal::

• Allow subtyping on validity qualifiers

42314321

invalid boxed valid boxed

Page 16: Type Systems For Distributed Data Structures

3

Global Assignment

5

::

:

global validboxed:

yx

y

x

x =

y =

Page 17: Type Systems For Distributed Data Structures

3

Global Assignment

5

::

)(expand:

global validboxed:

yx

y

x

x =

y =

Page 18: Type Systems For Distributed Data Structures

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!

Page 19: Type Systems For Distributed Data Structures

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

Page 20: Type Systems For Distributed Data Structures

Titanium Benchmarks: Speed

1%

42%

6%12%

27%

2%

56%

0%

10%

20%

30%

40%

50%

60%

lu-factmanual

lu-factauto

cannonmanual

cannonauto

sample gsrb pps

Red

uct

ion

in E

xecu

tion

Tim

e

Page 21: Type Systems For Distributed Data Structures

Titanium Benchmarks: Code Size

43%49% 46% 45%

50%

35%

43%

0%

10%

20%

30%

40%

50%

60%

lu-factmanual

lu-factauto

cannonmanual

cannonauto

sample gsrb pps

Red

uct

ion

in C

ode

Siz

e

Page 22: Type Systems For Distributed Data Structures

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

Page 23: Type Systems For Distributed Data Structures