INTRODUCTIONTO OPENCLUnai LopezIntelligent Systems GroupDepartment of Computer Architecture & TechnologyUniversity of the ...
Outline1)  Introduction2)  Programming Basics3)  “Hello World”4)  Final remarks
OpenCL•  Standard for the development of data parallel applications•  Most used for the development of GPGPU applications:...
OpenCL & GPGPU•  GPGPU: Take advantage of GPU’s computing power to make massively parallel applications•  Parallel applica...
OpenCL•  Furthermore, OpenCL provides portability:  same code can run on different architectures•  For example:Intel Core ...
OpenCL•  Provides the following abstraction: A compute device is composed by compute units•  OpenCL platform: Host + Compu...
Programming Basics•  Kernel: function that defines the behavior of each thread•  For example, kernel for vector addition: ...
Programming Basics•  An OpenCL applications consists of: Kernel file (OpenCL-C): problem computation   Host code(C): kerne...
Programming Basics•  Host code: programmed using OpenCL API•  API Calls, such as:   •  clCreateProgramWithSource: Load ker...
Hello World•  Implementation of simple vector addition in OpenCL•  Checks for default platform and device in the system•  ...
Final Remarks•  OpenCL does not provide performance portability•  Alternative to NVIDIA CUDA: Programming paradigm for NVI...
More about OpenCL•  Before starting to develop take a look at:   •  Context, command queues, events,…•  Documentation   • ...
INTRODUCTIONTO OPENCLUnai Lopez – ulopez009@ehu.esIntelligent Systems GroupDepartment of Computer Architecture & Technolog...
Upcoming SlideShare
Loading in …5
×

Introduction to OpenCL

1,174
-1

Published on

Brief introduction to OpenCL. Included a demo showing the source code of a vector addition.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,174
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
53
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Introduction to OpenCL

  1. 1. INTRODUCTIONTO OPENCLUnai LopezIntelligent Systems GroupDepartment of Computer Architecture & TechnologyUniversity of the Basque Country
  2. 2. Outline1)  Introduction2)  Programming Basics3)  “Hello World”4)  Final remarks
  3. 3. OpenCL•  Standard for the development of data parallel applications•  Most used for the development of GPGPU applications: General Purpose computing on Graphics Processing Units•  A GPU is comprised of hundreds of compute cores nVidia GTX 285 (240 Compute cores) nVidia GT200b Architecture•  Specialized for massively data parallel computation
  4. 4. OpenCL & GPGPU•  GPGPU: Take advantage of GPU’s computing power to make massively parallel applications•  Parallel applications with huge acceleration in Molecular Dynamics, Image Processing, Evolutionary Computation,…•  All cases based on data parallelism: each thread processes a subset of the data•  For example, a vector addition: A + B || C Thread ID 0 1 2 3 4 5 6 7 8 9 10 11
  5. 5. OpenCL•  Furthermore, OpenCL provides portability: same code can run on different architectures•  For example:Intel Core i5 CPU STICell B/E Intel Xeon Phi AMD HD 6950 GPU4 cores @ 2’5 Ghz 8 cores @ 3,2 Ghz 50 cores @ 1 Ghz 1408 cores @ 800 Mhz
  6. 6. OpenCL•  Provides the following abstraction: A compute device is composed by compute units•  OpenCL platform: Host + Compute Devices•  Each manufacturer provides an SDK: •  NVIDIA SDK for GPUs •  AMD APP for CPUs/GPU •  Intel for CPUs •  IBM for PowerPC and Cell B/E
  7. 7. Programming Basics•  Kernel: function that defines the behavior of each thread•  For example, kernel for vector addition: __kernel void sumKernel ( __global int* a, __global int* b, __global int* c) { int i = get_global_id(0); c[i] = a[i] + b[i]; }•  Written in OpenCL-C: ANSI-C + Set of kernel functions, e.g.: •  get_global_id: obtains thread index •  barrier: synchronizes threads
  8. 8. Programming Basics•  An OpenCL applications consists of: Kernel file (OpenCL-C): problem computation Host code(C): kernel management•  Basic host application flow: 1.  Load and Compilation of kernel 2.  Data copy from host to device (e.g. from CPU to GPU) 3.  Execution of kernel 4.  Data copy from device to host 5.  Release kernels and data from device memory•  Execution using command queue in each device
  9. 9. Programming Basics•  Host code: programmed using OpenCL API•  API Calls, such as: •  clCreateProgramWithSource: Load kernel from char* •  clBuildProgram: Compile kernel •  clSetKernelArgs: Set kernel arguments for the device •  clEnqueueWriteBuffer/clEnqueueRead: Copy data vector to device •  clEnqueueNDRangerKernel: Launch kernel in device•  API Types, such as: •  cl_mem: Pointer to device memory objects •  cl_program: Kernel object •  cl_float / cl_int / cl_uint: Redefinition of C types
  10. 10. Hello World•  Implementation of simple vector addition in OpenCL•  Checks for default platform and device in the system•  Modify Makefile with proper paths in each system•  Run: vectorAdd <size_of_vector>
  11. 11. Final Remarks•  OpenCL does not provide performance portability•  Alternative to NVIDIA CUDA: Programming paradigm for NVIDIA GPU cards•  Combinable with other parallel programming models: •  OpenMP for SMPs / MPI for MPPs•  Huge ecosystems for OpenCL, e.g. OpenACC: Develop GPGPU applications using directives #pragma acc kernels for(i = 0; i< N; i++) c[i] = b[i] + a[i];
  12. 12. More about OpenCL•  Before starting to develop take a look at: •  Context, command queues, events,…•  Documentation •  Khronos Group: Maintainers of OpenCL •  OpenCL Best practices guide in CUDA/AMD SDKs •  Programming Massively Parallel Processors (Book for CUDA)•  OpenCL sample applications: •  Most SDKs include example OpenCL applications •  Rodinia: http://lava.cs.virginia.edu/wiki/rodinia •  Parboil: http://impact.crhc.illinois.edu/parboil.aspx
  13. 13. INTRODUCTIONTO OPENCLUnai Lopez – ulopez009@ehu.esIntelligent Systems GroupDepartment of Computer Architecture & TechnologyUniversity of the Basque Country
  1. Gostou de algum slide específico?

    Recortar slides é uma maneira fácil de colecionar informações para acessar mais tarde.

×