Error CL_INVALID_KERNEL_NAME when I use cl_khr_fp64 in a kernel

The problem was that before call to clCreateProgramWithSource, we remove the newlines from source. E.g: the source:

"__kernel void f( __global char *x ){\nint id = get_global_id(0);\nx[id]=2;\n}"

Becomes:

"__kernel void simple( __global char *x, __global char *y ){"
"int id = get_global_id(0);"
"x[id]=2;}"

It causes no problem until we add the preproccessor directive.

It's the OpenCL preprocessor which actually wants newlines to be there. So, it should be written as:

"__kernel void simple( __global char *x, __global char *y ){\n"
"int id = get_global_id(0);\n"
"x[id]=2;}\n"

Tags:

Opencl