Skip to content

Simple OpenCL examples for exploiting GPU computing

Notifications You must be signed in to change notification settings

JueonPark/OpenCL-examples

 
 

Repository files navigation

Simple examples of OpenCL code

Simple examples of OpenCL code, which I am using to learn heterogeneous and GPU computing with OpenCL.

Examples included

  • add_numbers: add a list of numbers together. Includes detailed error handling which makes the code harder to read and understand
  • square_array: computes array^2 (I am playing mostly with this one)
  • sum_array: sums two arrays
  • cf4cl: testing OpenCL C wrapper
  • Hello_World: OpenCL "Hello World" by Apple
  • mandelbrot: my attempt at a simple Mandelbrot set calculation
  • N-BodySimulation: Apple's N-body simulator which clearly illustrates the speedup gained by using the GPU. Requires Xcode
  • RayTraced_Quaternion_Julia-Set_Example: Apple
  • rng: Illustrates how to generate random numbers in the host and in the GPU using the library clRNG
  • auger: generates random cosmic rays on an isotropic sky

The examples that clearly demonstrate the computational advantage of using a GPU for processing are N-BodySimulation, RayTraced_Quaternion_Julia-Set_Example (both developed by Apple programmers) and auger. For auger, I got impressive speedups of >200x compared to a serial code on the CPU.

Info about OpenCL devices

To learn about your OpenCL devices, try:

clinfo

To install clinfo on MacOS:

brew install homebrew/science/clinfo

References

Slides

Code walkthroughs

Courses

  • Hands-on OpenCL
  • AMD OpenCL course
  • Introduction to OpenCL, Manchester

Donate

If you are really happy with these examples, you can buy me a beer. Perhaps I could create a similar repo with CUDA examples?

TODO

About

Simple OpenCL examples for exploiting GPU computing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C++ 64.4%
  • C 19.5%
  • Objective-C 14.2%
  • Makefile 1.1%
  • C++ 0.6%
  • GLSL 0.2%