OpenCL Programming by Example
eBook - ePub

OpenCL Programming by Example

Ravishekhar Banger, Koushik Bhattacharyya

Compartir libro
  1. 304 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

OpenCL Programming by Example

Ravishekhar Banger, Koushik Bhattacharyya

Detalles del libro
Vista previa del libro
Índice
Citas

Información del libro

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.

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es OpenCL Programming by Example un PDF/ePUB en línea?
Sí, puedes acceder a OpenCL Programming by Example de Ravishekhar Banger, Koushik Bhattacharyya en formato PDF o ePUB, así como a otros libros populares de Informatik y Programmierung in C. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
2013
ISBN
9781849692342
Edición
1
Categoría
Informatik

OpenCL Programming by Example


Table of Contents

OpenCL Programming by Example
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
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
OpenCL code
OpenCL program flow
Run on a different device
Summary
References
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
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
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
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
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
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
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
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
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
11. Case studies – Regressions, Sort, and KNN
Regression with least square curve fitting
Linear approximations
Parabolic approximations
Implementation
Bitonic sort
k-Nearest Neighborhood (k-NN) algorithm
Summary
Index

OpenCL Programming by Example

Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark informati...

Índice