Adapt intercept layer to be used with native OPENCL_LAYERS - #474
Conversation
|
Thanks for taking a look at this! I'm definitely supportive of getting this working. I have a question about the high-level approach, though. Specifically, do we need to choose whether to use the system library method or the layer method at build time (ENABLE_OPENCL_NATIVE_LAYER) or can we choose between the two methods at runtime, instead? If we can switch between the two methods at runtime, then I think this has several advantages: there's only one build configuration to maintain, and a user wouldn't need to manage two binaries to switch between the two methods. Here's how I think this might work. The main difference between the layers method and the standard library replacement method is the dispatch table, as you have demonstrated. So, what if:
What do you think? Is this workable? One more specific comment: Please implement both |
Thank you for your interest in my implementation. Regarding this question, I actually think this approach is better. I'll try to implement it and verify that it doesn't introduce any issues. In theory, it should work, but it's better to validate it first. |
| INIT_NATIVE_LAYER_FUNC( clEnqueueAcquireDX9MediaSurfacesKHR ); | ||
| INIT_NATIVE_LAYER_FUNC( clEnqueueReleaseDX9MediaSurfacesKHR ); | ||
| #endif | ||
| INIT_NATIVE_LAYER_FUNC( clCreateCommandQueueWithProperties ); |
There was a problem hiding this comment.
Great, I think we're almost there now. We just need to wrap this block of OpenCL 2.0 and newer functions in:
#if !defined(__APPLE__)
Then, the Mac builds should be fixed.
| INIT_NATIVE_LAYER_FUNC( clSetProgramSpecializationConstant ); | ||
| INIT_NATIVE_LAYER_FUNC( clCreateBufferWithProperties ); | ||
| INIT_NATIVE_LAYER_FUNC( clCreateImageWithProperties ); | ||
| INIT_NATIVE_LAYER_FUNC( clSetContextDestructorCallback ); |
There was a problem hiding this comment.
Can you please add the new OpenCL 3.1 API here, also?
| INIT_NATIVE_LAYER_FUNC( clSetContextDestructorCallback ); | |
| INIT_NATIVE_LAYER_FUNC( clSetContextDestructorCallback ); | |
| INIT_NATIVE_LAYER_FUNC( clGetKernelSuggestedLocalWorkSize ); |
bashbaug
left a comment
There was a problem hiding this comment.
Thanks again for your contribution, this is really great!
Fixes #473
Description of Changes
This PR adapts the opencl-intercept-layer to function as a native Khronos OpenCL Layer. By enabling support for the OPENCL_LAYERS environment variable, it allows the system's Khronos ICD Loader to load the intercept layer cleanly and officially, eliminating the need to use a drop-in replacement for the system's OpenCL.dll.
Specifically, this change:
Testing Done