Repository navigation
Conversation
…fy kernel argument setting
…argument handling
| CL_CHECK(clSetKernelArg(kernel, 11, sizeof(cl_ulong), &nb21)); | ||
| CL_CHECK(clSetKernelArg(kernel, 12, sizeof(int), &ne0)); | ||
| CL_CHECK(clSetKernelArg(kernel, 13, sizeof(int), &ne1)); | ||
| cl_set_kernel_args(kernel, src0, src1, src2, dst, nb01, nb02, nb11, nb21, ne0, ne1); |
There was a problem hiding this comment.
It might be worth considering a shared header for kernel signatures to prevent mismatches between the host and device.
Knowing the refactoring effort would be high, but it would guarantee consistency.
There was a problem hiding this comment.
Currently we use a simple script to read a kernel file and make it into a C++ string in a header file to embed the kernels into executable. Using headers in kernel files will greatly increase the complexity of embedding kernels.
There was a problem hiding this comment.
Currently we use a simple script to read a kernel file and make it into a C++ string in a header file to embed the kernels into executable.
Yeah, I saw the embed_kernel.py script that converts the CL source into string literals.
If we introduce a new header here, I think we could extend that script to handle #include directives by simply replacing them with the content of the header file from the same directory.
| src1->nb, | ||
| ne0, | ||
| dst->nb | ||
| ); |
There was a problem hiding this comment.
Heres a safer version of this function that'll check if the parameters match the cl kernel func signiture
… and update related structures
|
@lhez |
Refactors the OpenCL kernel argument initialization process by introducing a template helper, significantly reducing boilerplate code and improving readability.
Key Changes
cl_set_kernel_args: A variadic template function that automatically iterates through arguments and sets them usingclSetKernelArg.cl_kernel_arg_setterstruct specializations to handle different types:data_device) and calculates the offset (offset + view_offs), setting both as kernel arguments.int64_t[4]andsize_t[4]arrays into individual scalar arguments (e.g., ne0, ne1, ne2, ne3).int,float,cl_ulong.