1*6467f958SSadaf Ebrahimi# OpenCL Conformance Test Suite (CTS) 2*6467f958SSadaf Ebrahimi 3*6467f958SSadaf EbrahimiThis is the OpenCL CTS for all versions of the Khronos 4*6467f958SSadaf Ebrahimi[OpenCL](https://www.khronos.org/opencl/) standard. 5*6467f958SSadaf Ebrahimi 6*6467f958SSadaf Ebrahimi## Building the CTS 7*6467f958SSadaf Ebrahimi 8*6467f958SSadaf EbrahimiThe CTS supports Linux, Windows, macOS, and Android platforms. In particular, 9*6467f958SSadaf EbrahimiGitHub Actions CI builds against Ubuntu 20.04, Windows-latest, and 10*6467f958SSadaf Ebrahimimacos-latest. 11*6467f958SSadaf Ebrahimi 12*6467f958SSadaf EbrahimiCompiling the CTS requires the following CMake configuration options to be set: 13*6467f958SSadaf Ebrahimi 14*6467f958SSadaf Ebrahimi* `CL_INCLUDE_DIR` Points to the unified 15*6467f958SSadaf Ebrahimi [OpenCL-Headers](https://github.com/KhronosGroup/OpenCL-Headers). 16*6467f958SSadaf Ebrahimi* `CL_LIB_DIR` Directory containing the OpenCL library to build against. 17*6467f958SSadaf Ebrahimi* `OPENCL_LIBRARIES` Name of the OpenCL library to link. 18*6467f958SSadaf Ebrahimi 19*6467f958SSadaf EbrahimiIt is advised that the [OpenCL ICD-Loader](https://github.com/KhronosGroup/OpenCL-ICD-Loader) 20*6467f958SSadaf Ebrahimiis used as the OpenCL library to build against. Where `CL_LIB_DIR` points to a 21*6467f958SSadaf Ebrahimibuild of the ICD loader and `OPENCL_LIBRARIES` is "OpenCL". 22*6467f958SSadaf Ebrahimi 23*6467f958SSadaf Ebrahimi### Example Build 24*6467f958SSadaf Ebrahimi 25*6467f958SSadaf EbrahimiSteps on a Linux platform to clone dependencies from GitHub sources, configure 26*6467f958SSadaf Ebrahimia build, and compile. 27*6467f958SSadaf Ebrahimi 28*6467f958SSadaf Ebrahimi```sh 29*6467f958SSadaf Ebrahimigit clone https://github.com/KhronosGroup/OpenCL-CTS.git 30*6467f958SSadaf Ebrahimigit clone https://github.com/KhronosGroup/OpenCL-Headers.git 31*6467f958SSadaf Ebrahimigit clone https://github.com/KhronosGroup/OpenCL-ICD-Loader.git 32*6467f958SSadaf Ebrahimi 33*6467f958SSadaf Ebrahimimkdir OpenCL-ICD-Loader/build 34*6467f958SSadaf Ebrahimicmake -S OpenCL-ICD-Loader -B OpenCL-ICD-Loader/build \ 35*6467f958SSadaf Ebrahimi -DOPENCL_ICD_LOADER_HEADERS_DIR=$PWD/OpenCL-Headers 36*6467f958SSadaf Ebrahimicmake --build ./OpenCL-ICD-Loader/build --config Release 37*6467f958SSadaf Ebrahimi 38*6467f958SSadaf Ebrahimimkdir OpenCL-CTS/build 39*6467f958SSadaf Ebrahimicmake -S OpenCL-CTS -B OpenCL-CTS/build \ 40*6467f958SSadaf Ebrahimi -DCL_INCLUDE_DIR=$PWD/OpenCL-Headers \ 41*6467f958SSadaf Ebrahimi -DCL_LIB_DIR=$PWD/OpenCL-ICD-Loader/build \ 42*6467f958SSadaf Ebrahimi -DOPENCL_LIBRARIES=OpenCL 43*6467f958SSadaf Ebrahimicmake --build OpenCL-CTS/build --config Release 44*6467f958SSadaf Ebrahimi``` 45*6467f958SSadaf Ebrahimi 46*6467f958SSadaf Ebrahimi## Running the CTS 47*6467f958SSadaf Ebrahimi 48*6467f958SSadaf EbrahimiA build of the CTS contains multiple executables representing the directories in 49*6467f958SSadaf Ebrahimithe `test_conformance` folder. Each of these executables contains sub-tests, and 50*6467f958SSadaf Ebrahimipossibly smaller granularities of testing within the sub-tests. 51*6467f958SSadaf Ebrahimi 52*6467f958SSadaf EbrahimiSee the `--help` output on each executable for the list of sub-tests available, 53*6467f958SSadaf Ebrahimias well as other options for configuring execution. 54*6467f958SSadaf Ebrahimi 55*6467f958SSadaf EbrahimiIf the OpenCL library built against is the ICD Loader, and the vendor library to 56*6467f958SSadaf Ebrahimibe tested is not registered in the 57*6467f958SSadaf Ebrahimi[default ICD Loader location](https://github.com/KhronosGroup/OpenCL-ICD-Loader#registering-icds) 58*6467f958SSadaf Ebrahimithen the [OCL_ICD_FILENAMES](https://github.com/KhronosGroup/OpenCL-ICD-Loader#table-of-debug-environment-variables) 59*6467f958SSadaf Ebrahimienvironment variable will need to be set for the ICD Loader to detect the OpenCL 60*6467f958SSadaf Ebrahimilibrary to use at runtime. For example, to run the basic tests on a Linux 61*6467f958SSadaf Ebrahimiplatform: 62*6467f958SSadaf Ebrahimi 63*6467f958SSadaf Ebrahimi```sh 64*6467f958SSadaf EbrahimiOCL_ICD_FILENAMES=/path/to/vendor_lib.so ./test_basic 65*6467f958SSadaf Ebrahimi``` 66*6467f958SSadaf Ebrahimi 67*6467f958SSadaf Ebrahimi### Offline Compilation 68*6467f958SSadaf Ebrahimi 69*6467f958SSadaf EbrahimiTesting OpenCL drivers which do not have a runtime compiler can be done by using 70*6467f958SSadaf Ebrahimiadditional command line arguments provided by the test harness for tests which 71*6467f958SSadaf Ebrahimirequire compilation, these are: 72*6467f958SSadaf Ebrahimi 73*6467f958SSadaf Ebrahimi* `--compilation-mode` Selects if OpenCL-C source code should be compiled using 74*6467f958SSadaf Ebrahimi an external tool before being passed on to the OpenCL driver in that form for 75*6467f958SSadaf Ebrahimi testing. Online is the default mode, but also accepts the values `spir-v`, and 76*6467f958SSadaf Ebrahimi `binary`. 77*6467f958SSadaf Ebrahimi 78*6467f958SSadaf Ebrahimi* `--compilation-cache-mode` Controls how the compiled OpenCL-C source code 79*6467f958SSadaf Ebrahimi should be cached on disk. 80*6467f958SSadaf Ebrahimi 81*6467f958SSadaf Ebrahimi* `--compilation-cache-path` Accepts a path to a directory where the compiled 82*6467f958SSadaf Ebrahimi binary cache should be stored on disk. 83*6467f958SSadaf Ebrahimi 84*6467f958SSadaf Ebrahimi* `--compilation-program` Accepts a path to an executable (default: 85*6467f958SSadaf Ebrahimi cl_offline_compiler) invoked by the test harness to perform offline 86*6467f958SSadaf Ebrahimi compilation of OpenCL-C source code. This executable must match the 87*6467f958SSadaf Ebrahimi [interface description](test_common/harness/cl_offline_compiler-interface.txt). 88*6467f958SSadaf Ebrahimi 89*6467f958SSadaf Ebrahimi## Generating a Conformance Report 90*6467f958SSadaf Ebrahimi 91*6467f958SSadaf EbrahimiThe Khronos [Conformance Process Document](https://members.khronos.org/document/dl/911) 92*6467f958SSadaf Ebrahimidetails the steps required for a conformance submission. 93*6467f958SSadaf EbrahimiIn this repository [opencl_conformance_tests_full.csv](test_conformance/submission_details_template.txt) 94*6467f958SSadaf Ebrahimidefines the full list of tests which must be run for conformance. The output log 95*6467f958SSadaf Ebrahimiof which must be included alongside a filled in 96*6467f958SSadaf Ebrahimi[submission details template](test_conformance/submission_details_template.txt). 97*6467f958SSadaf Ebrahimi 98*6467f958SSadaf EbrahimiUtility script [run_conformance.py](test_conformance/run_conformance.py) can be 99*6467f958SSadaf Ebrahimiused to help generating the submission log, although it is not required. 100*6467f958SSadaf Ebrahimi 101*6467f958SSadaf EbrahimiGit [tags](https://github.com/KhronosGroup/OpenCL-CTS/tags) are used to define 102*6467f958SSadaf Ebrahimithe version of the repository conformance submissions are made against. 103*6467f958SSadaf Ebrahimi 104*6467f958SSadaf Ebrahimi## Contributing 105*6467f958SSadaf Ebrahimi 106*6467f958SSadaf EbrahimiContributions are welcome to the project from Khronos members and non-members 107*6467f958SSadaf Ebrahimialike via GitHub Pull Requests (PR). Alternatively, if you've found a bug or have 108*6467f958SSadaf Ebrahimia question please file an issue in the GitHub project. First time contributors 109*6467f958SSadaf Ebrahimiwill be required to sign the Khronos Contributor License Agreement (CLA) before 110*6467f958SSadaf Ebrahimitheir PR can be merged. 111*6467f958SSadaf Ebrahimi 112*6467f958SSadaf EbrahimiPRs to the repository are required to be `clang-format` clean to pass CI. 113*6467f958SSadaf EbrahimiDevelopers can either use the `git-clang-format` tool locally to verify this 114*6467f958SSadaf Ebrahimibefore contributing, or update their PR based on the diff provided by a failing 115*6467f958SSadaf EbrahimiCI job. 116