Adapt intercept layer to be used with native OPENCL_LAYERS - #474
Adapt intercept layer to be used with native OPENCL_LAYERS#474bigmat18 wants to merge 2 commits into
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. |
| /////////////////////////////////////////////////////////////////////////////// | ||
| // | ||
| #define INIT_NATIVE_LAYER_FUNC(funcname) \ | ||
| layer_dispatch . funcname = CLIRN(funcname) |
There was a problem hiding this comment.
Might need to do something similar to CHECK_RETURN_ICD_LOADER_EXTENSION_FUNCTION here to avoid casting warnings. Something like (note: untested):
| layer_dispatch . funcname = CLIRN(funcname) | |
| { \ | |
| void** pfunc = (void**)( &layer_dispatch . funcname ); \ | |
| *pfunc = CLIRN(funcname); \ | |
| } |
| if (param_value_size < sizeof(version)) | ||
| return CL_INVALID_VALUE; | ||
|
|
||
| std::memcpy(param_value, &version, sizeof(version)); |
There was a problem hiding this comment.
Suggest using CLI_MEMCPY here instead of std::memcpy.
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