























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























The Problem Again reasonable implementation (Numerical recipes. GNU scientific library) Intel vendor library (hand-optimized assembly code) but also FFTW, SPIRAL generated code 10 x DFT size Writing fast numerical code is a tough problem
Moore’s Law
source: Scientific American, Nov 2004, p. 98 Moore’s Law: Consequences
Implementation Level
Algorithm Level
Common Philosophy a new breed of domain-aware approaches/tools push automation beyond what is currently possible applies for software and hardware design alike
one algorithm and program SPIRAL www.spiral.net Team: James C. Hoe (ECE, CMU) Jeremy Johnson (CS, Drexel) José M. F. Moura (ECE, CMU) David Padua (CS, UIUC) Markus Püschel (ECE, CMU) Manuela Veloso (CS, CMU) Robert W. Johnson (Quarry Comp. Inc.) Christoph Überhuber (Math, TU Wien Sponsors: DARPA NSF ACR- 0234293 NSF ITR/NGS- 0325687 and: Cylab, CMU Austrian Science Fund Intel ITRI, Taiwan ENSCO, Inc. Students/PostDocs: Bryan W. Singer (CS, CMU) Jianxin Xiong (CS, UIUC) Srinivas Chellappa (ECE, CMU) Franz Franchetti (ECE, CMU, before TU Vienna) Aca Gacic (ECE, CMU) Yevgen Voronenko (ECE, CMU) Anthony Breitzman (CS, Drexel) Kang Chen (CS, Drexel) Pinit Kumhom (ECE, Drexel) Adam Zelinski (ECE, CMU) Peter Tummeltshammer (CS, TU Vienna) … ~ 40 Publications Overview paper: Markus Püschel, José M. F. Moura, Jeremy Johnson, David Padua, Manuela Veloso, Bryan Singer, Jianxin Xiong, Franz Franchetti, Aca Gacic, Yevgen Voronenko, Kang Chen, Robert W. Johnson, and Nick Rizzolo, SPIRAL: Code Generation for DSP Transforms, Proceedings of the IEEE
Spiral
Code Generation and Tuning as Optimization Problem a DSP transform to be implemented the target platform set of possible implementations of T on P cost of implementation I of T on P The implementation of T that is tuned to P is given by: Problems:
DSP Algorithms: Example 4 - point DFT Cooley/Tukey FFT (size 4 ): ! mathematical notation exhibits structure: SPL (signal processing language) ! Suitable for computer representation ! contains all information to generate code
4 2 2 2 4 DFT 4 (^) =( DFT 2 " I 2 )! T 2 !( I " DFT )! L Fourier transform Identity Permutation Diagonal matrix (twiddles) Kronecker product SPL: Definition (BNF)
DSP Algorithms: Spiral Terminology
DFT (^) nm #^ ( D^ FTn " Im )!^ D !( I^ n " DFTm )^! P DFT 8 = ( F 2 " I 4 )! D !( I 2 "( I 2 " F 2 L))! P parameterized matrix
DFT 2 DFT 4 DFT 2 DFT 2
Formula- (Algorithm) generation
Remaining task (many possibilities) Set of Algorithms
expanded
space:
**k 1 2 3 4 5 6 7 8 9
1 6 40 296 27744 162570361280 ~1.01 • 10^ ~2.31 • 10^ ~2.86 • 10^
1 10 126 31242 1924443362 7343815121631354242 ~1.07 • 10^ ~2.30 • 10^ ~1.06 • 10^**
From Algorithm (Formula) to Optimized Algorithm Input: Fast algorithm as formula Output: Optimized formula Domain Knowledge II: Optimizing an algorithm Motivation: Loop Fusion **void I 4 xF 2 _L 84 (double *y, double x) { double t[ 8 ]; for (int i= 0 ; i< 8 ; i++) t[i== 7? 7 : (i 4 )% 7 ] = x[i]; for (int i= 0 ; i< 4 ; i++){ y[ 2 *i] = t[ 2 *i] + t[ 2 *i+ 1 ]; y[ 2 *i+ 1 ] = t[ 2 *i] - t[ 2 *i+ 1 ]; } } void I 4 xF 2 _L 84 (double *y, double *x) { for (int j= 0 ; j< 4 ; j++){ y[ 2 j] = x[j] + x[j+ 4 ]; y[ 2 j+ 1 ] = x[j] - x[j+ 4 ]; } } direct code generation no compiler does that Solution: !-SPL and Formula manipulation
Loop Fusion Beyond Cooley-Tukey Main DFT recursion (breakdown rules): rather cheap expensive very expensive
Example
Example (cont’d)
Example (cont’d)
Implementation of Formula Generation and Manipulation
From Optimized Algorithm (Formula) to Code Input: Optimized formula Output: Intermediate Code
From Code to Optimized Code Input: Intermediate Code Output: Optimized C code Code Level Optimizations
Search (Learning) for the Best Input: Performance Number Output: Controls Formula Generation Controls Implementation Options Search Methods ! Search over: ! Algorithmic degrees of freedom (choice of breakdown rules) ! Implementation degrees of freedom (degree of unrolling) ! Operates with the ruletree representation of an algorithm ! transform independent ! efficient ! Search Methods ! Exhaustive Search ! Dynamic Programming (DP) ! Random Search ! Hill Climbing ! STEER (an evolutionary algorithm)
STEER: Evolutionary Search Population n: Population n+1: …… …… Mutation Cross-Breeding expand differently swap expansions Survival of Fittest Learning
one size); represent algorithms by features
design rules
processes)
across sizes ( 2 ^ 12 - 2 ^ 18 ) Bryan Singer and Manuela Veloso Learning to Construct Fast Signal Processing Implementations Journal of Machine Learning Research, 2002 , Vol. 3 , pp. 887 - 919