Skip to content
프로젝트

소개

Simple OpenCL examples for exploiting GPU computing

학습 및 교육

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
+1
in 15 days
+1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Simple examples of OpenCL code

Simple examples of OpenCL code used to learn heterogeneous and GPU computing with OpenCL.

Documentation: https://rsnemmen.github.io/OpenCL-examples/

Examples included

* -- reproduced to work in 2025 on AMD GPU

  • *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's ray-traced quaternion Julia set renderer. Requires Xcode
  • 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
  • *waste: compute cycle waster

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.

How to build

CMake (recommended — works on macOS and Linux)

mkdir build && cd build
cmake ..
make

Each target is placed in its corresponding subdirectory under build/. Run executables from that subdirectory so the .cl kernel files are found:

cd build/square_array && ./square

Examples requiring clRNG (auger, rng) are built automatically when clRNG is detected; they are silently skipped otherwise.

Makefiles

Each example also has its own Makefile. Build from within the project directory:

cd <example> && make        # build OpenCL version
cd <example> && make run    # build and run

Exceptions: N-BodySimulation uses an Xcode project. RayTraced_Quaternion_Julia-Set_Example has a Makefile and CMakeLists.txt. cf4cl uses make.sh.

Info about OpenCL devices

To learn about your OpenCL devices, try:

clinfo

To install clinfo on MacOS:

brew install clinfo

TODO

  • similar repo with CUDA examples

Buy Me a Coffee

관련 프로젝트 살펴보기

불러오는 중…