api/opencl.cpp¶
Namespaces¶
| Name |
|---|
| cvedia |
| cvedia::rt API for controlling the server and lifecycle management of runtime instances. |
| cvedia::rt::api |
| cvedia::rt::api::opencl |
Functions¶
| Name | |
|---|---|
| std::recursive_mutex & | compilationMutex() Serialize OpenCL kernel compilation process-wide. |
Functions Documentation¶
function compilationMutex¶
std::recursive_mutex & compilationMutex()
Serialize OpenCL kernel compilation process-wide.
Intel's OpenCL compiler stack (IGC / opencl-clang) is not safe for concurrent invocation within one process: overlapping compile calls corrupt shared compiler state and crash with a NULL write inside libopencl-clang's Compile() (RT-2548). Compilation reaches the compiler from several separately loaded modules – OpenVINO GPU model compilation (whose internal compilation pool is additionally bounded to one thread), the OpenCL buffer plugin's lazily built kernels, the inference preprocessing kernels and the OpenCL motion kernels – so every clBuildProgram call and each GPU compile_model() must hold this mutex.
Serializing compile_model() calls also collapses concurrent cold-start compilations of the same model into one compile plus cache hits, because followers only start after the first compile has populated the OpenVINO model cache.
The mutex is owned by the core (not by a plugin module) so a single instance is visible across the separately loaded plugin modules that compile OpenCL kernels. Recursive, so a thread already holding it may re-enter helpers that re-acquire it. Thread-safe.