Hello,
I have the code:
char* string = "monday";
How can I execute the monday function without using if, case branching?
Using if-case branching. Even if OpenCL C were a high-level language with string-based dispatch, the runtime would only end up doing that anyway. OpenCL C is slightly more limited even than C in this because the functions have to be able to be inlined, so even computed branches and a function pointer table doesn't really work.
Are you looking to launch an OpenCL Kernel with the name "monday" from host ?
OR
Are you looking to call an OpenCL Function with the name "monday" from within an OpenCL kernel?
I am looking to an OpenCL function call within an OpenCL kernel. But an OpenCL kernel execution from host is also appreciated.
For OpenCl function calls from inside an OpenCL kernel, As Lee indicated, you need to go with "if-else".
If outside, you can create an appropriate cl_kernel object using "clCreateKernel" and pass the cl_kernel as the argument to clEnqueueNDRange API