Detecting and Exploiting Narrow Bitwidth Computations Mihai Budiu
Detecting and Exploiting Narrow Bitwidth Computations Mihai Budiu Carnegie Mellon University mihaib@cs. cmu. edu joint work with Seth Copen Goldstein 10/02/99 Mihai Budiu -- Narrowing bitwidths - SOCS 2
Motivation: applications • Media processing • Digital Signal Processing FFT 10/02/99 Mihai Budiu -- Narrowing bitwidths - SOCS 2 2
Motivation: hardware • “MMX” + + + • CPU support for narrow widths • Reconfigurable hardware b a (a & 0 xf) | (b & 0 x 18) 10/02/99 Mihai Budiu -- Narrowing bitwidths - SOCS 2 3
Motivation • No programming language support int a; long b; • No compiler support int a; a = (a >> 16) & 0 xf 0; 10/02/99 Mihai Budiu -- Narrowing bitwidths - SOCS 2 4
Types The type of an integer value describes: • sign (signed or unsigned) • width in bits • information about each bit – bit is constant (0 or 1) – bit is don’t care (x) – cannot predict bit -- don’t know (u) 10/02/99 Mihai Budiu -- Narrowing bitwidths - SOCS 2 5
Why? • You don’t have to implement: – don’t care bits – constant bits • This may enable you to exploit hardware more efficiently, increasing performance 10/02/99 Mihai Budiu -- Narrowing bitwidths - SOCS 2 6
The Type Inference 1. Sign inference 2. Width inference (forward) 3. Width inference (backward) 4. Constant propagation (forward) 5. Don’t care discovery (backward) 10/02/99 Mihai Budiu -- Narrowing bitwidths - SOCS 2 7
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) 10/02/99 Mihai Budiu -- Narrowing bitwidths - SOCS 2 8
Constant Propagation u 00 uu u 001 u + u 0 uuu 10/02/99 Mihai Budiu -- Narrowing bitwidths - SOCS 2 9
Don’t Care Propagation xxuuu In xxuux Out + xxuux • lsb out bit from lsb in bit • msb out bit from all in bits 10/02/99 Mihai Budiu -- Narrowing bitwidths - SOCS 2 10
Mixing u 00 uu xxuuu xx 01 u u 001 u xxuuu + u 0 uuu xxuux The mixing phase just takes bitwise the best of the information provided by the two propagations. 10/02/99 Mihai Budiu -- Narrowing bitwidths - SOCS 2 11
Circuit Reduction for Reconfigurable Hardware 10/02/99 Mihai Budiu -- Narrowing bitwidths - SOCS 2 12
C Program Size Reduction G 721 from Mediabench 10/02/99 Mihai Budiu -- Narrowing bitwidths - SOCS 2 14
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) 10/02/99 Mihai Budiu -- Narrowing bitwidths - SOCS 2 15
- Slides: 14