mcpp index

compat.opencl

#include

Khronos OpenCL ICD loader — the library an OpenCL program links

#include <CL/cl.h>
mcpp add compat.opencl@2026.05.29

Usage

From this repository's own test project — built and run by CI, not written for the website.

// Behavioural test: compat.opencl builds a loader a consumer can link, and the
// loader can enumerate whatever the machine advertises.
//
// Zero platforms is a pass. Every CI runner in this repository has no OpenCL
// driver, and CL_PLATFORM_NOT_FOUND_KHR is the loader's own answer for that
// case; it proves the trampolines are linked and the ICD scan ran. A machine
// with a driver, or with xim:pocl announced through OCL_ICD_FILENAMES, lists
// its platforms and devices; the test prints them so the log says which case
// it measured.
//
// Classic includes rather than `import std;`: `CL/cl_platform.h` includes
// `<xmmintrin.h>`, which pulls `<stdlib.h>` into the global module before the
// std module is imported, and GCC then reports conflicting language linkage
// for the declarations both provide.
#include <cstdio>
#if !defined(HAVE_OPENCL_LOADER)
int main() {
    std::printf("compat.opencl: skipped (no windows entry; drivers are enumerated through the registry there)\n");
    return 0;
}
#else
#define CL_TARGET_OPENCL_VERSION 300
// …

tests/examples/opencl/tests/platforms.cpp · project tests/examples/opencl

Build

targets
opencl (lib)
language
c++23
C standard
c11
import std
no
include dirs
*/loader, */include, mcpp_generated

Sources (4)

  • */loader/icd.c
  • */loader/icd_dispatch.c
  • */loader/icd_dispatch_generated.c
  • */loader/icd_trace.c

Generated files

  • mcpp_generated/icd_cmake_config.h

Versions

VersionPlatforms Mirrorssha256
2026.05.29 latest LinuxmacOS GLOBAL CN 48fd0c5181db…