OpenCL Programming by Example
eBook - ePub

OpenCL Programming by Example

Ravishekhar Banger, Koushik Bhattacharyya

Buch teilen
  1. 304 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

OpenCL Programming by Example

Ravishekhar Banger, Koushik Bhattacharyya

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

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.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist OpenCL Programming by Example als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu OpenCL Programming by Example von Ravishekhar Banger, Koushik Bhattacharyya im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Informatik & Programmierung in C. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2013
ISBN
9781849692342

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

Inhaltsverzeichnis