140 likes | 325 Views
Detecting and Exploiting Narrow Bitwidth Computations. Mihai Budiu Carnegie Mellon University mihaib@cs.cmu.edu joint work with Seth Copen Goldstein. Motivation: applications. Media processing Digital Signal Processing. FFT. Motivation: hardware. “MMX”
E N D
Detecting and Exploiting Narrow Bitwidth Computations Mihai Budiu Carnegie Mellon University mihaib@cs.cmu.edu joint work with Seth Copen Goldstein
Motivation: applications • Media processing • Digital Signal Processing FFT Mihai Budiu -- Narrowing bitwidths -- SOCS2
Motivation: hardware • “MMX” • CPU support for narrow widths • Reconfigurable hardware + + + + + b a (a & 0xf) | (b & 0x18) Mihai Budiu -- Narrowing bitwidths -- SOCS2
Motivation • No programming language support • No compiler support int a; long b; int a; a = (a >> 16) & 0xf0; Mihai Budiu -- Narrowing bitwidths -- SOCS2
Types The type of an integer value describes: • sign (signed or unsigned) • width in bits • information about each bit • bit is constant (0or1) • bit is don’t care (x) • cannot predict bit -- don’t know (u) Mihai Budiu -- Narrowing bitwidths -- SOCS2
Why? • You don’t have to implement: • don’t care bits • constant bits • This may enable you to exploit hardware more efficiently, increasing performance Mihai Budiu -- Narrowing bitwidths -- SOCS2
The Type Inference 1. Sign inference 2. Width inference (forward) 3. Width inference (backward) 4. Constant propagation (forward) 5. Don’t care discovery (backward) Mihai Budiu -- Narrowing bitwidths -- SOCS2
The Type Inference Algorithms(from 10000 feet) • Forms of abstract interpretation • I/O values are assigned types conservatively • Iterate until a fixed-point is reached • “Data-flow at the bit level” • Low complexity O(n^2 w) . Mihai Budiu -- Narrowing bitwidths -- SOCS2
Constant Propagation u00uu u001u + u0uuu Mihai Budiu -- Narrowing bitwidths -- SOCS2
Don’t Care Propagation xxuuu xxuuu xxuuu In + Out xxuux xxuux • lsb out bit from lsb in bit • msb out bit from all in bits Mihai Budiu -- Narrowing bitwidths -- SOCS2
Mixing u00uu u001u xx0uu xx01u xxuuu xxuuu + u0uuu xxuux xxuux The mixing phase just takes bitwise the best of the information provided by the two propagations. Mihai Budiu -- Narrowing bitwidths -- SOCS2
Circuit Reduction forReconfigurable Hardware Mihai Budiu -- Narrowing bitwidths -- SOCS2
C Program Size Reduction G721 from Mediabench Mihai Budiu -- Narrowing bitwidths -- SOCS2
Conclusions • Finding useless bits in a computation as a type inference problem • Efficient algorithms exhibited (data-flow analysis) • Big performance gain for reconfigurable hardware benchmarks (up to 95%) • Effective even for C programs (e.g. 7% dynamic size reduction) Mihai Budiu -- Narrowing bitwidths -- SOCS2