Troubles with clBuildProgram...

First hello to everybody and sorry for my english i’m an spanish speaker =), its my first time here and i want to congrats to everyone that colaborate ont his subject. Let’s go to the problem, i built my own “oclLoadProgSource” using the standart method for reading files in C, this is:

   FILE *fp;
   fp = fopen("", "r");
   if (!fp) {
     fprintf(stderr, "Failed to load kernel.
   kernelLength = ftell(fp);
   char *clMatrixMul = (char *) malloc (kernelLength);
Cantidad de caracteres: %i. 

but when i do this:

   clProgram = clCreateProgramWithSource(clGPUContext, 
                1,(const char **)&clMatrixMul, 
   clCheckErr(errcode, "clCreateProgramWithSource");

   errcode = clBuildProgram(clProgram,0, 
   clCheckErr(errcode, "clBuildProgram");

appear to be a problem with clBuildProgram. I’m not sure if i’m doing well the read of the file, and clCreateProgramWithSource it’s well constructed.


I think your program looks fine. You can try and print the file to your screen to see if reading it was successful.

But I guess that you have a bug in your kernel code, i.e. in the file “”. In this case, clBuildProgram will fail. Have a look at your kernel code again and see if you can find the error. If not, just post it here.

Use clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, …) to get more Info about the Build. I do this even for successfull build to get all warning.

Thanks for your answers, i’m looking the clGetProgramBuildInfo and it appear to be an error on the, fantastic!. I will continue looking this code this night and tomorrow will tells you if that was my only error. Thanks again!

By googling I found this page, and while playing with OpenCL I even discovered the original poster’s bug :slight_smile:
Where’s the ‘\0’ at the end of your loaded sources?!? :wink: