PDA

View Full Version : Troubles with clBuildProgram...



santtt
03-18-2010, 09:05 AM
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("kernel2.cl", "r");
if (!fp) {
fprintf(stderr, "Failed to load kernel.\n");
exit(1);
}
fseek(fp,0,SEEK_END);
kernelLength = ftell(fp);
rewind(fp);
char *clMatrixMul = (char *) malloc (kernelLength);
fread(clMatrixMul,1,kernelLength,fp);
//printf("%s \nCantidad de caracteres: %i. \n",clMatrixMul,kernelLength/sizeof(char));
fclose(fp);


but when i do this:



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

errcode = clBuildProgram(clProgram,0,
NULL,"",NULL,NULL);
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.

Thanks.

dominik
03-18-2010, 10:17 AM
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 "kernel2.cl". 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.

Kratzy974
03-18-2010, 10:25 AM
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.

santtt
03-18-2010, 02:58 PM
Thanks for your answers, i'm looking the clGetProgramBuildInfo and it appear to be an error on the kernel2.cl, fantastic!. I will continue looking this code this night and tomorrow will tells you if that was my only error. Thanks again!

bubu
04-14-2010, 06:59 AM
By googling I found this page, and while playing with OpenCL I even discovered the original poster's bug :)
Where's the '\0' at the end of your loaded sources?!? ;)