Growing Solver-Aided Languages with ROSETTE Emina Torlak & - - PowerPoint PPT Presentation

growing solver aided languages with rosette
SMART_READER_LITE
LIVE PREVIEW

Growing Solver-Aided Languages with ROSETTE Emina Torlak & - - PowerPoint PPT Presentation

Growing Solver-Aided Languages with ROSETTE Emina Torlak & Rastislav Bodik U.C. Berkeley solver-aided domain-specific language Solver-aided DSL (SDSL) Noun 1. A high-level language in which partially implemented programs can be executed


slide-1
SLIDE 1

Emina Torlak & Rastislav Bodik

U.C. Berkeley

Growing Solver-Aided Languages with ROSETTE

slide-2
SLIDE 2

solver-aided domain-specific language

2

Solver-aided DSL (SDSL) Noun

  • 1. A high-level language in which

partially implemented programs can be executed, verified, debugged and synthesized with the aid of a constraint solver.

slide-3
SLIDE 3

programming …

3

specification assume pre(x) P(x) { … } assert post(P(x))

slide-4
SLIDE 4

programming …

3

assume pre(x) P(x) { … } assert post(P(x))

formula, input/

  • utput pairs,

traces, another program, …

slide-5
SLIDE 5

programming with a solver

4

assume pre(x) P(x) { … } assert post(P(x)) assert post(P(x)) assume pre(x)

?

SAT/SMT solver translate(…)

slide-6
SLIDE 6

programming with a solver: code checking

5

assume pre(x) P(x) { … } assert post(P(x)) SAT/SMT solver Is there a valid input x for which P(x) violates the spec?

∃x . pre(x) ⋀

¬post(P(x))

CBMC [Oxford], Dafny [MSR], Jahob [EPFL], Miniatur / MemSAT [IBM], etc.

slide-7
SLIDE 7

programming with a solver: code checking

5

assume pre(x) P(x) { … } assert post(P(x)) SAT/SMT solver Is there a valid input x for which P(x) violates the spec?

∃x . pre(x) ⋀

¬post(P(x))

CBMC [Oxford], Dafny [MSR], Jahob [EPFL], Miniatur / MemSAT [IBM], etc.

model x = 42 counterexample

slide-8
SLIDE 8

programming with a solver: localizing faults

6

SAT/SMT solver Given x and x′, what subset of P is responsible for P(x) ≠ x′? pre(x) ⋀ post(x′) ∧ x′ = P(x) assume pre(x) P(x) { v = x + 2 … } assert post(P(x))

BugAssist [UCLA / MPI-SWS]

slide-9
SLIDE 9

programming with a solver: localizing faults

6

SAT/SMT solver MIN CORE / MAXSAT Given x and x′, what subset of P is responsible for P(x) ≠ x′? pre(x) ⋀ post(x′) ∧ x′ = P(x) repair candidates assume pre(x) P(x) { v = x + 2 … } assert post(P(x))

BugAssist [UCLA / MPI-SWS]

slide-10
SLIDE 10

programming with a solver: angelic execution

7

SAT/SMT solver Given x, choose v at runtime so that P(x, v) satisfies the spec.

∃v . pre(x) ⋀

post(P(x, v)) assume pre(x) P(x) { v = choose() … } assert post(P(x))

Kaplan [EPFL], PBnJ [UCLA], Skalch [Berkeley], Squander [MIT], etc.

slide-11
SLIDE 11

programming with a solver: angelic execution

7

SAT/SMT solver Given x, choose v at runtime so that P(x, v) satisfies the spec.

∃v . pre(x) ⋀

post(P(x, v)) assume pre(x) P(x) { v = choose() … } assert post(P(x)) model v = 0, … trace

Kaplan [EPFL], PBnJ [UCLA], Skalch [Berkeley], Squander [MIT], etc.

slide-12
SLIDE 12

programming with a solver: synthesis

8

SAT/SMT solver Replace ?? with expression e so that Pe(x) satisfies the spec on all valid inputs. assume pre(x) P(x) { v = ?? … } assert post(P(x))

∃e . ∀x . pre(x) ⇒

post(Pe(x))

Comfusy [EPFL], Sketch [Berkeley / MIT]

slide-13
SLIDE 13

programming with a solver: synthesis

8

SAT/SMT solver Replace ?? with expression e so that Pe(x) satisfies the spec on all valid inputs. assume pre(x) P(x) { v = ?? … } assert post(P(x)) model expressions

∃e . ∀x . pre(x) ⇒

post(Pe(x))

Comfusy [EPFL], Sketch [Berkeley / MIT]

x − 2

slide-14
SLIDE 14

but building solver-aided languages is hard …

9

P(x) { … } SAT/SMT solver translate(…)

?? ?

(Q x …) R(x) : … translate(…) translate(…)

Each new SDSL created by careful custom compilation to constraints, requiring years of training and experience.

slide-15
SLIDE 15

a solver-aided framework for building SDSLs

10

P(x) { … }

?? ?

(Q x …) R(x) : …

ROSETTE

interpret(…) interpret(…) API(…)

Implement a library or an interpreter for your SDSL, and get a synthesizer, verifier, debugger and angelic oracle for programs in that SDSL.

slide-16
SLIDE 16

a tiny solver-aided extension of racket …

11

top-level-form = general-top-level-form | (#%expression expr) | (module id name-id (#%plain-module-begin module-level-form ...)) | (begin top-level-form ...) | (begin-for-syntax top-level-form ...) module-level-form = general-top-level-form | (#%provide raw-provide-spec ...) | (begin-for-syntax module-level-form ...) general-top-level-form = expr | (define-values (id ...) expr) | (define-syntaxes (id ...) expr) | (#%require raw-require-spec ...) expr = id | (#%plain-lambda formals expr ...+) | (case-lambda (formals expr ...+) ...) | (if expr expr expr) | (begin expr ...+) | (begin0 expr expr ...) | (let-values ([(id ...) expr] ...) expr ...+) | (letrec-values ([(id ...) expr] ...) expr ...+) | (set! id expr) | (quote datum) | (quote-syntax datum) | (with-continuation-mark expr expr expr) | (#%plain-app expr ...+) | (#%top . id) | (#%variable-reference id) | (#%variable-reference (#%top . id)) | (#%variable-reference) formals = (id ...) | (id ...+ . id) | id

Racket

(define-symbolic id expr) (define-symbolic* id expr) (assert expr) (solve expr) (verify expr) (debug [expr ...+] expr) (synthesize #:forall expr #:guarantee expr)

ROSETTE

slide-17
SLIDE 17

… with a symbolic evaluator and compiler

12

ROSETTE

racket SDSL + program synthesize debug verify solve solver

transform, evaluate & compile to constraints

KODKOD

slide-18
SLIDE 18

… with a symbolic evaluator and compiler

12

ROSETTE

racket SDSL + program synthesize debug verify solve solver

map solution to program level

KODKOD

slide-19
SLIDE 19

… with a symbolic evaluator and compiler

12

ROSETTE

racket SDSL + program synthesize debug verify solve solver

map solution to program level

KODKOD

slide-20
SLIDE 20

rosette by example: an SDSL for circuits

13

F T T T F T T T spec impl

Why a circuit language?

  • A teaching aid
  • An oracle for

testing circuit transformations in SAT

  • based

solvers Booln → Bool Booln → Bool

b c d b c d a a

slide-21
SLIDE 21

rosette by example: an SDSL for circuits

13

F T T T F T T T spec impl

∀ a, b, c, d .

impl(a, b, c, d) ≡ spec(a, b, c, d)

verify Why a circuit language?

  • A teaching aid
  • An oracle for

testing circuit transformations in SAT

  • based

solvers

b c d b c d a a

slide-22
SLIDE 22

rosette by example: an SDSL for circuits

13

F T T T F T T T spec impl

debug Why a circuit language?

  • A teaching aid
  • An oracle for

testing circuit transformations in SAT

  • based

solvers

F T

slide-23
SLIDE 23

rosette by example: an SDSL for circuits

13

F T T T F T T T spec impl

synthesize Why a circuit language?

  • A teaching aid
  • An oracle for

testing circuit transformations in SAT

  • based

solvers

b c d b c d a a

slide-24
SLIDE 24

∀ a, b, c, d .

impl(a, b, c, d) ≡ spec(a, b, c, d)

verify

b c d b c d a a

a tiny circuit language (tcl) in racket

14

Warm up A classic DSL for testing and verification of circuits.

spec impl

slide-25
SLIDE 25

a sample tcl program

15

A circuit is a procedure that works

  • n boolean values.

(define-circuit (RBC-parity a b c d) (! (<=> (<=> a b) (<=> c d)))) #lang s-exp tcl (define-circuit (AIG-parity a b c d) (&& (! (&& (! (&& (! (&& a b)) (&& (! a) (! b)))) (! (&& (&& (! c) (! d)) (! (&& c d)))))) (! (&& (&& (! (&& a b)) (! (&& (! a) (! b)))) (&& (! (&& (! c) (! d))) (! (&& c d))))))) (verify-circuit AIG-parity RBC-parity)

slide-26
SLIDE 26

a sample tcl program

15

> (RBC-parity #f #f #t #f) #t > (AIG-parity #f #f #t #f) #t (define-circuit (RBC-parity a b c d) (! (<=> (<=> a b) (<=> c d)))) #lang s-exp tcl (define-circuit (AIG-parity a b c d) (&& (! (&& (! (&& (! (&& a b)) (&& (! a) (! b)))) (! (&& (&& (! c) (! d)) (! (&& c d)))))) (! (&& (&& (! (&& a b)) (! (&& (! a) (! b)))) (&& (! (&& (! c) (! d))) (! (&& c d))))))) (verify-circuit AIG-parity RBC-parity)

slide-27
SLIDE 27

a sample tcl program

15

(define-circuit (RBC-parity a b c d) (! (<=> (<=> a b) (<=> c d)))) #lang s-exp tcl (define-circuit (AIG-parity a b c d) (&& (! (&& (! (&& (! (&& a b)) (&& (! a) (! b)))) (! (&& (&& (! c) (! d)) (! (&& c d)))))) (! (&& (&& (! (&& a b)) (! (&& (! a) (! b)))) (&& (! (&& (! c) (! d))) (! (&& c d))))))) (verify-circuit AIG-parity RBC-parity)

And Inverter Graph (¬, ∧) Reduced Boolean Circuit (¬, ⇔)

slide-28
SLIDE 28

a sample tcl program

15

Verifies equivalence of two

n-ary circuit functions.

(define-circuit (RBC-parity a b c d) (! (<=> (<=> a b) (<=> c d)))) #lang s-exp tcl (define-circuit (AIG-parity a b c d) (&& (! (&& (! (&& (! (&& a b)) (&& (! a) (! b)))) (! (&& (&& (! c) (! d)) (! (&& c d)))))) (! (&& (&& (! (&& a b)) (! (&& (! a) (! b)))) (&& (! (&& (! c) (! d))) (! (&& c d))))))) (verify-circuit AIG-parity RBC-parity)

slide-29
SLIDE 29

1

#lang racket

3

(define-syntax-rule

4

(define-circuit (id in ...) expr)

5

(define (id in ...) expr))

a shallow embedding of tcl in racket

16

(define-circuit (RBC-parity a b c d) (! (<=> (<=> a b) (<=> c d))))

slide-30
SLIDE 30

1

#lang racket

3

(define-syntax-rule

4

(define-circuit (id in ...) expr)

5

(define (id in ...) expr))

a shallow embedding of tcl in racket

16

(define (RBC-parity a b c d) (! (<=> (<=> a b) (<=> c d))))

slide-31
SLIDE 31

1

#lang racket

3

(define-syntax-rule

4

(define-circuit (id in ...) expr)

5

(define (id in ...) expr))

a shallow embedding of tcl in racket

16

(define (RBC-parity a b c d) (! (<=> (<=> a b) (<=> c d))))

7

(define (! a) (if a #f #t))

8

(define (&& a b) (if a b #f))

9

(define (|| a b) (if a #t b))

10

(define (<=> a b) (if a b (! b)))

slide-32
SLIDE 32

1

#lang racket

3

(define-syntax-rule

4

(define-circuit (id in ...) expr)

5

(define (id in ...) expr))

a shallow embedding of tcl in racket

16

Naive exhaustive verifier.

7

(define (! a) (if a #f #t))

8

(define (&& a b) (if a b #f))

9

(define (|| a b) (if a #t b))

10

(define (<=> a b) (if a b (! b)))

12

(define (verify-circuit impl spec)

13

(define n (procedure-arity spec))

14

(for ([i (expt 2 n)])

15

(define bits (for/list ([j n]) (bitwise-bit-set? i j)))

16

(unless (eq? (apply impl bits) (apply spec bits))

17

(error "failed on" bits))))

slide-33
SLIDE 33

19

(provide

20

! && || <=> define-circuit verify-circuit

21

#%datum #%app #%module-begin #%top-interaction)

1

#lang racket

3

(define-syntax-rule

4

(define-circuit (id in ...) expr)

5

(define (id in ...) expr))

a shallow embedding of tcl in racket

16

#lang s-exp tcl

7

(define (! a) (if a #f #t))

8

(define (&& a b) (if a b #f))

9

(define (|| a b) (if a #t b))

10

(define (<=> a b) (if a b (! b)))

12

(define (verify-circuit impl spec)

13

(define n (procedure-arity spec))

14

(for ([i (expt 2 n)])

15

(define bits (for/list ([j n]) (bitwise-bit-set? i j)))

16

(unless (eq? (apply impl bits) (apply spec bits))

17

(error "failed on" bits))))

slide-34
SLIDE 34

verifying circuits with tcl

17

#lang s-exp tcl (define-circuit (RBC-parity a b c d) (! (<=> (<=> a b) (<=> c d)))) (define-circuit (AIG-parity a b c d) (&& (! (&& (! (&& (! (&& a b)) (&& (! a) (! b)))) (! (&& (&& (! c) (! d)) (! (&& c d)))))) (! (&& (&& (! (&& a b)) (! (&& (! a) (! b)))) (&& (! (&& (! c) (! d))) (! (&& c d))))))) (verify-circuit AIG-parity RBC-parity)

j failed on (#f #f #f #f)

> (RBC-parity #f #f #f #f) #f > (AIG-parity #f #f #f #f) #t

slide-35
SLIDE 35

verifying circuits with tcl

17

#lang s-exp tcl (define-circuit (RBC-parity a b c d) (! (<=> (<=> a b) (<=> c d)))) (define-circuit (AIG-parity a b c d) (&& (! (&& (! (&& (! (&& a b)) (&& (! a) (! b)))) (! (&& (&& (! c) (! d)) (! (&& c d)))))) (! (&& (&& (! (&& a b)) (! (&& (! a) (! b)))) (&& (! (&& (! c) (! d))) (! (&& c d))))))) (verify-circuit AIG-parity RBC-parity)

j failed on (#f #f #f #f)

> (RBC-parity #f #f #f #f) #f > (AIG-parity #f #f #f #f) #t

Where is the bug? How to fix it? Verify circuits with many inputs?

slide-36
SLIDE 36

1

#lang racket

3

(define-syntax-rule

4

(define-circuit (id in ...) expr)

5

(define (id in ...) expr))

7

(define (! a) (if a #f #t))

8

(define (&& a b) (if a b #f))

9

(define (|| a b) (if a #t b))

10

(define (<=> a b) (if a b (! b)))

12

(define (verify-circuit impl spec)

13

(define n (procedure-arity spec))

14

(for ([i (expt 2 n)])

15

(define bits (for/list ([j n]) (bitwise-bit-set? i j)))

16

(unless (eq? (apply impl bits) (apply spec bits))

17

(error "failed on" bits))))

19

(provide

20

! && || <=> define-circuit verify-circuit

21

#%datum #%app #%module-begin #%top-interaction)

porting tcl to rosette

18

slide-37
SLIDE 37

1

#lang racket

3

(define-syntax-rule

4

(define-circuit (id in ...) expr)

5

(define (id in ...) expr))

7

(define (! a) (if a #f #t))

8

(define (&& a b) (if a b #f))

9

(define (|| a b) (if a #t b))

10

(define (<=> a b) (if a b (! b)))

12

(define (verify-circuit impl spec)

13

(define n (procedure-arity spec))

14

(for ([i (expt 2 n)])

15

(define bits (for/list ([j n]) (bitwise-bit-set? i j)))

16

(unless (eq? (apply impl bits) (apply spec bits))

17

(error "failed on" bits))))

19

(provide

20

! && || <=> define-circuit verify-circuit

21

#%datum #%app #%module-begin #%top-interaction)

porting tcl to rosette

18

s-exp rosette

slide-38
SLIDE 38

1

#lang s-exp rosette

3

(define-syntax-rule

4

(define-circuit (id in ...) expr)

5

(define (id in ...) expr))

7

(define (verify-circuit impl spec)

8

(define input (symbolic-input spec))

9

(evaluate input (verify (correct impl spec input))))

11

(define (symbolic-input spec)

12

(for/list ([i (procedure-arity spec)])

13

(define-symbolic* b boolean?)

14

b))

16

(define (correct impl spec input)

17

(assert (eq? (apply impl input) (apply spec input))))

19

(provide

20

! && || <=> define-circuit verify-circuit

21

#%datum #%app #%module-begin #%top-interaction)

tcl with solver-aided verification (tcl+)

19

slide-39
SLIDE 39

Creates a list of fresh symbolic boolean constants to use as input to the circuits.

1

#lang s-exp rosette

3

(define-syntax-rule

4

(define-circuit (id in ...) expr)

5

(define (id in ...) expr))

7

(define (verify-circuit impl spec)

8

(define input (symbolic-input spec))

9

(evaluate input (verify (correct impl spec input))))

11

(define (symbolic-input spec)

12

(for/list ([i (procedure-arity spec)])

13

(define-symbolic* b boolean?)

14

b))

16

(define (correct impl spec input)

17

(assert (eq? (apply impl input) (apply spec input))))

19

(provide

20

! && || <=> define-circuit verify-circuit

21

#%datum #%app #%module-begin #%top-interaction)

tcl with solver-aided verification (tcl+)

19

slide-40
SLIDE 40

(verify expr) searches for an interpretation of symbolic constants that causes expr to fail.

1

#lang s-exp rosette

3

(define-syntax-rule

4

(define-circuit (id in ...) expr)

5

(define (id in ...) expr))

7

(define (verify-circuit impl spec)

8

(define input (symbolic-input spec))

9

(evaluate input (verify (correct impl spec input))))

11

(define (symbolic-input spec)

12

(for/list ([i (procedure-arity spec)])

13

(define-symbolic* b boolean?)

14

b))

16

(define (correct impl spec input)

17

(assert (eq? (apply impl input) (apply spec input))))

19

(provide

20

! && || <=> define-circuit verify-circuit

21

#%datum #%app #%module-begin #%top-interaction)

tcl with solver-aided verification (tcl+)

19

slide-41
SLIDE 41

#lang s-exp tcl+ (define-circuit (RBC-parity a b c d) (! (<=> (<=> a b) (<=> c d)))) (define-circuit (AIG-parity a b c d) (&& (! (&& (! (&& (! (&& a b)) (&& (! a) (! b)))) (! (&& (&& (! c) (! d)) (! (&& c d)))))) (! (&& (&& (! (&& a b)) (! (&& (! a) (! b)))) (&& (! (&& (! c) (! d))) (! (&& c d))))))) (verify-circuit AIG-parity RBC-parity) ’(#f #t #t #t) > (RBC-parity #f #t #t #t) #t > (AIG-parity #f #t #t #t) #f

verifying circuits with tcl+

20

slide-42
SLIDE 42

#lang s-exp tcl+ (define-circuit (RBC-parity a b c d) (! (<=> (<=> a b) (<=> c d)))) (define/debug (AIG-parity a b c d) (&& (! (&& (! (&& (! (&& a b)) (&& (! a) (! b)))) (! (&& (&& (! c) (! d)) (! (&& c d)))))) (! (&& (&& (! (&& a b)) (! (&& (! a) (! b)))) (&& (! (&& (! c) (! d))) (! (&& c d))))))) (debug-circuit AIG-parity RBC-parity ’(#f #t #t #t))

debugging circuits with tcl+ (desiderata)

21

implementation Why does the implementation differ from the specification

  • n this input?

specification

slide-43
SLIDE 43

22

(require

23

rosette/lang/debug

24

rosette/lib/tools/render)

26

(define (debug-circuit impl spec input)

27

(render

28

(debug [boolean?]

29

(correct impl spec input))))

31

(provide debug-circuit define/debug quote)

(debug [t] expr) computes a minimal set

  • f expressions of type t

that are responsible for the failure in expr.

extending tcl+ with solver-aided debugging

22

slide-44
SLIDE 44

#lang s-exp tcl+ (define-circuit (RBC-parity a b c d) (! (<=> (<=> a b) (<=> c d)))) (define/debug (AIG-parity a b c d) (&& (! (&& (! (&& (! (&& a b)) (&& (! a) (! b)))) (! (&& (&& (! c) (! d)) (! (&& c d)))))) (! (&& (&& (! (&& a b)) (! (&& (! a) (! b)))) (&& (! (&& (! c) (! d))) (! (&& c d))))))) (debug-circuit AIG-parity RBC-parity ’(#f #t #t #t))

debugging circuits with tcl+ (a minimal core)

23

Non-core (grayed-out) expressions are irrelevant to the failure: there is no way to fix the behavior of AIG- parity on the sample input by editing these expressions.

slide-45
SLIDE 45

#lang s-exp tcl+ (define-circuit (RBC-parity a b c d) (! (<=> (<=> a b) (<=> c d)))) (define-circuit (AIG-parity a b c d) (&& (Circuit [! &&] a b c d #:depth 3) (! (&& (&& (! (&& a b)) (! (&& (! a) (! b)))) (&& (! (&& (! c) (! d))) (! (&& c d))))))) (synthesize-circuit AIG-parity RBC-parity)

synthesizing circuits with tcl+ (desiderata)

24

A sketch of the desired repair. Complete the sketch so that the given circuits are equivalent on all inputs.

slide-46
SLIDE 46

(synthesize #:forall V #:guarantee expr[V, H]) searches for an interpretation of the symbolic constants H that guarantees expr will succeed for all interpretations of V.

32

(require rosette/lib/meta/meta)

34

(define (synthesize-circuit impl spec)

35

(define input (symbolic-input spec))

36

(generate-forms

37

(synthesize #:forall input

38

#:guarantee (correct impl spec input))))

40

(define-synthax (Circuit [op1 op2 ...] expr ... #:depth d)

41

#:assert (>= d 0)

42

([choose op1 identity]

43

[choose

44

expr ...

45

([choose op2 ...]

46

(Circuit [op1 op2 ...] expr ... #:depth (- d 1))

47

(Circuit [op1 op2 ...] expr ... #:depth (- d 1)))]))

49

(provide synthesize-circuit Circuit (for-syntax #%datum))

extending tcl+ with solver-aided synthesis

25

slide-47
SLIDE 47

32

(require rosette/lib/meta/meta)

34

(define (synthesize-circuit impl spec)

35

(define input (symbolic-input spec))

36

(generate-forms

37

(synthesize #:forall input

38

#:guarantee (correct impl spec input))))

40

(define-synthax (Circuit [op1 op2 ...] expr ... #:depth d)

41

#:assert (>= d 0)

42

([choose op1 identity]

43

[choose

44

expr ...

45

([choose op2 ...]

46

(Circuit [op1 op2 ...] expr ... #:depth (- d 1))

47

(Circuit [op1 op2 ...] expr ... #:depth (- d 1)))]))

49

(provide synthesize-circuit Circuit (for-syntax #%datum))

extending tcl+ with solver-aided synthesis

25

To construct a circuit, choose a unary

  • perator (or identity)

and apply it either to

  • ne of the provided

terminal expressions or to a circuit constructed using one of the given binary operators.

slide-48
SLIDE 48

#lang s-exp tcl+ (define-circuit (RBC-parity a b c d) (! (<=> (<=> a b) (<=> c d)))) (define-circuit (AIG-parity a b c d) (&& (! (&& (! (&& (! (&& a b)) (! (&& (! a) (! b))))) (! (&& (! (&& c d)) (! (&& (! c) (! d))))))) (! (&& (&& (! (&& a b)) (! (&& (! a) (! b)))) (&& (! (&& (! c) (! d))) (! (&& c d))))))) (synthesize-circuit AIG-parity RBC-parity)

synthesizing circuits with tcl+ (the repair)

26

(Circuit [! &&] a b c d #:depth 3) (! (&& (&& (! (&& a b)) (! (&& (!

slide-49
SLIDE 49

stacking interpreters to synthesize a compiler

27

TTL+ RBC AIG Z3 rax

. RBC . RBC ≡ rax(RBC)

∃ ∀

slide-50
SLIDE 50

stacking interpreters to synthesize a compiler

27

TTL+ RBC AIG Z3 rax

. RBC . RBC ≡ rax(RBC)

∃ ∀

Synthesized a rewriter from RBCs to AIGs that works for all RBCs of bounded size. Deep SDSL embedding

slide-51
SLIDE 51

web, spatial programming, superoptimization

28

slide-52
SLIDE 52

websynth: web scraping by demonstration

29

Websynth synthesizes a scraping script given a web page and a few examples

  • f desired data, using a

declarative SDSL (XPaths). Implemented by two undergraduate students in a few weeks.

Sail, AWOLNATION Diamonds, Rihanna

slide-53
SLIDE 53

websynth: web scraping by demonstration

29

Sail, AWOLNATION Diamonds, Rihanna 10 20 30 2 4 8 16 synthesis time (sec) number of examples iTunes IMBDb AlAnon

slide-54
SLIDE 54

partitioning code & data for a low power chip

30

Figure by Per Ljung

Instructions/Second vs Power

~100x

GreenArrays GA144 Processor

slide-55
SLIDE 55
  • Stack-based 18-bit architecture
  • 32 instructions
  • 8 x 18 array of asynchronous cores
  • No shared resources (cache, memory)
  • Limited communication, neighbors only
  • < 300 byte memory per core

partitioning code & data for a low power chip

30

Figure by Per Ljung

Instructions/Second vs Power

~100x

GreenArrays GA144 Processor

slide-56
SLIDE 56
  • Stack-based 18-bit architecture
  • 32 instructions
  • 8 x 18 array of asynchronous cores
  • No shared resources (cache, memory)
  • Limited communication, neighbors only
  • < 300 byte memory per core

Manual function partitioning: break functions up into a pipeline with a few operations per core.

Drawing by Mangpo Phothilimthana

partitioning code & data for a low power chip

30

Figure by Per Ljung

Instructions/Second vs Power

~100x

GreenArrays GA144 Processor

slide-57
SLIDE 57

partitioning code & data for a low power chip

31

partitioner code generator

high-level program per-core high-level programs per-core optimized machine code new programming model new approach using synthesis

Mangpo Phothilimthana Nishant Totla

slide-58
SLIDE 58

partitioning code & data for a low power chip

31

partitioner code generator

high-level program per-core high-level programs per-core optimized machine code new programming model new approach using synthesis

Mangpo Phothilimthana Nishant Totla

slide-59
SLIDE 59

partitioning code & data for a low power chip

32

Ri

256-byte mem per core initial data placement specified

106 6

K

103 3 102 104 4 105 5 2

F

M R M K

F

<<< <<<

high low

  • ne iteration of MD5 hash
  • ptimal code partitioning

(synthesized in 5 min)

Ki Mi

slide-60
SLIDE 60

(define (fast-max x y) (let* ([t1 (bvge x y]) [t2 (bvneg t1]) [t3 (bvxor y x]) [t4 (bvand t3 t2]) [t5 (bvxor y t4)]) t5)) (define-fragment (fast-max x y) #:ensures (lambda (x y result) (= result (if (> x y) x y))) #:library (bvlib [{bvneg bvge bvand} 1] [{bvxor} 2]))

component-based synthesis of loop free code

33

Gulwani et al. PLDI’11 1 10 100 1000 synthesis time (sec) Hacker’s Delight benchmarks completed timeout

slide-61
SLIDE 61

34

slide-62
SLIDE 62

34

ROSETTE

{emina, bodik}@eecs.berkeley.edu