Visible to Intel only — GUID: ewa1444245039361
Ixiasoft
Visible to Intel only — GUID: ewa1444245039361
Ixiasoft
11.1. Multi-Threaded Host Application
The figure below illustrates how a single-threaded host application might process parallel, independent data paths between kernel executions:
The OpenCL runtime is thread safe and supports multithreaded applications. Thus, you can perform work tasks on the host in parallel threads while still allowing those threads to access the OpenCL APIs in a thread-safe way.
However, thread safety is enforced at the OpenCL API boundary by synchronizing threads immediately after any OpenCL host API is called, which means, only one thread is ever active in the runtime while the other threads wait. As such, if one thread calls clFlinish on a queue full of work, another thread calling clSetKernelArg may have to wait for all of that work to complete before executing.
If possible, process data on CPU on multiple-threads, and use single dedicated thread to interact with the OpenCL API.
The figure below illustrates how a multi-threaded host application processes parallel, independent data paths between kernel executions: