Well, I agree that it doesn't seem to make much of a sense at first, but kernel functions are just functions that can have a pointer from the Host code. In other words, a __kernel can be called from inside the OpenCL code just like any other function.
Consider this: you create a OpenCL framework which requires the user to implement functions F and G. If either F or G are missing, the overall code won't compile, agree?
You can compile only the code supplied by the user (which your framework will call) to see if their implementation has mistakes. By using __kernel F and __kernel G, you can check whether F and G are implemented or not. Then AFTER that you may go on to the (slower) compilation of the entire framework with F and G embedded.
I know this is far-fetched in many ways, but my point is that since __kernel can be used just like any function there is a chance, however remote, that this could be useful.
For example, this code compiles without warning (note that there's even a variable local to the function itself):
| Code: |
__kernel void F(float x, __local float * y)
{
y[0] = x;
}
__kernel void myKernel1(__global float * z)
{
float x = 1.0f;
__local float y[5];
F(x, y);
}
|
Does that answer your question?