compat.opencl
#includeKhronos OpenCL ICD loader — the library an OpenCL program links
#include <CL/cl.h>
mcpp add compat.opencl@2026.05.29
用法
来自本仓库自己的测试项目 —— CI 真的编译并运行过,不是为了网站写的。
// 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 · 项目 tests/examples/opencl
构建
- targets
opencl (lib)- language
c++23- C standard
c11- import std
- no
- include dirs
*/loader, */include, mcpp_generated
源文件 (4)
*/loader/icd.c*/loader/icd_dispatch.c*/loader/icd_dispatch_generated.c*/loader/icd_trace.c
生成的文件
mcpp_generated/icd_cmake_config.h