You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository contains an extension loader library for OpenCL extension APIs.
5
5
6
-
This library is a work in progress.
7
-
Check back soon for updates!
6
+
The extension loader library provides function definitions for all known OpenCL extension APIs and code to query the extension APIs, allowing them to be called just like core OpenCL APIs.
7
+
8
+
## How to Build the OpenCL Extension Loader
9
+
10
+
The OpenCL Extension Loader uses CMake to generate build files.
11
+
It is regularly used and tested on Windows and Linux.
12
+
13
+
The OpenCL Extension Loader requires the following external dependencies: OpenCL headers and an OpenCL library to link with.
14
+
These dependencies can be provided via several different methods:
15
+
16
+
1. Via CMake's `find_package(OpenCL)`.
17
+
For many operating systems, if OpenCL packages or vendor-specific SDKs are installed in standard locations, they will be found automatically.
18
+
Updated CMake packages may also be provided by the Khronos [OpenCL-SDK](https://github.com/KhronosGroup/OpenCL-SDK).
19
+
20
+
1. Specified manually via the CMake variables `OpenCL_INCLUDE_DIRS` and `OPENCL_LIBRARIES`.
21
+
22
+
The OpenCL Extension Loader may also be used as a CMake sub-project, in which case it will inherit the CMake variables `OpenCL_INCLUDE_DIRS` and `OPENCL_LIBRARIES` if set, and will `find_package(OpenCL)` otherwise.
23
+
24
+
## How to Use the OpenCL Extension Loader
25
+
26
+
After building the OpenCL Extension Loader, simply link with it as you would link to the standard OpenCL libraries.
27
+
This will satisfy build dependencies for OpenCL extension APIs, allowing them to be called just like core OpenCL APIs.
28
+
29
+
For example usage, please see [SimpleOpenCLSamples](https://github.com/bashbaug/SimpleOpenCLSamples).
30
+
31
+
## How to Generate Support for New Extensions
32
+
33
+
The OpenCL Extension Loader is generated from API definitions in the [OpenCL XML File](https://github.com/KhronosGroup/OpenCL-Docs/blob/main/xml/cl.xml) and several [Python Mako Templates](https://www.makotemplates.org/).
34
+
To add support for many new extensions, simply run the `gen_openclext.py` script in the `scripts` directory.
35
+
To simplify generation, there is also a CMake target `extension_loader_generate`, which will invoke the script.
36
+
37
+
After generation, examine the generated files to ensure everything looks correct, then copy the generated files to the OpenCL Extension Loader source directories.
38
+
This can be done manually, or via the CMake target `extension_loader_copy`.
39
+
40
+
In some cases, the scripts themselves may need to be modified.
41
+
This typically happens when an extension adds a new type.
42
+
When an extension adds a new type:
43
+
44
+
* The OpenCL Extension Loader template file `openclext.cpp.mako` may need to add a function to get the OpenCL Extension Loader dispatch table from an object of the new type.
45
+
* The OpenCL Extension Loader template file may also need to be modified if new extension functions are atypical and the OpenCL Extension Loader dispatch table should not be queried from the first function parameter.
46
+
* The OpenCL Extension Loader test generation template file may need to be updated to add default values for the new type.
47
+
48
+
The OpenCL Extension Loader is most commonly used with the upstream OpenCL XML File, but it can also be used with a fork of the upstream OpenCL XML File, say to generate functions for a private or as-yet unreleased extension.
49
+
50
+
## CMake Variables
51
+
52
+
The following CMake variables are supported. To specify one of these variables
53
+
via the command line generator, use the CMake syntax `-D<option name>=<value>`.
54
+
See your CMake documentation for more details.
55
+
56
+
| Variable | Type | Description |
57
+
|:---------|:-----|:------------|
58
+
|OPENCL\_EXTENSION\_LOADER\_FORCE\_STATIC\_LIB | BOOL | Unconditionally Build a Static OpenCL Extension Loader. A static library can simplify building and distribution. Default: `TRUE`
59
+
|OPENCL\_EXTENSION\_LOADER\_SINGLE\_PLATFORM\_ONLY | BOOL | Only Support Extensions from a Single OpenCL Platform. This may improve performance by simplifying dispatch table lookups. Default: `FALSE`
60
+
|OPENCL\_EXTENSION\_LOADER\_INSTALL | BOOL | Generate a CMake Installation Target for the OpenCL Extension Loader. Default: `FALSE`
0 commit comments