OpenCL Programming by Example
eBook - ePub

OpenCL Programming by Example

Ravishekhar Banger, Koushik Bhattacharyya

Partager le livre
  1. 304 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

OpenCL Programming by Example

Ravishekhar Banger, Koushik Bhattacharyya

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

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.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que OpenCL Programming by Example est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  OpenCL Programming by Example par Ravishekhar Banger, Koushik Bhattacharyya en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Informatik et Programmierung in C. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2013
ISBN
9781849692342
Édition
1

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...

Table des matiĂšres