OpenCL Programming by Example


OpenCL Programming by Example
eBook: $32.99
Formats: PDF, PacktLib, ePub and Mobi formats
$28.04
save 15%!
Print + free eBook + free PacktLib access to the book: $87.98    Print cover: $54.99
$54.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Reviews
Support
Sample Chapters
  • Learn about all of the OpenCL Architecture and major APIs.
  • Learn OpenCL programming with simple examples from Image Processing, Pattern Recognition and Statistics with detailed code explanation.
  • Explore several aspects of optimization techniques, with code examples to guide you through the process
  • Understand how to use OpenCL in your problem domains

Book Details

Language : English
Paperback : 304 pages [ 235mm x 191mm ]
Release Date : December 2013
ISBN : 1849692343
ISBN 13 : 9781849692342
Author(s) : Ravishekhar Banger, Koushik Bhattacharyya
Topics and Technologies : All Books


Table of Contents

Preface
Chapter 1: Hello OpenCL
Chapter 2: OpenCL Architecture
Chapter 3: OpenCL Buffer Objects
Chapter 4: OpenCL Images
Chapter 5: OpenCL Program and Kernel Objects
Chapter 6: Events and Synchronization
Chapter 7: OpenCL C Programming
Chapter 8: Basic Optimization Techniques with Case Studies
Chapter 9: Image Processing and OpenCL
Chapter 10: OpenCL-OpenGL Interoperation
Chapter 11: Case studies – Regressions, Sort, and KNN
Index
  • Chapter 1: Hello OpenCL
    • Advances in computer architecture
    • Different parallel programming techniques
      • OpenMP
      • MPI
      • OpenACC
      • CUDA
        • CUDA or OpenCL?
      • Renderscripts
      • Hybrid parallel computing model
    • Introduction to OpenCL
      • Hardware and software vendors
        • Advanced Micro Devices, Inc. (AMD)
        • NVIDIA®
        • Intel®
        • ARM Mali™ GPUs
    • OpenCL components
    • An example of OpenCL program
      • Basic software requirements
        • Windows
        • Linux
      • Installing and setting up an OpenCL compliant computer
      • Installation steps
        • Installing OpenCL on a Linux system with an AMD graphics card
        • Installing OpenCL on a Linux system with an NVIDIA graphics card
        • Installing OpenCL on a Windows system with an AMD graphics card
        • Installing OpenCL on a Windows system with an NVIDIA graphics card
        • Apple OSX
        • Multiple installations
        • Implement the SAXPY routine in OpenCL
    • Summary
    • References
  • Chapter 2: OpenCL Architecture
    • Platform model
      • AMD A10 5800K APUs
      • AMD Radeon™ HD 7870 Graphics Processor
      • NVIDIA® GeForce® GTC 680 GPU
      • Intel® IVY bridge
    • Platform versions
      • Query platforms
      • Query devices
    • Execution model
      • NDRange
      • OpenCL context
      • OpenCL command queue
    • Memory model
      • Global memory
      • Constant memory
      • Local memory
      • Private memory
    • OpenCL ICD
      • What is an OpenCL ICD?
    • Application scaling
    • Summary
  • Chapter 3: OpenCL Buffer Objects
    • Memory objects
    • Creating subbuffer objects
    • Histogram calculation
      • Algorithm
        • OpenCL Kernel Code
        • The Host Code
    • Reading and writing buffers
      • Blocking_read and Blocking_write
      • Rectangular or cuboidal reads
    • Copying buffers
    • Mapping buffer objects
    • Querying buffer objects
    • Undefined behavior of the cl_mem objects
    • Summary
  • Chapter 4: OpenCL Images
    • Creating images
      • Image format descriptor cl_image_format
      • Image details descriptor cl_image_desc
      • Passing image buffers to kernels
    • Samplers
    • Reading and writing buffers
    • Copying and filling images
    • Mapping image objects
    • Querying image objects
    • Image histogram computation
    • Summary
  • Chapter 5: OpenCL Program and Kernel Objects
    • Creating program objects
      • Creating and building program objects
      • OpenCL program building options
      • Querying program objects
      • Creating binary files
      • Offline and online compilation
      • SAXPY using the binary file
      • SPIR – Standard Portable Intermediate Representation
    • Creating kernel objects
      • Setting kernel arguments
      • Executing the kernels
      • Querying kernel objects
      • Querying kernel argument
      • Releasing program and kernel objects
      • Built-in kernels
    • Summary
  • Chapter 6: Events and Synchronization
    • OpenCL events and monitoring these events
    • OpenCL event synchronization models
      • No synchronization needed
        • Single device in-order usage
      • Synchronization needed
        • Single device and out-of-order queue
        • Multiple devices and different OpenCL contexts
        • Multiple devices and single OpenCL context
    • Coarse-grained synchronization
    • Event-based or fine-grained synchronization
    • Getting information about cl_event
    • User-created events
    • Event profiling
    • Memory fences
    • Summary
  • Chapter 7: OpenCL C Programming
    • Built-in data types
      • Basic data types and vector types
      • The half data type
      • Other data types
      • Reserved data types
      • Alignment of data types
      • Vector data types
      • Vector components
    • Aliasing rules
    • Conversions and type casts
      • Implicit conversion
      • Explicit conversion
      • Reinterpreting data types
    • Operators
      • Operation on half data type
    • Address space qualifiers
      • __global/global address space
      • __local/local address space
      • __constant/constant address space
      • __private/private address space
      • Restrictions
    • Image access qualifiers
      • Function attributes
      • Data type attributes
      • Variable attribute
    • Storage class specifiers
    • Built-in functions
      • Work item function
      • Synchronization and memory fence functions
      • Other built-ins
    • Summary
  • Chapter 8: Basic Optimization Techniques with Case Studies
    • Finding the performance of your program?
      • Explaining the code
      • Tools for profiling and finding performance bottlenecks
    • Case study – matrix multiplication
      • Sequential implementation
      • OpenCL implementation
      • Simple kernel
      • Kernel optimization techniques
    • Case study – Histogram calculation
    • Finding the scope of the use of OpenCL
    • General tips
    • Summary
  • Chapter 9: Image Processing and OpenCL
    • Image representation
    • Implementing image filters
      • Mean filter
      • Median filter
      • Gaussian filter
      • Sobel filter
    • OpenCL implementation of filters
      • Mean and Gaussian filter
      • Median filter
      • Sobel filter
    • JPEG compression
      • Encoding JPEG
      • OpenCL implementation
    • Summary
    • References
  • Chapter 10: OpenCL-OpenGL Interoperation
    • Introduction to OpenGL
    • Defining Interoperation
    • Implementing Interoperation
      • Detecting if OpenCL-OpenGL Interoperation is supported
      • Initializing OpenCL context for OpenGL Interoperation
      • Mapping of a buffer
      • Listing Interoperation steps
      • Synchronization
      • Creating a buffer from GL texture
      • Renderbuffer object
    • Summary

Ravishekhar Banger

Ravishekhar Banger calls himself a "Parallel Programming Dogsbody". Currently he is a specialist in OpenCL programming and works for library optimization using OpenCL. After graduation from SDMCET, Dharwad, in Electrical Engineering, he completed his Masters in Computer Technology from Indian Institute of Technology, Delhi. With more than eight years of industry experience, his present interest lies in General Purpose GPU programming models, parallel programming, and performance optimization for the GPU. Having worked for Samsung and Motorola, he is now a Member of Technical Staff at Advanced Micro Devices, Inc. One of his dreams is to cover most of the Himalayas by foot in various expeditions. You can reach him at ravibanger@gmail.com.


Koushik Bhattacharyya

Koushik Bhattacharyya is working with Advanced Micro Devices, Inc. as Member Technical Staff and also worked as a software developer in NVIDIA®. He did his M.Tech in Computer Science (Gold Medalist) from Indian Statistical Institute, Kolkata, and M.Sc in pure mathematics from Burdwan University. With more than ten years of experience in software development using a number of languages and platforms, Koushik's present area of interest includes parallel programming and machine learning.

Code Downloads

Download the code and support files for this book.


Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

OpenCL Programming by Example +    Oracle Web Services Manager =
50% Off
the second eBook
Price for both: $41.70

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Understand OpenCL Platform Model, Execution Model, Memory Model, and Programming Model
  • Explore the different OpenCL objects, APIs for building kernel, memory allocation, data transfer, synchronization, and many more
  • Get to grips with API explanations, featuring simple examples
  • Create image processing examples such as Image histogram and Image convolution
  • Learn optimization techniques with Matrix Multiplication and Histogram examples.
  • Develop Bitonic sort in OpenCL
  • Build JPEG decoder using OpenCL
  • Construct linear and parabolic regression equation in OpenCL
  • Compose k-nearest neighborhood clustering algorithm from pattern recognition
  • Use OpenCL with OpenGL interoperability

In Detail

Research in parallel programming has been a mainstream topic for a decade, and will continue to be so for many decades to come. Many parallel programming standards and frameworks exist, but only take into account one type of hardware architecture. Today computing platforms come with many heterogeneous devices. OpenCL provides royalty free standard to program heterogeneous hardware.

This guide offers you a compact coverage of all the major topics of OpenCL programming. It explains optimization techniques and strategies in-depth, using illustrative examples and also provides case studies from diverse fields. Beginners and advanced application developers will find this book very useful.

Beginning with the discussion of the OpenCL models, this book explores their architectural view, programming interfaces and primitives. It slowly demystifies the process of identifying the data and task parallelism in diverse algorithms.

It presents examples from different domains to show how the problems within different domains can be solved more efficiently using OpenCL. You will learn about parallel sorting, histogram generation, JPEG compression, linear and parabolic regression and k-nearest neighborhood, a clustering algorithm in pattern recognition. Following on from this, optimization strategies are explained with matrix multiplication examples. You will also learn how to do an interoperation of OpenGL and OpenCL.

"OpenCL Programming by Example" explains OpenCL in the simplest possible language, which beginners will find it easy to understand. Developers and programmers from different domains who want to achieve acceleration for their applications will find this book very useful.

Approach

This book follows an example-driven, simplified, and practical approach to using OpenCL for general purpose GPU programming.

Who this book is for

If you are a beginner in parallel programming and would like to quickly accelerate your algorithms using OpenCL, this book is perfect for you! You will find the diverse topics and case studies in this book interesting and informative. You will only require a good knowledge of C programming for this book, and an understanding of parallel implementations will be useful, but not necessary.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software