Manual-sync mirror of chromium.googlesource.com/external/github.com/KhronosGroup/OpenCL-CTS
Find a file
Romaric Jodin 30185979a0
ci: Update result tracking with new golden format (#2706)
The primary goal of this commit is to improve CI tracking by
introducing a new golden format that can differentiate test results
based on command-line arguments. To cleanly extract and pass these
arguments into the JSON result outputs, the command-line parsing
infrastructure across the CTS required a significant refactoring.

Key changes include:
* Enhanced CI Tracking: Updates `ci/compare_results.py`,
`ci/pocl/golden.json`, and `saveResultsToJson` to include and evaluate
an `args` key. The golden JSON now uses a nested format mapping
specific argument strings (e.g., `--wimpy -1`) to their expected
results, allowing the CI to validate the same binary run under
different parameters.
* Centralized Parsing Infrastructure: Introduces the `ParseArgsFn`
callback and `runTestHarnessWithCheckAndParse`. This offloads custom
argument parsing from individual test `main()` functions and safely
extracts the arguments used so they can be logged by the test harness.
* Help Text Consolidation: Replaces fragmented `printUsage()`
functions with unified `help` string references populated directly by
the standard parsing callbacks.

As agreed on 30Jun26 call
2026-06-30 09:16:58 -07:00
.github Bump actions/cache from 4 to 5 in the github-actions group (#2708) 2026-06-02 08:50:53 -07:00
ci ci: Update result tracking with new golden format (#2706) 2026-06-30 09:16:58 -07:00
test_common ci: Update result tracking with new golden format (#2706) 2026-06-30 09:16:58 -07:00
test_conformance ci: Update result tracking with new golden format (#2706) 2026-06-30 09:16:58 -07:00
.clang-format clang-format: indent continued lines (#739) 2020-04-17 10:54:58 +01:00
.gitignore [NFC] Add .gitignore file (#2216) 2025-01-09 20:55:37 -08:00
check-format.sh Bump clang-format version to 14 (#1983) 2024-06-25 09:44:31 -07:00
CMakeLists.txt cmake: Add asan and ubsan sanitizer options (#2672) 2026-05-12 09:07:54 -07:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2018-10-10 16:02:58 -04:00
LICENSE.txt Change name to LICENSE.txt, revert to Apache 2.0 2018-10-03 10:08:39 -04:00
README.md Add dynamic PR testing with golden reference comparison (#2664) 2026-05-26 08:47:48 -07:00

OpenCL Conformance Test Suite (CTS)

This is the OpenCL CTS for all versions of the Khronos OpenCL standard.

Building the CTS

The CTS supports Linux, Windows, macOS, and Android platforms. In particular, GitHub Actions CI builds against Ubuntu 20.04, Windows-latest, and macos-latest.

Compiling the CTS requires the following CMake configuration options to be set:

  • CL_INCLUDE_DIR Points to the unified OpenCL-Headers.
  • SPIRV_INCLUDE_DIR Points to the unified SPIRV-Headers.
  • CL_LIB_DIR Directory containing the OpenCL library to build against.
  • SPIRV_TOOLS_DIR Directory containing the spirv-as and spirv-val binaries to be used in the CTS build process. Alternatively, the location to these binaries can be provided via the PATH variable.
  • OPENCL_LIBRARIES Name of the OpenCL library to link.

It is advised that the OpenCL ICD-Loader is used as the OpenCL library to build against. Where CL_LIB_DIR points to a build of the ICD loader and OPENCL_LIBRARIES is "OpenCL".

Example Build

Steps on a Linux platform to clone dependencies from GitHub sources, configure a build, and compile.

git clone https://github.com/KhronosGroup/OpenCL-CTS.git
git clone https://github.com/KhronosGroup/OpenCL-Headers.git
git clone https://github.com/KhronosGroup/SPIRV-Headers.git
git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader.git
git clone https://github.com/KhronosGroup/SPIRV-Tools.git
git clone https://github.com/KhronosGroup/SPIRV-Headers.git SPIRV-Tools/external/spirv-headers
git clone https://github.com/google/effcee.git SPIRV-Tools/external/effcee
git clone https://github.com/google/re2.git SPIRV-Tools/external/re2


mkdir OpenCL-ICD-Loader/build
cmake -S OpenCL-ICD-Loader -B OpenCL-ICD-Loader/build \
      -DOPENCL_ICD_LOADER_HEADERS_DIR=$PWD/OpenCL-Headers
cmake --build ./OpenCL-ICD-Loader/build --config Release

mkdir SPIRV-Tools/build
cmake -S SPIRV-Tools -B SPIRV-Tools/build -DSPIRV_SKIP_TESTS=ON
cmake --build SPIRV-Tools/build --config Release

mkdir OpenCL-CTS/build
cmake -S OpenCL-CTS -B OpenCL-CTS/build \
      -DCL_INCLUDE_DIR=$PWD/OpenCL-Headers \
      -DSPIRV_INCLUDE_DIR=$PWD/SPIRV-Headers \
      -DCL_LIB_DIR=$PWD/OpenCL-ICD-Loader/build \
      -DSPIRV_TOOLS_DIR=$PWD/SPIRV-Tools/build/tools/ \
      -DOPENCL_LIBRARIES=OpenCL
cmake --build OpenCL-CTS/build --config Release

Running the CTS

A build of the CTS contains multiple executables representing the directories in the test_conformance folder. Each of these executables contains sub-tests, and possibly smaller granularities of testing within the sub-tests.

See the --help output on each executable for the list of sub-tests available, as well as other options for configuring execution.

If the OpenCL library built against is the ICD Loader, and the vendor library to be tested is not registered in the default ICD Loader location then the OCL_ICD_FILENAMES environment variable will need to be set for the ICD Loader to detect the OpenCL library to use at runtime. For example, to run the basic tests on a Linux platform:

OCL_ICD_FILENAMES=/path/to/vendor_lib.so ./test_basic

Offline Compilation

Testing OpenCL drivers which do not have a runtime compiler can be done by using additional command line arguments provided by the test harness for tests which require compilation, these are:

  • --compilation-mode Selects if OpenCL-C source code should be compiled using an external tool before being passed on to the OpenCL driver in that form for testing. Online is the default mode, but also accepts the values spir-v, and binary.

  • --compilation-cache-mode Controls how the compiled OpenCL-C source code should be cached on disk.

  • --compilation-cache-path Accepts a path to a directory where the compiled binary cache should be stored on disk.

  • --compilation-program Accepts a path to an executable (default: cl_offline_compiler) invoked by the test harness to perform offline compilation of OpenCL-C source code. This executable must match the interface description.

Generating a Conformance Report

The Khronos Conformance Process Document details the steps required for a conformance submission. In this repository opencl_conformance_tests_full.csv defines the full list of tests which must be run for conformance. The output log of which must be included alongside a filled in submission details template.

Utility script run_conformance.py can be used to help generating the submission log, although it is not required.

Git tags are used to define the version of the repository conformance submissions are made against.

Contributing

Contributions are welcome to the project from Khronos members and non-members alike via GitHub Pull Requests (PR). Alternatively, if you've found a bug or have a question please file an issue in the GitHub project. First time contributors will be required to sign the Khronos Contributor License Agreement (CLA) before their PR can be merged.

PRs to the repository are required to be clang-format clean to pass CI. Developers can either use the git-clang-format tool locally to verify this before contributing, or update their PR based on the diff provided by a failing CI job.

Running Targeted CI Tests on Pull Requests

To help verify fixes or check for regressions without running the entire conformance test suite, our continuous integration pipeline allows contributor to trigger specific tests on Pull Requests against the pocl implementation.

How to Trigger Tests

Testing is triggered by adding a special tag to either your Pull Request description or in any of your commit messages.

The CI parses the text for the following syntax: [run-test: <command>]

Multiples tags for a single Pull Request is supported.

Examples

[run-test: test_bruteforce exp -w -1]