Add spec file for Tizen (#1)
[platform/upstream/OpenCL-ICD-Loader.git] / README.md
1 # OpenCL ICD Loader
2
3 This repo contains the source code and tests for the Khronos official OpenCL ICD Loader.
4
5 ## CI Build Status
6
7 [![Windows Build Status](https://ci.appveyor.com/api/projects/status/47uhjgp5h4de2f63/branch/master?svg=true)](https://ci.appveyor.com/project/Khronoswebmaster/opencl-icd-loader/branch/master) [![Linux OSX Build Status](https://github.com/KhronosGroup/OpenCL-ICD-Loader/workflows/Presubmit/badge.svg)](https://github.com/KhronosGroup/OpenCL-ICD-Loader/actions?query=workflow%3APresubmit)
8
9 ## Introduction
10
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
14 * Exporting OpenCL API entry points
15 * Enumerating OpenCL implementations
16 * Forwarding OpenCL API calls to the correct implementation
17
18 This repo contains the source code and tests for the Khronos official OpenCL ICD Loader.
19
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.
22
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 package manager, please consult the [CMake website](https://cmake.org).
35
36 The Windows OpenCL ICD Loader requires the Windows SDK to check for and enumerate the OpenCLOn12 ICD.
37 An OpenCL ICD Loader can be built without a dependency on the Windows SDK using the CMake variable `OPENCL_ICD_LOADER_DISABLE_OPENCLON12`.
38 This variable should only be used when building an import lib to link with, and must be enabled when building an OpenCL ICD Loader for distribution!
39
40 ### Build and Install Directories
41
42 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.
43 The remainder of these instructions follow this convention, although you may place these directories in any location.
44
45 ### Example Usage
46
47 For most Windows and Linux usages, the following steps are sufficient to build the OpenCL ICD Loader:
48
49 1. Clone this repo:
50
51         git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
52
53 1. Obtain the OpenCL Headers, if you are not planning to use system OpenCL headers.
54 Headers may be obtained from the [Khronos OpenCL Headers](https://github.com/KhronosGroup/OpenCL-Headers) repository.
55
56 1. Create a `build` directory:
57
58         cd OpenCL-ICD-Loader
59         mkdir build
60         cd build
61
62 1. Invoke `cmake` to generate solution files, Makefiles, or files for other build systems.
63
64         cmake ..
65
66 1. Build using the CMake-generated files.
67
68 Notes:
69
70 * For 64-bit Windows builds, you may need to specify a 64-bit generator manually, for example:
71
72         cmake.exe -G "Visual Studio 14 2015 Win64" ..
73
74 * Some users may prefer to use a CMake GUI frontend, such as `cmake-gui` or `ccmake`, vs. the command-line CMake.
75
76 ## OpenCL ICD Loader Tests
77
78 OpenCL ICD Loader Tests can be run using `ctest`, which is a companion to CMake.
79 The OpenCL ICD Loader Tests can also be run directly by executing icd_loader_test(.exe) executable from the bin folder.
80
81 ### Test Setup
82
83 The OpenCL ICD Loader Tests use a "stub" ICD, which must be set up manually.
84 The OpenCL ICD Loader Tests will "fail" if the "stub" ICD is not set up correctly.
85 The method to install the "stub" ICD is operating system dependent.
86
87 On Linux, install the "stub" ICD by creating a file with the full path to the "stub" ICD in `/etc/OpenCL/vendors`:
88
89     echo full/path/to/libOpenCLDriverStub.so > /etc/OpenCL/vendors/test.icd
90
91 On Windows, add the "stub" ICD by adding a `REG_DWORD` value to the registry keys:
92
93     // For 32-bit operating systems, or 64-bit tests on a 64-bit operating system:
94     HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors
95     
96     // For 32-bit tests on a 64-bit operating system:
97     HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Khronos\OpenCL\Vendors
98
99     // The name of the REG_DWORD value should be the full path to the "stub" ICD
100     // OpenCLDriverStub.dll, and the data for this value should be 0.
101
102 ### Running Tests
103
104 To run the tests, invoke `ctest` from the `build` directory.
105 The CMake-generated build files may be able to invoke the OpenCL ICD Loader tests as well.
106
107 ### Test Cleanup
108
109 Manually remove the file or registry keys added during Test Setup.
110
111 ## About Layers
112
113 Layers have been added as an experimental feature in the OpenCL ICD Loader. We do not
114 expect the API or ABI to change significantly, but the OpenCL Working Group reserves
115 the right to do so. The layer support can also be completely deactivated during
116 configuration by using the `ENABLE_OPENCL_LAYERS` (`ON` by default) cmake variable:
117
118 ```bash
119 cmake -DENABLE_OPENCL_LAYERS=OFF
120 ```
121
122 For now, runtime configuration of layers is done using the `OPENCL_LAYERS` environment
123 variable. A colon (Linux) or semicolon (Windows) list of layers to use can be provided
124 through this environment variable.
125
126 We are looking for feedback.
127
128 ## Support
129
130 Please create a GitHub issue to report an issue or ask questions.
131
132 ## Contributing
133
134 Contributions to the OpenCL ICD Loader are welcomed and encouraged.
135 You will be prompted with a one-time "click-through" CLA dialog as part of submitting your pull request or other contribution to GitHub.
136
137 ## Table of Debug Environment Variables
138
139 The following debug environment variables are available for use with the OpenCL ICD loader:
140
141 | Environment Variable              | Behavior            |  Example Format      |
142 |:---------------------------------:|---------------------|----------------------|
143 | OCL_ICD_FILENAMES                 | Specifies a list of additional ICDs to load.  The ICDs will be enumerated first, before any ICDs discovered via default mechanisms. | `export OCL_ICD_FILENAMES=libVendorA.so:libVendorB.so`<br/><br/>`set OCL_ICD_FILENAMES=vendor_a.dll;vendor_b.dll` |
144 | OCL_ICD_VENDORS                   | On Linux and Android, specifies a directory to scan for ICDs to enumerate in place of the default `/etc/OpenCL/vendors'. |  `export OCL_ICD_VENDORS=/my/local/icd/search/path` |
145 | OPENCL_LAYERS                    | Specifies a list of layers to load. |  `export OPENCL_LAYERS=libLayerA.so:libLayerB.so`<br/><br/>`set OPENCL_LAYERS=libLayerA.dll;libLayerB.dll` |