Hi everyone,
I got puzzled when using the function clCreateKernel in my program. It returned CL_INVALID_PROGRAM_EXECUTABLE. This is how I wrote my codes(partly):
................
kernelFile.open("source.cl");
const char * source = kernelFile.source().c_str();
sourceSize = strlen(source) ;
program = clCreateProgramWithSource(context,1,&source,&sourceSize,&status);
if(!sampleCommon->checkVal(status,CL_SUCCESS,"clCreateProgramWithSource failed."))
{
return PROGRAM_FAILURE;
}
/* create a cl program executable for all the devices specified */
status = clBuildProgram(program, 1, devices, NULL, NULL, NULL);
if(!sampleCommon->checkVal(status,CL_SUCCESS,"clBuildProgram failed."))
{
return PROGRAM_FAILURE;
}
/* get kernel object handles for kernels with the given name */
kernel_dx1 = clCreateKernel(program, "kernel_dx1", &status);
if(!sampleCommon->checkVal(status,CL_SUCCESS,"clCreateKernel kernel_dx1 failed."))
{
return PROGRAM_FAILURE;
}
kernel_dx2 = clCreateKernel(program, "kernel_dx2", &status);
if(!sampleCommon->checkVal(status,CL_SUCCESS,"clCreateKernel kernel_dx2 failed."))
{
return PROGRAM_FAILURE;
}
..................................
it is strange that before clCreateKernel(program, “kernel_dx1”, &status), it ran successfully. that is clBuildProgram returned CL_SUCCESS.
but clCreateKernel failed with CL_INVALID_PROGRAM_EXECUTABLE.
And it is also strange that I compiled and ran the entire code on Windows VS.2008, it was totally okay. Is there something wrong with the code in linux?
thanks