xref: /aosp_15_r20/external/OpenCL-Headers/README.md (revision 3cc257528f335c5672e46865a03b8ee020e5fe2d)
1*3cc25752SFrank Piva# OpenCL<sup>TM</sup> API Headers
2*3cc25752SFrank Piva
3*3cc25752SFrank PivaThis repository contains C language headers for the OpenCL API.
4*3cc25752SFrank Piva
5*3cc25752SFrank PivaThe authoritative public repository for these headers is located at:
6*3cc25752SFrank Piva
7*3cc25752SFrank Pivahttps://github.com/KhronosGroup/OpenCL-Headers
8*3cc25752SFrank Piva
9*3cc25752SFrank PivaIssues, proposed fixes for issues, and other suggested changes should be
10*3cc25752SFrank Pivacreated using Github.
11*3cc25752SFrank Piva
12*3cc25752SFrank Piva## Build instructions
13*3cc25752SFrank Piva
14*3cc25752SFrank Piva> While the OpenCL Headers can be built and installed in isolation, it is part of the [OpenCL SDK](https://github.com/KhronosGroup/OpenCL-SDK). If looking for streamlined build experience and a complete development package, refer to the SDK build instructions instead of the following guide.
15*3cc25752SFrank Piva
16*3cc25752SFrank Piva### Dependencies
17*3cc25752SFrank Piva
18*3cc25752SFrank Piva- The OpenCL Headers CMake package support uses CMake for its build system.
19*3cc25752SFrank PivaIf CMake is not provided by your build system or OS package manager, please consult the [CMake website](https://cmake.org).
20*3cc25752SFrank Piva
21*3cc25752SFrank Piva### Example Build
22*3cc25752SFrank PivaWhile the headers may just be copied as-is, this repository also contains a
23*3cc25752SFrank PivaCMake script with an install rule to allow for packaging the headers.
24*3cc25752SFrank Piva
25*3cc25752SFrank Piva```bash
26*3cc25752SFrank Pivacmake -S . -B build -DCMAKE_INSTALL_PREFIX=/chosen/install/prefix
27*3cc25752SFrank Pivacmake --build build --target install
28*3cc25752SFrank Piva```
29*3cc25752SFrank Piva
30*3cc25752SFrank Piva### Example Use
31*3cc25752SFrank Piva
32*3cc25752SFrank PivaExample CMake invocation
33*3cc25752SFrank Piva
34*3cc25752SFrank Piva```bash
35*3cc25752SFrank Pivacmake -D CMAKE_PREFIX_PATH=/chosen/install/prefix /path/to/opencl/app
36*3cc25752SFrank Piva```
37*3cc25752SFrank Piva
38*3cc25752SFrank Pivaand sample `CMakeLists.txt`
39*3cc25752SFrank Piva
40*3cc25752SFrank Piva```cmake
41*3cc25752SFrank Pivacmake_minimum_required(VERSION 3.0)
42*3cc25752SFrank Pivacmake_policy(VERSION 3.0...3.18.4)
43*3cc25752SFrank Pivaproject(proj)
44*3cc25752SFrank Pivaadd_executable(app main.cpp)
45*3cc25752SFrank Pivafind_package(OpenCLHeaders REQUIRED)
46*3cc25752SFrank Pivatarget_link_libraries(app PRIVATE OpenCL::Headers)
47*3cc25752SFrank Piva```
48*3cc25752SFrank Piva
49*3cc25752SFrank Piva## Branch Structure
50*3cc25752SFrank Piva
51*3cc25752SFrank PivaThe OpenCL API headers in this repository are Unified headers and are designed
52*3cc25752SFrank Pivato work with all released OpenCL versions. This differs from previous OpenCL
53*3cc25752SFrank PivaAPI headers, where version-specific API headers either existed in separate
54*3cc25752SFrank Pivabranches, or in separate folders in a branch.
55*3cc25752SFrank Piva
56*3cc25752SFrank Piva## Compiling for a Specific OpenCL Version
57*3cc25752SFrank Piva
58*3cc25752SFrank PivaBy default, the OpenCL API headers in this repository are for the latest
59*3cc25752SFrank PivaOpenCL version (currently OpenCL 3.0).  To use these API headers to target
60*3cc25752SFrank Pivaa different OpenCL version, an application may `#define` the preprocessor
61*3cc25752SFrank Pivavalue `CL_TARGET_OPENCL_VERSION` before including the OpenCL API headers.
62*3cc25752SFrank PivaThe `CL_TARGET_OPENCL_VERSION` is a three digit decimal value representing
63*3cc25752SFrank Pivathe OpenCL API version.
64*3cc25752SFrank Piva
65*3cc25752SFrank PivaFor example, to enforce usage of no more than the OpenCL 1.2 APIs, you may
66*3cc25752SFrank Pivainclude the OpenCL API headers as follows:
67*3cc25752SFrank Piva
68*3cc25752SFrank Piva```c
69*3cc25752SFrank Piva#define CL_TARGET_OPENCL_VERSION 120
70*3cc25752SFrank Piva#include <CL/opencl.h>
71*3cc25752SFrank Piva```
72*3cc25752SFrank Piva
73*3cc25752SFrank Piva## Controlling Function Prototypes
74*3cc25752SFrank Piva
75*3cc25752SFrank PivaBy default, the OpenCL API headers in this repository declare function
76*3cc25752SFrank Pivaprototypes for every known core OpenCL API and OpenCL extension API.  If this is
77*3cc25752SFrank Pivanot desired, the declared function prototypes can be controlled by the following
78*3cc25752SFrank Pivapreprocessor defines:
79*3cc25752SFrank Piva
80*3cc25752SFrank Piva* `CL_NO_PROTOTYPES`: No function prototypes will be declared.  This control
81*3cc25752SFrank Piva  applies to core OpenCL APIs and OpenCL extension APIs.
82*3cc25752SFrank Piva* `CL_NO_CORE_PROTOTYPES`: No function prototypes will be declared for core
83*3cc25752SFrank Piva  OpenCL APIs.
84*3cc25752SFrank Piva* `CL_NO_EXTENSION_PROTOTYPES`: No function prototypes will be declared for
85*3cc25752SFrank Piva  OpenCL extension APIs.  This control applies to all OpenCL extension APIs.
86*3cc25752SFrank Piva* `CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES`: No function prototypes will be
87*3cc25752SFrank Piva  declared for OpenCL extension APIs that are in the ICD dispatch table for
88*3cc25752SFrank Piva  historical reasons.
89*3cc25752SFrank Piva* `CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES`: No function prototypes will be
90*3cc25752SFrank Piva  declared for OpenCL extension APIs that are not in the ICD dispatch table.
91*3cc25752SFrank Piva
92*3cc25752SFrank PivaFor example, to declare function prototypes for core OpenCL 3.0 APIs only, you
93*3cc25752SFrank Pivamay include the OpenCL API headers as follows:
94*3cc25752SFrank Piva
95*3cc25752SFrank Piva```c
96*3cc25752SFrank Piva#define CL_TARGET_OPENCL_VERSION 300
97*3cc25752SFrank Piva#define CL_NO_EXTENSION_PROTOTYPES
98*3cc25752SFrank Piva#include <CL/opencl.h>
99*3cc25752SFrank Piva```
100*3cc25752SFrank Piva
101*3cc25752SFrank Piva## Compatibility Notes
102*3cc25752SFrank Piva
103*3cc25752SFrank PivaOpenCL values backward compatibility and in most cases an application using an
104*3cc25752SFrank Pivaolder version of the OpenCL API headers can seamlessly update to a newer version
105*3cc25752SFrank Pivaof the OpenCL API headers.  In rare cases, though, the OpenCL API headers may
106*3cc25752SFrank Pivabreak backward compatibility:
107*3cc25752SFrank Piva
108*3cc25752SFrank Piva* Very rarely, there may be bugs or other issues in the OpenCL API headers that
109*3cc25752SFrank Piva  cannot be fixed without breaking compatibility.
110*3cc25752SFrank Piva* The OpenCL API headers for provisional features or provisional extensions may
111*3cc25752SFrank Piva  be changed in a way that breaks compatibility.
112*3cc25752SFrank Piva
113*3cc25752SFrank PivaApplications or libraries that require stable OpenCL API headers are encouraged
114*3cc25752SFrank Pivato use tagged or released OpenCL API headers.  We will do our best to document
115*3cc25752SFrank Pivaany breaking changes in the description of each release.  The OpenCL API headers
116*3cc25752SFrank Pivaare tagged at least as often as each OpenCL specification release.
117*3cc25752SFrank Piva
118*3cc25752SFrank Piva## Directory Structure
119*3cc25752SFrank Piva
120*3cc25752SFrank Piva```
121*3cc25752SFrank PivaREADME.md               This file
122*3cc25752SFrank PivaLICENSE                 Source license for the OpenCL API headers
123*3cc25752SFrank PivaCL/                     Unified OpenCL API headers tree
124*3cc25752SFrank Piva```
125*3cc25752SFrank Piva
126*3cc25752SFrank Piva## License
127*3cc25752SFrank Piva
128*3cc25752SFrank PivaSee [LICENSE](LICENSE).
129*3cc25752SFrank Piva
130*3cc25752SFrank Piva---
131*3cc25752SFrank Piva
132*3cc25752SFrank PivaOpenCL and the OpenCL logo are trademarks of Apple Inc. used by permission by Khronos.
133