|
1 | | -# Building the OpenCL ICD Loader and Tests |
| 1 | +# OpenCL ICD Loader |
2 | 2 |
|
3 | | -The build system will build ICD Loader library (OpenCL.dll or libOpenCL.so), the |
4 | | -ICD Loader Test binary (icd_loader_test), and some helper libraries for the test. |
| 3 | +This repo contains the source code and tests for the Khronos official OpenCL ICD Loader. |
5 | 4 |
|
6 | | -## Linux |
| 5 | +## CI Build Status |
7 | 6 |
|
8 | | -Run "make" |
| 7 | +TBD |
9 | 8 |
|
10 | | -## Windows |
| 9 | +## Introduction |
11 | 10 |
|
12 | | -Run "build_using_cmake.bat" |
| 11 | +OpenCL defines an *Installable Client Driver* (ICD) mechanism to allow developers to build applications against an *Installable Client Driver* loader (ICD loader) rather than linking their applications against a specific OpenCL implementation. |
| 12 | +The ICD Loader is responsible for: |
13 | 13 |
|
14 | | -## Running ICD Test |
| 14 | +* Exporting OpenCL API entry points |
| 15 | +* Enumerating OpenCL implementations |
| 16 | +* Forwarding OpenCL API calls to the correct implementation |
15 | 17 |
|
16 | | -The ICD Test can be run using ctest, which is a companion to cmake. It can also be |
17 | | -run directly by executing icd_loader_test(.exe) executable from the bin folder. |
| 18 | +This repo contains the source code and tests for the Khronos official OpenCL ICD Loader. |
18 | 19 |
|
19 | | -### Linux |
| 20 | +Note that this repo does not contain an OpenCL implementation (ICD). |
| 21 | +You will need to obtain and install an OpenCL implementation for your OpenCL device that supports the OpenCL ICD extension `cl_khr_icd` to run an application using the OpenCL ICD Loader. |
20 | 22 |
|
21 | | -1. Add driver stub as an ICD |
22 | | - echo full/path/to/libOpenCLDriverStub.so > /etc/OpenCL/vendors/test.icd |
| 23 | +The OpenCL *Installable Client Driver* extension (`cl_khr_icd`) is described in the OpenCL extensions specification, which may be found on the [Khronos OpenCL Registry](https://www.khronos.org/registry/OpenCL/). |
| 24 | + |
| 25 | +## Build Instructions |
| 26 | + |
| 27 | +### Dependencies |
| 28 | + |
| 29 | +The OpenCL ICD Loader requires OpenCL Headers. |
| 30 | +To use system OpenCL Headers, please specify the OpenCL Header location using the CMake variable `OPENCL_ICD_LOADER_HEADERS_DIR`. |
| 31 | +By default, the OpenCL ICD Loader will look for OpenCL Headers in the `inc` directory. |
| 32 | + |
| 33 | +The OpenCL ICD Loader uses CMake for its build system. |
| 34 | +If CMake is not provided by your build system or OS pcakage manager, please consult the [CMake website](https://cmake.org). |
| 35 | + |
| 36 | +### Build and Install Directories |
| 37 | + |
| 38 | +A common convention is to place the `build` directory in the top directory of the repository and to place the `install` directory as a child of the `build` directory. |
| 39 | +The remainder of these instructions follow this convention, although you may place these directores in any location. |
| 40 | + |
| 41 | +### Example Usage |
| 42 | + |
| 43 | +For most Windows and Linux usages, the following steps are sufficient to build the OpenCL ICD Loader: |
| 44 | + |
| 45 | +1. Clone this repo: |
| 46 | + |
| 47 | + git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader |
| 48 | + |
| 49 | +1. Obtain the OpenCL Headers, if you are not planning to use system OpenCL headers. |
| 50 | +Headers may be obtained from the [Khronos OpenCL Headers](https://github.com/KhronosGroup/OpenCL-Headers) repository. |
| 51 | + |
| 52 | +1. Create a `build` directory: |
| 53 | + |
| 54 | + cd OpenCL-ICD-Loader |
| 55 | + mkdir build |
| 56 | + cd build |
| 57 | + |
| 58 | +1. Invoke `cmake` to generate solution files, Makefiles, or files for other build systems. |
| 59 | + |
| 60 | + cmake .. |
23 | 61 |
|
24 | | -2. Run test using ctest |
25 | | - make test |
| 62 | +1. Build using the CMake-generated files. |
26 | 63 |
|
27 | | -### Windows |
| 64 | +Notes: |
28 | 65 |
|
29 | | -1. Add driver stub as an ICD by adding appropriate registry value |
30 | | - Key for 32-bit apps: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Khronos\OpenCL\Vendors |
31 | | - Key for 64-bit apps: HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors |
| 66 | +* For 64-bit Windows builds, you may need to specify a 64-bit generator manually, for example: |
32 | 67 |
|
33 | | - Add a REG_DWORD value: |
34 | | - Name: c:/full/path/to/OpenCLDriverStub.dll |
35 | | - Data: 0 |
| 68 | + cmake.exe -G "Visual Studio 14 2015 Win64" .. |
36 | 69 |
|
37 | | - Note: The build_using_cmake.bat builds ICD test as a 32-bit binary. |
| 70 | +* Some users may prefer to use a CMake GUI frontend, such as `cmake-gui` or `ccmake`, vs. the command-line CMake. |
| 71 | + |
| 72 | +## OpenCL ICD Loader Tests |
| 73 | + |
| 74 | +OpenCL ICD Loader Tests can be run using `ctest`, which is a companion to CMake. |
| 75 | +The OpenCL ICD Loader Tests can also be run directly by executing icd_loader_test(.exe) executable from the bin folder. |
| 76 | + |
| 77 | +### Test Setup |
| 78 | + |
| 79 | +The OpenCL ICD Loader Tests use a "stub" ICD, which must be set up manually. |
| 80 | +The OpenCL ICD Loader Tests will "fail" if the "stub" ICD is not set up correctly. |
| 81 | +The method to install the "stub" ICD is operating system dependent. |
| 82 | + |
| 83 | +On Linux, install the "stub" ICD by creating a file with the full path to the "stub" ICD in `/etc/OpenCL/vendors`: |
| 84 | + |
| 85 | + echo full/path/to/libOpenCLDriverStub.so > /etc/OpenCL/vendors/test.icd |
| 86 | + |
| 87 | +On Windows, add the "stub" ICD by adding a `REG_DWORD` value to the registry keys: |
| 88 | + |
| 89 | + // For 32-bit operating systems, or 64-bit tests on a 64-bit operating system: |
| 90 | + HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors |
38 | 91 |
|
39 | | -2. Run test using ctest.exe |
40 | | - cd build |
41 | | - ctest.exe |
| 92 | + // For 32-bit tests on a 64-bit operating system: |
| 93 | + HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Khronos\OpenCL\Vendors |
| 94 | + |
| 95 | + // The name of the REG_DWORD value should be the full path to the "stub" ICD |
| 96 | + // OpenCLDriverStub.dll, and the data for this value should be 0. |
| 97 | + |
| 98 | +### Running Tests |
| 99 | + |
| 100 | +To run the tests, invoke `ctest` from the `build` directory. |
| 101 | +The CMake-generated build files may be able to invoke the OpenCL ICD Loader tests as well. |
| 102 | + |
| 103 | +### Test Cleanup |
| 104 | + |
| 105 | +Manually remove the file or registry keys added during Test Setup. |
| 106 | + |
| 107 | +## Support |
42 | 108 |
|
43 | | -### Cleanup |
| 109 | +Please create a GitHub issue to report an issue or ask questions. |
44 | 110 |
|
45 | | -Manually remove the registry key or .icd files added for running the ICD test. |
| 111 | +## Contributing |
46 | 112 |
|
47 | | -The "build" and "bin" folders are autogenerated by the build so those may be |
48 | | -safely deleted without losing any source code (on Linux "make clobber" will |
49 | | -delete them). |
| 113 | +Contributions to the OpenCL ICD Loader are welcomed and encouraged. |
| 114 | +You will be prompted with a one-time "click-through" CLA dialog as part of submitting your pull request or other contribution to GitHub. |
0 commit comments