carnegie mellon generating high performance generating
play

Carnegie Mellon Generating High Performance Generating High - PowerPoint PPT Presentation

Carnegie Mellon Generating High Performance Generating High Performance General Size Linear Transform General Size Linear Transform Libraries Using Spiral Libraries Using Spiral Yevgen Voronenko Franz Franchetti Frdric de Mesmay Markus


  1. Carnegie Mellon Generating High ‐ Performance Generating High ‐ Performance General Size Linear Transform General Size Linear Transform Libraries Using Spiral Libraries Using Spiral Yevgen Voronenko Franz Franchetti Frédéric de Mesmay Markus Püschel Carnegie Mellon University HPEC, September 2008, Lexington, MA, USA This work was supported by DARPA DESA program, NSF ‐ NGS/ITR, NSF ‐ ACR, and Intel

  2. Carnegie Mellon The Problem: Example DFT The Problem: Example DFT Best code 30x 30x 12x 12x Numerical recipes Standard desktop computer � Same operations count ≈ 4nlog 2 (n) � 2 Similar plots can be shown for all numerical problems �

  3. Carnegie Mellon DFT Plot: Analysis DFT Plot: Analysis Discrete Fourier Transform ( DFT) (on 2xCore2Duo 3 GHz) Perform ance [ Gflop/ s] 30 Multiple threads: 2x 25 20 15 Vector instructions: 3x 10 Memory hierarchy: 5x 5 0 input size � High performance library development = nightmare � Automation? 3

  4. Carnegie Mellon Idea: Textbook to Adaptive Library Idea: Textbook to Adaptive Library Textbook FFT ? ? “FFTW” 4

  5. Carnegie Mellon Goal: Teach Computers to Write Libraries Teach Computers to Write Libraries Goal: Input: Key technologies: Transform : � Layered domain specific � Algorithm : language � Hardware: 2 ‐ way SIMD + multithreaded Algorithm manipulation � � via rewriting Feedback ‐ driven search � Spiral Spiral Result: Full automation � Output: � FFTW equivalent library � For general input size � Vectorized and multithreaded � Performance competitive 5

  6. Carnegie Mellon Contribution: General Size Library Contribution: General Size Library Transform T Spiral Spiral DFT of size 1024 library for DFT of or any size Env_1 dft(1024); dft_1024(X, Y); dft.compute(X, Y); Fundamentally different problems 6

  7. Carnegie Mellon Beyond Fourier Transform and FFTW Beyond Fourier Transform and FFTW Cooley ‐ Tukey “Cooley ‐ Tukey” DCT Overlap ‐ save/add FIR FFT Spiral Spiral Spiral Spiral Spiral Spiral “FFTW” “FCTW” “FIRW” Fast Walsh Transform Fast Wavelet Transform Fast Hartley Transform Spiral Spiral Spiral Spiral Spiral Spiral “WHTW” “FWTW” “FHTW” 7

  8. Carnegie Mellon Examples of Generated Libraries Examples of Generated Libraries RDFT DHT DCT2 DCT3 DCT4 DFT • 2 ‐ way vectorized, 2 ‐ threaded • 2 ‐ way vectorized, 2 ‐ threaded • Most are faster than hand ‐ written libs • Most are faster than hand ‐ written libs • Code size: 8–120 KLOC or 0.5–5 MB • Code size: 8–120 KLOC or 0.5–5 MB • Generation time: 1–3 hours • Generation time: 1–3 hours Filter Wavelet Total: 300 KLOC / 13.3 MB of code generated in < 20 hours from a few simple algorithm specs 8 Intel IPP library 6.0 will include Spiral generated code

  9. Carnegie Mellon I. Background II. Library Generation III. Experimental Results IV. Conclusions and Future Work 9

  10. Carnegie Mellon Linear Transforms Linear Transforms � Mathematically: matrix ‐ vector product Output vector Transform matrix Input vector � Examples: 10

  11. Carnegie Mellon Fast Algorithms, Example: 4 ‐ ‐ point FFT point FFT Fast Algorithms, Example: 4 � Fast algorithms = matrix factorizations 12 adds 4 adds 1 mult 4 adds 4 mults (when multiplied with input vector � ) Fourier transform Kronecker product Identity Permutation � SPL = mathematical, declarative specification � Space of algorithms generated using breakdown rules 11

  12. Carnegie Mellon Examples of Breakdown Rules Examples of Breakdown Rules DFT Cooley ‐ Tukey DCT “Cooley ‐ Tukey” � “Teach” Spiral domain knowledge of algorithms. Never obsolete. � “Teach” Spiral domain knowledge of algorithms. Never obsolete. 12 � Each rule leads to a library � Each rule leads to a library

  13. Carnegie Mellon I. Background II. Library Generation III. Experimental Results IV. Conclusions and Future Work 13

  14. Carnegie Mellon How Library Generation Works How Library Generation Works Transforms + Library Target Breakdown rules (FFTW, VSIPL, IPP FFT, ...) Library Structure Library Structure recursion step closure as Σ‐ SPL formulas Library Implementation Library Implementation 14 High ‐ performance library

  15. Carnegie Mellon Breakdown Rules to Library Code Breakdown Rules to Library Code Cooley ‐ Tukey Fast Fourier Transform (FFT) � DFT k=4 Naive implementation � void dft ( int n, cplx X[], cplx Y[]) { k = choose_factor(n); m = n/k; Z = permute(X) for i=0 to k ‐ 1 dft_subvec (m, Z, Y, …) for i=0 to n ‐ 1 Y[i] = Y[i]*T[i]; for i=0 to m ‐ 1 dft_strided (k, Y, Y, …) } 2 extra functions needed 15

  16. Carnegie Mellon Breakdown Rules to Library Code Breakdown Rules to Library Code Cooley ‐ Tukey Fast Fourier Transform (FFT) � DFT Optimized implementation Naive implementation � � void dft ( int n, cplx X[], cplx Y[]) { void dft ( int n, cplx X[], cplx Y[]) { k = choose_factor(n); m = n/k; k = choose_factor(n); m = n/k; Z = permute(X) for i=0 to k ‐ 1 for i=0 to k ‐ 1 dft_strided2 (m, X, Y, …) dft_subvec (m, Z, Y, …) for i=0 to m ‐ 1 for i=0 to n ‐ 1 dft_strided3_scaled (k, Y, Y, T, …) Y[i] = Y[i]*T[i]; for i=0 to m ‐ 1 } dft_strided (k, Y, Y, …) } 2 extra functions needed 2 extra functions needed 16 How to discover these specialized variants automatically? How to discover these specialized variants automatically?

  17. Carnegie Mellon Library Structure Library Structure Input: � � Breakdown rules Output: � Library Structure Library Structure � Recursion step closure � Σ‐ SPL Implementation of each recursion step Parallelization/Vectorization � � Adds additional breakdown rules � Orthogonal to the closure generation 17

  18. Carnegie Mellon Computing Recursion Step Closure Computing Recursion Step Closure Input: transform T and a breakdown rule � Output: spawned recursion steps + Σ‐ SPL implementation � Algorithm: � 1. Apply the breakdown rule Convert to Σ ‐ SPL 2. 3. Apply loop merging + index simplification rules. 4. Extract recursion steps 5. Repeat until closure is reached Parametrization (not shown) derives the independent parameter set 18 for each recursion step

  19. Carnegie Mellon Recursion Step Closure Examples Recursion Step Closure Examples DFT (scalar) 4 mutually recursive functions ‐ computed automatically ‐ described using Σ‐ SPL formulas DCT4 (vectorized) 19 17 mutually recursive functions

  20. Carnegie Mellon Base Cases Base Cases � Base cases are called “codelets” in FFTW � Why needed: � Closure is converted into mutually recursive functions � Recursion must be terminated � Larger base cases eliminate overhead from recursion � How many: � In FFTW 3.2: 183 codelets for complex DFT (21 types) 147 codelets for real DFT (18 types) � In our generator: # codelet types � # recursion steps � Obtained by using standard Spiral to generate fixed size code 20 . . .

  21. Carnegie Mellon Library Implementation Library Implementation � Input: � Recursion step closure � Σ‐ SPL implementation of each recursion step (base cases + recursions) � Output: � High ‐ performance library � Target language: C++, Java, etc. Library Implementation Library Implementation � Process: � Build library plan � Perform hot/cold partitioning � Generate target language code 21 High ‐ performance library

  22. Carnegie Mellon I. Background II. Library Generation III. Experimental Results IV. Conclusions and Future Work 22

  23. Carnegie Mellon Double Precision Performance: Intel Xeon 5160 Double Precision Performance: Intel Xeon 5160 2 ‐ ‐ way vectorization, up to 2 threads way vectorization, up to 2 threads 2 Generated library Generated library FFTW Intel IPP Complex DFT Real DFT Generated library Generated library DCT ‐ 2 WHT 23

  24. Carnegie Mellon FIR Filter Performance FIR Filter Performance 2 ‐ ‐ and 4 ‐ ‐ way vectorization, up to 2 threads way vectorization, up to 2 threads 2 and 4 Generated Generated library library Intel IPP 8 ‐ tap filter 8 ‐ tap wavelet Generated Generated library library 32 ‐ tap filter 32 ‐ tap wavelet 24

  25. Carnegie Mellon 2 ‐ ‐ D Transforms Performance D Transforms Performance 2 2 ‐ ‐ or 4 ‐ ‐ way vectorization, up to 2 threads way vectorization, up to 2 threads 2 or 4 Generated library FFTW Generated library Intel IPP 2 ‐ D DFT double 2 ‐ D DFT single Generated library Generated library 2 ‐ D DCT ‐ 2 double 2 ‐ D DCT ‐ 2 single 25

  26. Carnegie Mellon Customization: Code Size Customization: Code Size 13 KLOC 3 KLOC FFTW: 150 KLOC 2 KLOC 1.3 KLOC 1 KLOC 26

  27. Carnegie Mellon Backend Customization: Java Backend Customization: Java Generated library Generated library JTransforms Complex DFT Real DFT Generated library Generated library DCT ‐ 2 FIR Filter 27 Portable, but only 50% of scalar C performance

  28. Carnegie Mellon Summary Summary FFT � Full automation: Textbook to adaptive library Spiral Spiral � Performance � SIMD “FFTW” � Multicore � Customization FIR � Industry collaboration Spiral Spiral � Intel IPP 6.0 will include Spiral generated code “FIRW” 28

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend