Skip to content

cqcallaw/SimpleOpenCLSamples

 
 

Repository files navigation

Simple OpenCLTM Samples

build

This repo contains simple OpenCL samples that demonstrate how to build OpenCL applications using only the Khronos-provided headers and libs. All samples have been tested on Windows and Linux.

Most of the samples are written in C and C++ using the OpenCL C++ bindings. A few of the samples have been ported to Python using PyOpenCL.

Code Structure

README.md               This file
LICENSE                 License information
CMakeLists.txt          Top-level CMakefile
external/               External Projects (headers and libs)
include/                Include Files (OpenCL C++ bindings)
samples/                Samples
tutorials/              Tutorials

How to Build the Samples

The samples require the following external dependencies:

OpenCL Headers:

git clone https://github.com/KhronosGroup/OpenCL-Headers external/OpenCL-Headers

OpenCL ICD Loader:

git clone https://github.com/KhronosGroup/opencl-icd-loader external/opencl-icd-loader

Many samples that use extensions additionally require the OpenCL Extension Loader:

git clone https://github.com/bashbaug/opencl-extension-loader external/opencl-extension-loader

After satisfying the external dependencies create build files using CMake. For example:

mkdir build && cd build
cmake ..

Then, build with the generated build files.

How to Run the Samples

To run the samples, you will need to obtain and install an ICD loader and an OpenCL implementation (ICD) that supports the cl_khr_icd extension.

The ICD loader is likely provided by your operating system or an OpenCL implementation. If desired, you may use the ICD loader that is built along with these OpenCL samples. The OpenCL implementation will likely be provided by your OpenCL device vendor. There are several open source OpenCL implementations as well.

Further Reading

A Note About Error Checking

For brevity, most samples do not include error checking. This means that a sample may crash or incorrectly report success if an OpenCL error occurs. By defining the CMake variable SAMPLES_ENABLE_EXCEPTIONS many samples can instead throw an exception if an OpenCL error occurs.

Tools like the OpenCL Intercept Layer can also be useful to detect when an OpenCL error occurs and to identify the cause of the error.

License

These samples are licensed under the MIT License.

Notes:


OpenCL and the OpenCL logo are trademarks of Apple Inc. used by permission by Khronos.

* Other names and brands may be claimed as the property of others.

About

Simple OpenCL Samples that Build with Khronos Headers and Libs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 98.5%
  • CMake 1.5%