I have an error in an OpenCL kernel, when I try to use the cl_khr_fp64 extension, the kernel compiles and the build log is empty, but when I call clCreateKernel
, I have CL_INVALID_KERNEL_NAME error.
The source that fails:
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
__kernel void simple( __global char *x, __global char *y ){
int id = get_global_id(0);
y[id]=2*x[id];
}
This source compiles right:
__kernel void simple( __global char *x, __global char *y ){
int id = get_global_id(0);
y[id]=2*x[id];
}
I'm using OpenCL 1.0 with a Tesla C1060 that have cl_khr_fp64 in CL_DEVICE_EXTENSIONS, driver 280.13 and CL_PLATFORM_VERSION=OpenCL 1.1 CUDA 4.0.1
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With