- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When invoking clCreateKernelsInProgram to the same cl_program from many different threads. The Intel OpenCL runtime will randomly raise a CL_INVALID_VALUE error.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It should be thread safe according to OpenCL specification appendix A.2 ("Multiple Host Threads")
All OpenCL API calls are thread-safe except clSetKernelArg.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi YangB,
Thanks for your sighting.
- Which OCL runtime are you using and for which platform? Can you identify the version and/or install package you used?
- If you're using a runtime that leverages ocl spec >= 2.0 it's slightly different, if read extremely strictly the spec's section A.2 suggests any function that modifies the state of cl_kernel objects is not thread safe.
- Consequently, as a future proof solution I recommend staying away from unguarded clCreateKernelsInProgram calls in multiple host threads. My intent here is not to garner a discussion on how the spec should be or is, just an observation for how it can be interpreted.
- API References:
- 2.0 https://www.khronos.org/registry/OpenCL/sdk/2.0/docs/man/xhtml/clCreateKernelsInProgram.html
- 1.2 https://www.khronos.org/registry/OpenCL/sdk/1.2/docs/man/xhtml/clCreateKernelsInProgram.html
- Spec References:
- Can you give a minimal reproducer to demonstrate the issue? (While staying away from unsharable code of course?)
Thanks,
-MichaelC

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page