/opencl:openclfrom opencl
Provides OpenCL SDK guidance for cross-platform GPU/CPU parallel computing in C and C++. Covers kernel writing, device/context/queue management, buffer allocation, program building, and C++ wrapper usage (opencl.hpp).
Ships in opencl. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Version: v2026.05.29 (Khronos Group OpenCL-SDK) Language: C (OpenCL 1.0–3.1) / C++ (opencl.hpp wrapper) License: Apache-2.0 Repo: https://github.com/KhronosGroup/OpenCL-SDK
OpenCL (Open Computing Language) is a framework for parallel programming across heterogeneous platforms — GPUs, CPUs, FPGAs, and DSPs — from a single API. The SDK bundles:
<CL/cl.h>, <CL/cl_ext.h>)<CL/opencl.hpp>)<CL/Utils/>, <CL/SDK/>)Kernel file saxpy.cl:
__kernel void saxpy(float a, __global float *x, __global float *y) {
int i = get_global_id(0);
y[i] = fma(a, x[i], y[i]);
}
Host:
#include <CL/cl.h>
cl_platform_id plat; cl_device_id dev;
clGetPlatformIDs(1, &plat, NULL);
clGetDeviceIDs(plat, CL_DEVICE_TYPE_DEFAULT, 1, &dev, NULL);
cl_context ctx = clCreateContext(NULL, 1, &dev, NULL, NULL, &err);
cl_command_queue q = clCreateCommandQueueWithProperties(ctx, dev, NULL, &err);
// ... load source, clCreateProgramWithSource, clBuildProgram,
// clCreateKernel, clSetKernelArg, clEnqueueNDRangeKernel,
// clEnqueueReadBuffer, clReleaseXxx ...
#define CL_HPP_ENABLE_EXCEPTIONS
#define CL_HPP_TARGET_OPENCL_VERSION 300 // default is now 310 (OpenCL 3.1); minimum 200
#include <CL/opencl.hpp>
cl::Context ctx{CL_DEVICE_TYPE_DEFAULT};
cl::Device dev = ctx.getInfo<CL_CONTEXT_DEVICES>()[0];
cl::CommandQueue queue{ctx, dev};
cl::Program prog{ctx, source_string};
prog.build(dev);
auto saxpy = cl::KernelFunctor<cl_float, cl::Buffer, cl::Buffer>(prog, "saxpy");
saxpy(cl::EnqueueArgs{queue, cl::NDRange{N}}, a, buf_x, buf_y);
__kernel function compiled from OpenCL C source or SPIR-V__global (buffers), __local (shared), __constant (read-only), __private (per-item)| Domain | Reference File | Key Functions / Types |
|---|---|---|
| Platform & Device | references/api-platform-device.md | clGetPlatformIDs, clGetDeviceIDs, clGetDeviceInfo, clCreateSubDevices, UUID/LUID & SPIR-V queries (3.1), timer APIs |
| Context & Queue | references/api-context-queue.md | clCreateContext, clCreateCommandQueueWithProperties, clFlush, clFinish, destructor callbacks |
| Memory Objects | references/api-memory.md | clCreateBuffer, clCreateImage, enqueue read/write/copy/fill, map/unmap, pipes, samplers, SVM |
| Programs & Kernels | references/api-program-kernel.md | clCreateProgramWithSource, clBuildProgram, clCompileProgram, clLinkProgram, clCreateKernel, clGetKernelSuggestedLocalWorkSize (3.1), sub-group queries |
| Execution & Events | references/api-execution.md | clEnqueueNDRangeKernel, clWaitForEvents, clSetEventCallback, profiling, extension access |
| C++ Wrapper | references/api-cpp-wrapper.md | cl::Context, cl::Buffer, cl::Pipe, cl::Sampler, cl::KernelFunctor, cl::SVMAllocator, exceptions |
| Workflows | references/workflows.md | Quick-start, vector add, image blur, async events, binary caching, error handling |
See references/workflows.md for complete, runnable examples:
KernelFunctor pattern with RAIIread_imageui / write_imageuiInclude <CL/Utils/Utils.h> (C) or <CL/Utils/Utils.hpp> (C++) and link OpenCLUtils / OpenCLUtilsCpp.
| Header | API |
|---|---|
<CL/Utils/Context.h> | cl_util_get_device, cl_util_get_context, cl_util_print_device_info |
<CL/Utils/File.h> | cl_util_read_text_file, cl_util_read_exe_relative_text_file, cl_util_write_binaries |
<CL/Utils/Error.h> | OCLERROR_RET, OCLERROR_PAR, MEM_CHECK macros, cl_util_print_error |
<CL/Utils/Event.h> | cl_util_get_event_duration |
<CL/Utils/Device.hpp> | cl::util::supports_extension, cl::util::supports_feature |
SDK Library (samples only, not installed): <CL/SDK/CLI.h>, <CL/SDK/Random.h>, <CL/SDK/Image.h>.
Release everything: Every clCreate* call must be paired with the corresponding clRelease*. Leak buffers or kernels and you exhaust device memory silently.
Blocking vs. non-blocking transfers: clEnqueueReadBuffer(..., CL_TRUE, ...) blocks the CPU. Use CL_FALSE + events for overlap. Always clFlush before blocking on an event from another thread.
Local work-group size: Must evenly divide global work size in each dimension. Query CL_KERNEL_WORK_GROUP_SIZE for the max; CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE for optimal alignment. Passing NULL lets the runtime choose (portable, not always optimal).
Build log on failure: clBuildProgram returns CL_BUILD_PROGRAM_FAILURE — always query CL_PROGRAM_BUILD_LOG to get the compiler error message. The SDK's cl_util_build_program does this automatically.
Image format validation: Not all cl_image_format combinations are supported on every device. Call clGetSupportedImageFormats before creating images.
Event callbacks must not block: Callbacks registered via clSetEventCallback are invoked from a runtime thread. Never call clFinish or clWaitForEvents inside a callback.
C++ exceptions: Enable with #define CL_HPP_ENABLE_EXCEPTIONS before including <CL/opencl.hpp>. Without it, check cl_int error parameters manually.
OpenCL version targeting: Set CL_HPP_TARGET_OPENCL_VERSION (e.g., 310, 300, 200, 120) to control which API surface is available in the C++ wrapper. As of this SDK the default is 310 (OpenCL 3.1) and the minimum is 200; the C headers default CL_TARGET_OPENCL_VERSION to 310 too. OpenCL 1.x deprecated clCreateCommandQueue; use clCreateCommandQueueWithProperties for 2.0+.
OpenCL 3.1 additions: clGetKernelSuggestedLocalWorkSize (query the runtime's optimal local size for an NDRange) is now core, along with device queries CL_DEVICE_UUID / CL_DRIVER_UUID, CL_DEVICE_LUID / CL_DEVICE_LUID_VALID / CL_DEVICE_NODE_MASK, integer dot-product capabilities, and SPIR-V extension/capability queries — all previously KHR extensions. In C++, use queue.getKernelSuggestedLocalWorkSize(...) and #define CL_HPP_CUSTOM_EXCEPTION_TYPE to plug your own exception class. CL_DEVICE_MAX_WORK_ITEM_SIZES is now spelled CL_DEVICE_MAX_WORK_GROUP_SIZES (same value; old name deprecated).
SVM requires OpenCL 2.0+: Shared Virtual Memory (clSVMAlloc) requires device support for CL_DEVICE_SVM_CAPABILITIES. Check before use.
references/api-context-queue.md (opens in a new tab)references/api-cpp-wrapper.md (opens in a new tab)references/api-execution.md (opens in a new tab)references/api-memory.md (opens in a new tab)references/api-platform-device.md (opens in a new tab)references/api-program-kernel.md (opens in a new tab)references/workflows.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub datathings/marketplace --plugin openclOther plugins' skills for the same job