Introduction to Opencl™ Programming
Total Page:16
File Type:pdf, Size:1020Kb
Introduction to OpenCL™ Programming Training Guide Publication #: 137-41768-10 ∙ Rev: A ∙ Issue Date: May, 2010 Introduction to OpenCL™ Programming PID: 137-41768-10 ∙ Rev: A ∙ May, 2010 © 2010 Advanced Micro Devices Inc. All rights reserved. The contents of this document are provided in connection with Advanced Micro Devices, Inc. ("AMD") products. AMD makes no representations or warranties with respect to the accuracy or completeness of the contents of this publication and reserves the right to make changes to specifications and product descriptions at any time without notice. The information contained herein may be of a preliminary or advance nature and is subject to change without notice. No license, whether express, implied, arising by estoppel or otherwise, to any intellectual property rights is granted by this publication. Except as set forth in AMD's Standard Terms and Conditions of Sale, AMD assumes no liability whatsoever, and disclaims any express or implied warranty, relating to its products including, but not limited to, the implied warranty of merchantability, fitness for a particular purpose, or infringement of any intellectual property right. AMD's products are not designed, intended, authorized or warranted for use as components in systems intended for surgical implant into the body, or in other applications intended to support or sustain life, or in any other application in which the failure of AMD's product could create a situation where personal injury, death, or severe property or environmental damage may occur. AMD reserves the right to discontinue or make changes to its products at any time without notice. Trademarks AMD, the AMD Arrow logo, AMD Athlon, AMD Opteron, AMD Phenom, AMD Sempron, AMD Turion, and combinations thereof, are trademarks of Advanced Micro Devices, Inc. HyperTransport is a licensed trademark of the HyperTransport Technology Consortium. Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies. ii PID: 137-41768-10 ∙ Rev: A ∙ May, 2010 Introduction to OpenCL™ Programming Contents Chapter 1 Course Overview . 1 1.1 Objectives . 1 1.2 Audience . 1 1.3 References . 1 Chapter 2 Introduction . 3 2.1 What is GPU Compute? . 3 2.2 A Brief History of GPU Compute . 3 2.3 Heterogeneous Computing . 4 Chapter 3 Introduction to OpenCL . 7 3.1 What is OpenCL? . .7 3.1.1 Benefits of OpenCL . .7 3.2 Anatomy of OpenCL . 8 3.2.1 Language Specification . 8 3.2.2 Platform API . 8 3.2.3 Runtime API . 8 3.3 OpenCL Architecture . 8 3.3.1 The Platform Model . 9 3.3.2 The Execution Model . 11 3.3.3 The Memory Model . 14 Chapter 4 Getting Started with OpenCL . 17 4.1 The Software Development Environment and Tools . 17 4.1.1 Requirements . .17 4.1.2 Installing on Windows . 19 4.1.3 Installing on Linux . 21 4.2 "Hello World" in OpenCL . 22 4.3 Compiling OpenCL Source . 24 4.3.1 Compiling on Linux . 25 4.3.2 Compiling on Windows . 25 Chapter 5 OpenCL Programming in Detail . 29 iii Introduction to OpenCL™ Programming PID: 137-41768-10 ∙ Rev: A ∙ May, 2010 5.1 Executing an OpenCL Program . ..