Scaling Program Synthesis by Exploiting Existing Code James - - PowerPoint PPT Presentation

scaling program synthesis by exploiting existing code
SMART_READER_LITE
LIVE PREVIEW

Scaling Program Synthesis by Exploiting Existing Code James - - PowerPoint PPT Presentation

Scaling Program Synthesis by Exploiting Existing Code James Bornholt Emina Torlak University of Washington Synthesis: write programs automatically Syntax Semantics Synthesis: write programs automatically Syntax Semantics Synthesis: write


slide-1
SLIDE 1

Scaling Program Synthesis by Exploiting Existing Code

James Bornholt Emina Torlak

University of Washington

slide-2
SLIDE 2

Synthesis: write programs automatically

Semantics Syntax

slide-3
SLIDE 3

Synthesis: write programs automatically

Semantics Syntax

slide-4
SLIDE 4

Synthesis: write programs automatically

Target Behavior

Semantics Syntax

f(x) = 4x + 1

slide-5
SLIDE 5

Synthesis: write programs automatically

Target Behavior 4*x + 1

Semantics Syntax

f(x) = 4x + 1

slide-6
SLIDE 6

Synthesis: write programs automatically

Target Behavior x + x + x + x + 1 4*x + 1

Semantics Syntax

f(x) = 4x + 1

(x<<2) + 1

slide-7
SLIDE 7

Synthesis: write programs automatically

Target Behavior

Semantics Syntax

Permutation(L, f(L)) ∧ Sorted(f(L))

slide-8
SLIDE 8

Synthesis: write programs automatically

Target Behavior

Semantics Syntax

Permutation(L, f(L)) ∧ Sorted(f(L))

Quicksort Bubble Sort

slide-9
SLIDE 9

The success of synthesis

End-user programming by example [FlashFill, POPL’11] Cache coherence protocols

[Transit, PLDI’13]

Parallel browser layout engines [PPoPP’13] Compilers for new spatial architectures [Chlorophyll, PLDI’14]

slide-10
SLIDE 10

The success of synthesis

End-user programming by example [FlashFill, POPL’11] Cache coherence protocols

[Transit, PLDI’13]

Parallel browser layout engines [PPoPP’13] Compilers for new spatial architectures [Chlorophyll, PLDI’14]

S y n t h e s i s

turns

h i g h

  • l

e v e l i n t e n t

into

l

  • w
  • l

e v e l d e t a i l

slide-11
SLIDE 11

The success of synthesis

End-user programming by example [FlashFill, POPL’11] Cache coherence protocols

[Transit, PLDI’13]

Parallel browser layout engines [PPoPP’13] Compilers for new spatial architectures [Chlorophyll, PLDI’14]

S y n t h e s i s

turns

h i g h

  • l

e v e l i n t e n t

into

l

  • w
  • l

e v e l d e t a i l

Approximate Computing

quality bounds

into

approximate programs

slide-12
SLIDE 12

The success of synthesis

End-user programming by example [FlashFill, POPL’11] Cache coherence protocols

[Transit, PLDI’13]

Parallel browser layout engines [PPoPP’13] Compilers for new spatial architectures [Chlorophyll, PLDI’14]

S y n t h e s i s

turns

h i g h

  • l

e v e l i n t e n t

into

l

  • w
  • l

e v e l d e t a i l

Approximate Computing

quality bounds

into

approximate programs

Hardware Synthesis

programs

into

hardware designs

slide-13
SLIDE 13

The success of synthesis

End-user programming by example [FlashFill, POPL’11] Cache coherence protocols

[Transit, PLDI’13]

Parallel browser layout engines [PPoPP’13] Compilers for new spatial architectures [Chlorophyll, PLDI’14]

S y n t h e s i s

turns

h i g h

  • l

e v e l i n t e n t

into

l

  • w
  • l

e v e l d e t a i l

Approximate Computing

quality bounds

into

approximate programs

Hardware Synthesis

programs

into

hardware designs

Black Box Systems

  • bserved behaviors

into

specifjcations

slide-14
SLIDE 14

Not all applications require perfect accuracy

Approximate Computing

quality bounds

into

approximate programs

slide-15
SLIDE 15

Not all applications require perfect accuracy

Approximate Computing

quality bounds

into

approximate programs

slide-16
SLIDE 16

Not all applications require perfect accuracy

Approximate Computing

quality bounds

into

approximate programs

Video and image quality

slide-17
SLIDE 17

Not all applications require perfect accuracy

Approximate Computing

quality bounds

into

approximate programs

Video and image quality Sensors and simulation Machine learning

slide-18
SLIDE 18

Not all applications require perfect accuracy

Approximate Computing

quality bounds

into

approximate programs Precise Implementation

slide-19
SLIDE 19

Not all applications require perfect accuracy

Approximate Computing

quality bounds

into

approximate programs Precise Implementation Desired Quality

slide-20
SLIDE 20

Not all applications require perfect accuracy

Approximate Computing

quality bounds

into

approximate programs

Approximate Compiler

Precise Implementation Desired Quality

slide-21
SLIDE 21

Not all applications require perfect accuracy

Approximate Computing

quality bounds

into

approximate programs

Approximate Compiler

Precise Implementation Desired Quality Approximate Program

slide-22
SLIDE 22

Not all applications require perfect accuracy

Approximate Computing

quality bounds

into

approximate programs

Approximate Program Synthesis†

Precise Implementation Desired Quality Approximate Program

† Bornholt, Torlak, Ceze, Grossman. Approximate Program Synthesis. At WAX’15, collocated with PLDI’15.

slide-23
SLIDE 23

Hardware Synthesis

programs

into

hardware designs

Synthesizing circuits from high-level languages

slide-24
SLIDE 24

Hardware Synthesis

programs

into

hardware designs

Synthesizing circuits from high-level languages

module example(input a, b, c, output y); assign y = ~a & ~b & ~c | a & ~b & ~c | a & ~b & c; endmodule

slide-25
SLIDE 25

Hardware Synthesis

programs

into

hardware designs

Synthesizing circuits from high-level languages

module example(input a, b, c, output y); assign y = ~a & ~b & ~c | a & ~b & ~c | a & ~b & c; endmodule

slide-26
SLIDE 26

Hardware Synthesis

programs

into

hardware designs

Synthesizing circuits from high-level languages

module example(input a, b, c, output y); assign y = ~a & ~b & ~c | a & ~b & ~c | a & ~b & c; endmodule

slide-27
SLIDE 27

Hardware Synthesis

programs

into

hardware designs

Synthesizing circuits from high-level languages

High-Level Synthesis (HLS)

slide-28
SLIDE 28

Hardware Synthesis

programs

into

hardware designs

Synthesizing circuits from high-level languages

High-Level Synthesis (HLS)

Place and route Timing closure Crosstalk and feedback Quantum!

slide-29
SLIDE 29

Hardware Synthesis

programs

into

hardware designs

Synthesizing circuits from high-level languages

Mark Wyse

UW grad student and HLS extraordinaire

slide-30
SLIDE 30

Hardware Synthesis

programs

into

hardware designs

Synthesizing circuits from high-level languages

float dist(float a[3], float b[3]) { float r = 0; r += (a[0] - b[0]) * (a[0] - b[0]); r += (a[1] - b[1]) * (a[1] - b[1]); r += (a[2] - b[2]) * (a[2] - b[2]); return sqrt(r); }

Mark Wyse

UW grad student and HLS extraordinaire

slide-31
SLIDE 31

Black Box Systems

  • bserved behaviors

into

specifjcations

Defjning system behavior by observation

slide-32
SLIDE 32

Black Box Systems

  • bserved behaviors

into

specifjcations

Defjning system behavior by observation

slide-33
SLIDE 33

Black Box Systems

  • bserved behaviors

into

specifjcations

Defjning system behavior by observation

slide-34
SLIDE 34

Black Box Systems

  • bserved behaviors

into

specifjcations

Defjning system behavior by observation

slide-35
SLIDE 35

Black Box Systems

  • bserved behaviors

into

specifjcations

Defjning system behavior by observation

Programming by example

slide-36
SLIDE 36

Black Box Systems

  • bserved behaviors

into

specifjcations

Defjning system behavior by observation

Programming by example Synthesizing x86 instruction specs

Godefroid and Taly. Automated Synthesis of Symbolic Instruction Encodings from I/O Samples. PLDI’12.

slide-37
SLIDE 37

Black Box Systems

  • bserved behaviors

into

specifjcations

Approximate Computing

quality bounds

into

approximate programs

Hardware Synthesis

programs

into

hardware designs

slide-38
SLIDE 38

Machine Learning and Synthesis

slide-39
SLIDE 39

Learning programs from examples

Black Box Systems

  • bserved behaviors

into

specifjcations

∃P. ^

xi∈X

ϕ(xi, P(xi))

slide-40
SLIDE 40

Learning programs from examples

Black Box Systems

  • bserved behaviors

into

specifjcations

∃P. ^

xi∈X

ϕ(xi, P(xi))

FlashFill

slide-41
SLIDE 41

Learning programs from examples

FlashFill Version Space Algebra

slide-42
SLIDE 42

Machine learning and synthesis

Program Synthesis Statistical Machine Learning

slide-43
SLIDE 43

Machine learning and synthesis

Program Synthesis Statistical Machine Learning

Millions of examples/parameters

slide-44
SLIDE 44

Machine learning and synthesis

Program Synthesis Statistical Machine Learning

Millions of examples/parameters 100 instructions

slide-45
SLIDE 45

Machine learning and synthesis

Program Synthesis Statistical Machine Learning

Millions of examples/parameters 100 instructions

Approximate Computing Hardware Synthesis Black Box Systems

slide-46
SLIDE 46

Machine learning and synthesis

Program Synthesis Statistical Machine Learning

Millions of examples/parameters 100 instructions

Approximate Computing Hardware Synthesis Black Box Systems

slide-47
SLIDE 47

Programs are not uniformly distributed.

slide-48
SLIDE 48

Programs are not uniformly distributed.

Stack Overfmow mentions 20000 40000 60000 80000 malloc longjmp

slide-49
SLIDE 49

Programs are not uniformly distributed.

Stack Overfmow mentions 20000 40000 60000 80000 malloc longjmp

slide-50
SLIDE 50

Programs are not uniformly distributed.

Stack Overfmow mentions 20000 40000 60000 80000 malloc longjmp

slide-51
SLIDE 51

Programs are not uniformly distributed.

Stack Overfmow mentions 20000 40000 60000 80000 malloc longjmp mov

call

push

mov call test jmp lea push sub

slide-52
SLIDE 52

Component-Based Synthesis

slide-53
SLIDE 53

Synthesis of Loop-Free Programs

Gulwani, Jha, Tiwari, and Venkatesan. Synthesis of loop-free programs. PLDI’11.

slide-54
SLIDE 54

Synthesis of Loop-Free Programs

Gulwani, Jha, Tiwari, and Venkatesan. Synthesis of loop-free programs. PLDI’11.

f(x, y) = x + y 2 ⌫

slide-55
SLIDE 55

Synthesis of Loop-Free Programs

Gulwani, Jha, Tiwari, and Venkatesan. Synthesis of loop-free programs. PLDI’11.

f(x, y) = x + y 2 ⌫

and xor add >> 1

slide-56
SLIDE 56

Synthesis of Loop-Free Programs

Gulwani, Jha, Tiwari, and Venkatesan. Synthesis of loop-free programs. PLDI’11.

f(x, y) = x + y 2 ⌫

and xor add >> 1 x y

slide-57
SLIDE 57

Synthesis of Loop-Free Programs

Gulwani, Jha, Tiwari, and Venkatesan. Synthesis of loop-free programs. PLDI’11.

f(x, y) = x + y 2 ⌫

and xor add >> 1 x y f(x,y)

slide-58
SLIDE 58

Synthesis of Loop-Free Programs

Gulwani, Jha, Tiwari, and Venkatesan. Synthesis of loop-free programs. PLDI’11.

f(x, y) = x + y 2 ⌫

and xor add >> 1 x y f(x,y)

slide-59
SLIDE 59

Synthesis of Loop-Free Programs

f(x, y) = x + y 2 ⌫

and xor add >> 1

Gulwani, Jha, Tiwari, and Venkatesan. Synthesis of loop-free programs. PLDI’11.

slide-60
SLIDE 60

lt gt

Synthesis of Loop-Free Programs

f(x, y) = x + y 2 ⌫

and xor add >> 1 sub mul div udiv rem urem

  • r

nand not neg << 1 >>> 1 << 2 eq le ge

Gulwani, Jha, Tiwari, and Venkatesan. Synthesis of loop-free programs. PLDI’11.

slide-61
SLIDE 61

lt gt

Synthesis of Loop-Free Programs

f(x, y) = x + y 2 ⌫

and xor add >> 1 sub mul div udiv rem urem

  • r

nand not neg << 1 >>> 1 << 2 eq le ge

Gulwani, Jha, Tiwari, and Venkatesan. Synthesis of loop-free programs. PLDI’11. Solving time (secs) 500 1000 1500 2000 Number of components 4 8 12 16

slide-62
SLIDE 62

lt gt

Higher-level components

and xor add >> 1 sub mul div udiv rem urem

  • r

nand not neg << 1 >>> 1 << 2 eq le ge

f(L) = min{li | li ∈ L}

slide-63
SLIDE 63

Higher-level components

f(L) = min{li | li ∈ L}

slide-64
SLIDE 64

Higher-level components

f(L) = min{li | li ∈ L}

quicksort [ ]

slide-65
SLIDE 65

Higher-level components

f(L) = min{li | li ∈ L}

quicksort f(L) = quicksort(L)[0] [ ]

slide-66
SLIDE 66

Higher-level components

f(L) = min{li | li ∈ L}

quicksort f(L) = quicksort(L)[0] [ ] Mine existing code bases for common idioms

slide-67
SLIDE 67

Higher-level components

f(L) = min{li | li ∈ L}

quicksort f(L) = quicksort(L)[0] [ ] Mine existing code bases for common idioms Hardware Synthesis

programs

into

hardware designs

slide-68
SLIDE 68

Producing candidate programs

f(x, y) = x + y 2 ⌫

and xor add >> 1 x y f(x,y)

slide-69
SLIDE 69

Producing candidate programs

f(x, y) = x + y 2 ⌫

and xor add >> 1 x y

slide-70
SLIDE 70

Producing candidate programs

f(x, y) = x + y 2 ⌫

and xor add >> 1 x y

mov

call

push

mov call test jmp lea push sub

slide-71
SLIDE 71

Producing candidate programs

f(x, y) = x + y 2 ⌫

and xor add >> 1 x y Learn search heuristics from existing code

mov

call

push

mov call test jmp lea push sub

slide-72
SLIDE 72

Producing candidate programs

f(x, y) = x + y 2 ⌫

and xor add >> 1 x y Learn search heuristics from existing code Programming by example

[FlashFill, POPL’11]

Autocomplete with synthesis

[CodeHint, ICSE’14]

mov

call

push

mov call test jmp lea push sub

slide-73
SLIDE 73

Producing candidate programs

f(x, y) = x + y 2 ⌫

and xor add >> 1 x y Learn search heuristics from existing code Programming by example

[FlashFill, POPL’11]

Autocomplete with synthesis

[CodeHint, ICSE’14] Mine existing code bases for common idioms

mov

call

push

mov call test jmp lea push sub

slide-74
SLIDE 74

Producing candidate programs

Learn search heuristics from existing code

Mine existing code bases for common idioms

Black Box Systems

  • bserved behaviors

into

specifjcations

Selecting among many candidate solutions

slide-75
SLIDE 75

Sketch-Based Synthesis

slide-76
SLIDE 76

Sketches make synthesis more tractable

slide-77
SLIDE 77

Sketches make synthesis more tractable

bit[W] popCount(bit[W] x) { x = (x & 0x5555) + ((x >> 1) & 0x5555); x = (x & 0x3333) + ((x >> 2) & 0x3333); x = (x & 0x0077) + ((x >> 8) & 0x0077); x = (x & 0x000F) + ((x >> 4) & 0x000F); return x; }

slide-78
SLIDE 78

Sketches make synthesis more tractable

bit[W] popSketched(bit[W] x) { loop (??) { x = (x & ??) + ((x >> ??) & ??); } return x; } bit[W] popCount(bit[W] x) { x = (x & 0x5555) + ((x >> 1) & 0x5555); x = (x & 0x3333) + ((x >> 2) & 0x3333); x = (x & 0x0077) + ((x >> 8) & 0x0077); x = (x & 0x000F) + ((x >> 4) & 0x000F); return x; }

slide-79
SLIDE 79

Sketches make synthesis more tractable

bit[W] popSketched(bit[W] x) { loop (??) { x = (x & ??) + ((x >> ??) & ??); } return x; }

slide-80
SLIDE 80

Sketches make synthesis more tractable

bit[W] popSketched(bit[W] x) { loop (??) { x = (x & ??) + ((x >> ??) & ??); } return x; }

int[] map(int[] xs) { int[] ys = {}; for (int i=0; i<xs.length; i++) { ys.append(??(xs[i])); } return ys; } int[] filter(int[] xs) { int[] ys = {}; for (int i=0; i<xs.length; i++) { if (??(xs[i])) ys.append(xs[i]); } } int[] foldl(int[] xs) { int acc = ??; for (int i=0; i<xs.length; i++) { acc = ??(acc, xs[i]); } return ys; }

slide-81
SLIDE 81

Sketches make synthesis more tractable

Identify common sketches from existing code

slide-82
SLIDE 82

Sketches make synthesis more tractable

Identify common sketches from existing code

Mine existing code bases for common idioms

slide-83
SLIDE 83

Sketches make synthesis more tractable

Identify common sketches from existing code

Mine existing code bases for common idioms

Approximate Computing

quality bounds

into

approximate programs

slide-84
SLIDE 84

Sketches make synthesis more tractable

Identify common sketches from existing code

Mine existing code bases for common idioms

Approximate Computing

quality bounds

into

approximate programs Precise Implementation Approximate Program Synthesis

slide-85
SLIDE 85

Program Synthesis Statistical Machine Learning

Approximate Computing Hardware Synthesis Black Box Systems

slide-86
SLIDE 86

Program Synthesis Statistical Machine Learning

Approximate Computing Hardware Synthesis Black Box Systems

slide-87
SLIDE 87

Program Synthesis Statistical Machine Learning

Approximate Computing Hardware Synthesis Black Box Systems

Thanks!