Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error CL_INVALID_KERNEL_NAME when I use cl_khr_fp64 in a kernel

Tags:

opencl

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

like image 851
Zhen Avatar asked Nov 22 '11 08:11

Zhen


1 Answers

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"
like image 81
Zhen Avatar answered Oct 25 '22 10:10

Zhen