OpenCL Programming Guide

OpenCL Programming Guide

By Aaftab Munshi, Benedict R Gaster, Timothy G. Mattson, James Fung, Dan Ginsburg

Addison-Wesley Professional; 1 edition (July 25, 2011)
ISBN-10: 0321749642

Buying Information

Key Features (includes)

  • Understanding OpenCL’s core models, concepts, terminology, goals, and rationale
  • Discovering and preparing available resources
  • Programming with OpenCL C, its built-in functions, and runtime API
  • Using buffers, sub-buffers, images, samplers, and events
  • Sharing and synchronizing data with OpenGL and Microsoft’s Direct3D
  • Simplifying development with the C++ Wrapper API
  • Using OpenCL Embedded Profiles to support devices ranging from cellphones to supercomputer nodes
  • Building complete applications: image histograms, edge detection filters, physics simulations, Fast Fourier Transforms, optical flow, and more
  • Using OpenCL with PyOpenCL, including issues in porting from C++ to Python
  • Performing matrix multiplication and high-performance sparse matrix multiplication

Description

Using the new OpenCL (Open Computing Language) standard and framework, you can write applications that access all available programming resources: CPUs, GPUs, accelerators, and even external processors. Already implemented by Apple, ATI, NVIDIA, and other leaders, OpenCL has outstanding potential for PCs, servers, handheld/embedded devices, high-performance computing, and even cloud systems. This is the first comprehensive, authoritative, and practical guide to OpenCL 1.1 specifically for working developers and software architects.

Authored by five leading OpenCL authorities, OpenCL Programming Guide covers the entire specification. It reviews key use cases, shows how OpenCL can express a wide range of parallel algorithms, and offers complete reference material on both the API and OpenCL C programming language.

Through complete case studies and downloadable code examples, the authors show how to write complex parallel programs that decompose workloads across many different devices. They also present all the essentials of OpenCL software performance optimization, including probing and adapting to hardware.

Code Samples

The book contains an wide selection of code samples, covering API usage, OpenCL C development, to full sample applications covering the OpenCL 1.1 specification. To support the open development of these samples and allow additions over time they are hosted as Google Code project: opencl-book-samples.

Errors

Please email errors and other comments to errors@openclprogramminguide.com and enter errata into the “Issues” list Google Code project: opencl-book-samples.

Readership

Software engineers, programmers, hardware engineers, students / advanced students

Contents

Table of Contents

  1. Introduction to OpenCL
  2. HelloWorld: An OpenCL Example
  3. Platforms, Contexts, and Devices
  4. Programming with OpenCL C
  5. OpenCL C Built-in Functions
  6. Programs and Kernels
  7. Buffers and Sub-Buffers
  8. Images and Samplers
  9. Events
  10. Iteroperability with OpenGL
  11. Iteroperability with Direct3D
  12. C++ Wrapper API
  13. OpenCL Embedded Profile
  14. Image Histogram
  15. Sobel Edge Detection Filter
  16. Parallelizing Dikjstra’s Single Source Shortest Path Graph Algorithm
  17. Coth Simulation in the Bullet Physics SDK
  18. Simulating the Ocean with Fast Fourier Transform
  19. Optical Flow
  20. Using OpenCL with PyOpenCL
  21. Matrix Multiplication with OpenCL
  22. Sparse Matrix-vector Multiplication
  23. Appendix
    1. Summary of OpenCL 1.1

Author Information

Aaftab Munshi is the spec editor for the OpenGL ES 1.1, OpenGL ES 2.0 and OpenCL specifications andco-author of the book OpenGL ES 2. 0 Programming Guide (with Dan Ginsburg and Dave Shreiner, AddisonWesley). He currently works at Apple.

Benedict R. Gaster is a software architect working on programming models for next-generation heterogeneousprocessors, in particular looking at high-level abstractions for parallel programming on the emerging class ofprocessors that contain both CPUs and accelerators such as GPUs. Benedict has contributed extensively to theOpenCL’s design and has represented AMD at the Khronos Group open standard consortium. Benedict has a Ph.D in computer science for his work on type systems for extensible records and variants. He has beenworking at AMD since 2008.

Tim Mattson is an old-fashioned parallel programmer starting in the mid-80’s with the Caltech Cosmic Cubeand continuing up to the present. Along the way, he has worked with most classes of parallel computer (vectorsupercomputers, SMP, VLIW, NUMA, MPP, clusters, and many-core processors). Tim has published extensively including the books Patterns for Parallel Programming (with Beverly Sanders and Berna Massingill, Addison Wesley, 2004) and An Introduction to Concurrency in Programming Languages (with Matthew J.Sottile and Craig E Rasmussen, CRC Press, 2009). Tim has a Ph.D. in chemistry for his work on molecularscattering theory. He has been working at Intel since 1993.

Dan Ginsburg currently works at Children’s Hospital Boston as a Principal Software Architect in the Fetal-Neonatal Neuroimaging and Development Science Center where he uses OpenCL for accelerating neuroimaging algorithms. Previously, he worked for Still River Systems developing GPU-accelerated image registration software for the Monarch 250 proton beam radiotherapy system. Dan was also Senior Member ofTechnical Staff at AMD, where he worked for over eight years in a variety of roles, including the developmentof OpenGL drivers, the creation of desktop and handheld 3D demos, and leading the development of handheld GPU developer tools. Dan holds a B.S. in computer science from Worcester Polytechnic Institute and anM.B.A. from Bentley University.

James Fung has been developing computer vision on the GPU as it progressed from graphics to general purposecomputation. James has a Ph.D. in Electrical and Computer Engineering from the University of Toronto andnumerous IEEE and ACM publications in the areas of parallel GPU Computer Vision and Mediated Reality.He is currently a Developer Technology Engineer at NVIDIA where he examines computer vision and imageprocessing on graphics hardware.