21
Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

  • View
    220

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Sketching high-performance implementations of bitstream programs.

Armando Solar-Lezama, Rastislav BodikUC Berkeley

Page 2: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Bitstream programs

• bitstream programs: a growing domain– crypto, compression, NSA/BitTwiddle, coding in general.

• bitstream algorithms easy to state– e.g., “Drop every third bit in the bit stream.”

• but bitstream programs hard to implement – because efficient bit manipulations are hard to code

• Can only work with word-size arrays of bits • Exponentially many ways of accomplishing the same task

SLOW O(n) FAST O(log n)

Page 3: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Current development process

• A collaborative experience:1. domain expert writes a high-level algorithm, in

C/Fortran,2. system expert tunes its performance, often drastically

turning the algorithm into ugly low-level code.

• Now, if the original algorithm needs to be modified: – introduce changes into optimized code (error-prone),

or– rewrite the algorithm and repeat tuning (time-

consuming).

Page 4: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Our development process

• A (better) collaborative experience:1.domain expert writes a clean algorithm, in a clean DSL,2.system expert optimizes the implementation by writing a

(reusable) transformation specification in a TSL.

• If the original algorithm is modified, then – simply reapply the transformation specification.

• The transformation spec: think of it as …– sequence of program edits, or– high level description of the desired implementation, or– an optimizer tailored to the algorithm

Page 5: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Challenges, and our solution (overview)

1. How to make the transformation reusable?– Transformation should apply after the algorithm changes.

2. How to simplify transformation development?– Should be much easier than editing the program by hand.– Should not allow you to introduce bugs

Our solution: a transformation sketch– system expert sketches the transformation,– details filled in automatically.

functionality sketch

?? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

full implementation

+

DSL: StreamIt TSL: transf. specTSL with sketching

Page 6: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

DSL: StreamIt

• High-level bitstream algorithms written in StreamIt.

• Example: “drop every third bit”.

filter dropThird { Work push 2 pop 3 { for (int i=0; i<3; ++i) { x = peek(i); if (i<2) push(x); pop(); } }}

1 0 00 1 03

2

consumes a 3-bit chunk of input;produces a 2-bit of output.

xyz

xy

x =

Page 7: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

The development strategy

• We offer several methods for “lowering” filters into low-level form (i.e., for implementing them with target code):

1. Manual-transformation: M(P) For any filter P, the system expert could manually write a TSL spec to make P low level.

2. Auto-transformation: N(P) For any filter P, the system knows how to produce a naïve lowering TSL spec N. • N is thus a simple code generator for P

Page 8: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Transforming into low-level form (1)

1 0 00 1 0

• unroll 4x to make input/output a multiple of W=4 bits.

3

2

1 0 0 0 0 0 0 0 0 0 0 00 1 0 0 0 0 0 0 0 0 0 00 0 0 1 0 0 0 0 0 0 0 00 0 0 0 1 0 0 0 0 0 0 00 0 0 0 0 0 1 0 0 0 0 00 0 0 0 0 0 0 1 0 0 0 00 0 0 0 0 0 0 0 0 1 0 00 0 0 0 0 0 0 0 0 0 1 0

12

8

Page 9: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Transforming into low-level form (2)• decompose into filters operating on W=4 bits of

input.

1 0 0 0 0 0 0 0 0 0 0 00 1 0 0 0 0 0 0 0 0 0 00 0 0 1 0 0 0 0 0 0 0 00 0 0 0 1 0 0 0 0 0 0 00 0 0 0 0 0 1 0 0 0 0 00 0 0 0 0 0 0 1 0 0 0 00 0 0 0 0 0 0 0 0 1 0 00 0 0 0 0 0 0 0 0 0 1 0

rrobin 4,4,4

1 0 0 0 0 1 0 00 0 0 10 0 0 00 0 0 00 0 0 00 0 0 00 0 0 0

0 0 0 00 0 0 00 0 0 01 0 0 0 0 0 1 00 0 0 10 0 0 00 0 0 0

or

0 0 0 00 0 0 00 0 0 00 0 0 00 0 0 00 0 0 00 1 0 00 0 1 0

4

8

12

8

Page 10: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Transforming into low-level form (3)• decompose into filters producing W=4 bits of

output.

rrobin 4,4,4

1 0 0 0 0 1 0 00 0 0 10 0 0 00 0 0 00 0 0 00 0 0 00 0 0 0

0 0 0 00 0 0 00 0 0 01 0 0 0 0 0 1 00 0 0 10 0 0 00 0 0 0

or

0 0 0 00 0 0 00 0 0 00 0 0 00 0 0 00 0 0 00 1 0 00 0 1 0

rrobin 4,4,4

1 0 0 0 0 1 0 00 0 0 10 0 0 0

0 0 0 00 0 0 00 0 0 01 0 0 0 0 0 1 00 0 0 10 0 0 00 0 0 0

or

0 0 0 00 0 0 00 0 0 00 0 0 00 0 0 00 0 0 00 1 0 00 0 1 0

0 0 0 00 0 0 00 0 0 00 0 0 0

duplicate

cat

Page 11: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Implementing a basic filter (4)

• decompose word-size filter into available instructions.

1 0 0 0 0 1 0 00 0 0 10 0 0 0

1 0 0 0 0 1 0 00 0 0 00 0 0 0

0 1 0 00 0 1 00 0 0 10 0 0 0

duplicate

or

0 0 0 00 0 0 00 0 1 00 0 0 0

t1 = in AND 1100

t2 = in SHIFTL 1

t3 = t2 AND 0010

out = t1 OR t3

in

Page 12: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

The development strategy

• We offer several methods for “lowering” filters into low-level form (i.e., for implementing them with target code):

1. Manual-transformation: M(P) For any filter P, the filter system expert could manually bring it to low level form.

2. Auto-transformation: N(P) For any filter P, the system knows how to produce a naïve lowering TSL spec N. • N is thus a simple code generator for P

3. Half-way transformation. N(T(P)) System expert provides a spec T that transforms P so that N generates better code.• If written well, T brings P closer to low-level code (gives it a good

structure) so that N can do a perfect job generating the code.

Page 13: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Half way transformations

• The expert guides lowering by imparting structure to the filter– If the system expert has an algorithm in mind to

implement a particular filter, the expert can decompose the filter into a sequence of filters, each one implementing one step of the algorithm.

• So, specifying an efficient bit manipulation often boils down to specifying a decomposition of the filter’s matrix.– filter = filter1 x filter2

• This can be done hierarchically,– Detail is only added where necessary.

Page 14: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

F.F_1

Half way transformations-example

• System Expert provides high level decomposition

• System Takes care of Lowering F.F_1, F.F_2 and F.F_3

• Correctness is guaranteed as long as F = [F.F_3]x[F.F_2]x[F.F_1]

• Fully Specifying F.F._1, F.F_2 and F.F_3 is still too difficult. We would like to be able to sketch them

1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 1 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 1 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 1 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 1 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 1 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 1 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 1 0 00 0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 1 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 1 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 1 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 1 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0

F

F.F_2

F.F_3

F.F_1

F.F_2

F.F_3

Half way transformation to specify FAST bit shifting algorithm

Page 15: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

The development strategy

• We offer several methods for “lowering” filters into low-level form (i.e., for implementing them with target code):

1. Manual-transformation: M(P) For any filter P, the filter system expert could manually bring it to low level form.

2. Auto-transformation: N(P) For any filter P, the system knows how to produce a naïve lowering TSL spec N.

• N is thus a simple code generator for P

3. Half-way transformation. N(T(P)) System expert provides a spec T that transforms P so that N generates better code.

• If written well, T brings P closer to low-level code (gives it a good structure) so that N can do a perfect job generating the code.

4. Half-specified transformation. N(s[T](P)) System expert provides a sketch of a transformation T.

• The compiler completes the sketch by requiring that the completed transformation (s[T]) produces a filter semantically equivalent to P.

Page 16: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Sketching a transformation

• A transformation sketch:– Specifies the number of stages in the decomposition– Gives constraints on terms of the decomposition– System derives a decomposition satisfying the

constraints and semantically equivalent to original filter

• Example. A fragment of TSL for FAST compaction:

filter = [shift(1:16 by 0 || 1)] x [shift(1:16 by 0 || 2)] x [shift(1:16 by 0 || 4)]functionality

sketch

?? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

full implementation

Page 17: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Complete TSL spec for FAST

WSIZE=16;subsequence = Unroll[WSIZE](subsequence); subsequence = PermutFactor[ [shift(1:2 by 0), shift(17:18 by 0), shift(33:34

by 0)], [shift(1:16 by ?), shift(17:32 by ?), shift(33:48

by ?)] ] ( subsequence );

subsequence.subsequence_1=DiagSplit[WSIZE](subsequence);

for(i=0; i<3; ++i) {bsequence.subsequence_1.filter(i) =

PermutFactor[ [shift(1:16 by 0 || 1)], [shift(1:16 by 0 || 2)], [shift(1:16 by 0 || 4)] ]( subsequence.subsequence_1.filter(i) );}

Size: 13 lines

Page 18: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Reusability of the TSL specs

• A TSL spec is reusable under a given change to the program if the changed program can still be profitably transformed with the TSL spec.

• Experiment:1. Start with the program P = “drop every third bit”,2. Write the FAST spec for it,3. Modify P to “drop the second bit in each three bits.”

• no change in the original TSL spec needed.

4. Modify P to “drop every fourth bit”.• Only minor change in the TSL spec needed.

Page 19: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Performance Gain: bit compaction• On a pentium III processor running at 1.5 GHz,

the unoptimized code took 0.068 seconds to process .127 Mb of data 100 times.

• On the same machine, optimized version took 0.041 seconds, a performance gain of 39%.

Page 20: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Performance Gain: Permutation from DES

• On the same machine the unoptimized code took .102 seconds to process the same amount of data.

• After a simple TSL specificationDESIP=PermutFactor[ [ shift(1:2:31 by -33), shift(2:2:32 by 0),               shift(33:2:63 by 0), shift(34:2:64 by 33) ],[]](DESIP);

• Optimized version took .073 seconds, a speedup of 28%

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Page 21: Sketching high-performance implementations of bitstream programs. Armando Solar-Lezama, Rastislav Bodik UC Berkeley

Conclusions

• Our system allows the separation of the algorithm specification from performance tuning through the use of TSL

• System expert only needs to specify high level transformations, system can take care of the details

• Sketching the transformations makes them reusable and easier to write.