• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# OpenCL<sup>TM</sup> API Headers
2
3This repository contains C language headers for the OpenCL API.
4
5The authoritative public repository for these headers is located at:
6
7https://github.com/KhronosGroup/OpenCL-Headers
8
9Issues, proposed fixes for issues, and other suggested changes should be
10created using Github.
11
12## CMake Package
13While the headers may just be copied as-is, this repository also contains a
14CMake script with an install rule to allow for packaging the headers.
15
16```bash
17cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/chosen/install/prefix
18cmake --build build --target install
19```
20
21To consume the package:
22
23```bash
24cmake path/to/opencl/app -DOpenCLHeaders_ROOT=/chosen/install/prefix
25```
26
27```cmake
28cmake_minimum_required(VERSION 3.0)
29cmake_policy(VERSION 3.0...3.18.4)
30project(proj)
31add_executable(app main.cpp)
32find_package(OpenCLHeaders REQUIRED)
33target_link_libraries(app PRIVATE OpenCL::Headers)
34```
35
36## Branch Structure
37
38The OpenCL API headers in this repository are Unified headers and are designed
39to work with all released OpenCL versions.  This differs from previous OpenCL
40API headers, where version-specific API headers either existed in separate
41branches, or in separate folders in a branch.
42
43## Compiling for a Specific OpenCL Version
44
45By default, the OpenCL API headers in this repository are for the latest
46OpenCL version (currently OpenCL 2.2).  To use these API headers to target
47a different OpenCL version, an application may `#define` the preprocessor
48value `CL_TARGET_OPENCL_VERSION` before including the OpenCL API headers.
49The `CL_TARGET_OPENCL_VERSION` is a three digit decimal value representing
50the OpenCL API version.
51
52For example, to enforce usage of no more than the OpenCL 1.2 APIs, you may
53include the OpenCL API headers as follows:
54
55```c
56#define CL_TARGET_OPENCL_VERSION 120
57#include <CL/opencl.h>
58```
59
60## Directory Structure
61
62```
63README.md               This file
64LICENSE                 Source license for the OpenCL API headers
65CL/                     Unified OpenCL API headers tree
66```
67
68## License
69
70See [LICENSE](LICENSE).
71
72---
73
74OpenCL and the OpenCL logo are trademarks of Apple Inc. used by permission by Khronos.
75