haskell accelerate

Download Haskell  Accelerate

Post on 03-Jul-2015




3 download

Embed Size (px)


My slides from Haskell Hackers at Hacker Dojo on 10/16/2014.


  • 1. GPU Programming withHaskellSteve Severancesseverance@alphaheavy.com

2. OutlineIntroduction to GPUsWhen to use a GPU instead of a CPUUsing a GPU with accelerateBuilding an options pricer 3. What is a GPU?Graphics Processing UnitHundreds or Thousands of CoresHigh Memory ThroughputFully Programmable 4. GPU ArchitectureSingle Instruction Multiple Data (SIMD)High Throughput Thread SchedulerInterleaving Operations 5. GPU Architecture16GB/sGPU CPU Memory 6. GPU Circa 1999Geforce 256Accelerated Graphics Port (AGP)Hardware Transform and Lighting (TnL)Fixed Function Pipeline 7. GPU Circa 2001Geforce 3/R200/XBoxFirst Pixel/Vertex ShadersLimited C-like Language 8. GPU Circa 2014Fully ProgrammableUnified MemoryRich High Level Languages/Tools 9. GPU TradeoffsLimited branchingLimited MemoryHigh Latency 10. GPU vs CPUGPU is about throughputCPU is about flexibility and latency 11. ProgrammabilityCUDAOpenCLDirectCompute 12. GPU ProblemsNon-branching algorithmsMatrix (cudaBLAS)Deep LearningOptions Pricing 13. Can I run GPU Programs?accelerate requires CUDAOpenCL is a low level OpenCL wrapperNVidia CUDA Tools (https://developer.nvidia.com/cuda-toolkit) 14. Introducing AccelerateDSL for Parallel CodePrimarily CUDA, Also LLVMCompiler lowers into CUDA code 15. Accelerate BasicsAcc is our DSL type. Holds the Abstract Syntax Tree(AST) of our computationFamiliar operators replace Prelude (fold,map,zip,etc) 16. Accelerate BasicsCreating a ComputationAcc (Array DIM1 Float) -> Acc (Array DIM1 Float)Running a Computationrun :: Arrays a => Acc a -> a 17. Arraysdata Array sh eComprised of both a Shape and an Element (Elt)Elt instances for common numeric types and tuplesArrays can be multi-dimensional, but not nested 18. Array ShapesZ is a Rank-0:. Operator Increases the Rank by One DimensionDIM1, DIM2, DIM3, etc 19. ComputationsAcc is a computation on an arrayExp is a computation on an elementExp can also be used to pass constants 20. What run is going to doCompile our ProgramCopy Data to GPUExecute ProgramCopy Results Back to Memory 21. Black-SholesPartial Differential Equation to Compute the Price of anOptionMassive Performance Boost on a GPUBloomberg Uses GPUs to compute Options Prices 22. Black-Sholes EquationStolen from investopedia.com 23. Code/Demo Time 24. Summarylift/unliftuse adds an Array to the computationconstant wraps constantsmap does what map always does 25. What next?accelerate has a rich APISlicesAggregationRecursionStencils 26. ThanksNathan HowellThe accelerate TeamYou for listening 27. Further Readinghttps://speakerdeck.com/tmcdonell/gpgpu-programming-in-haskell-with-acceleratehttp://hackage.haskell.org/package/acceleratehttp://quantlib-gpu.sourceforge.net/AcceleratingFinancialApplicationsOnTheGPU-paper.pdf