Results 1 to 5 of 5

Thread: Troubles with clBuildProgram...

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    22

    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:

    Code :
       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:

    Code :
       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.

  2. #2
    Member
    Join Date
    Nov 2009
    Location
    Scotland
    Posts
    72

    Re: Troubles with clBuildProgram...

    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.

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Location
    Germany
    Posts
    21

    Re: Troubles with clBuildProgram...

    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.

  4. #4
    Junior Member
    Join Date
    Mar 2010
    Posts
    22

    Re: Troubles with clBuildProgram...

    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!

  5. #5
    Junior Member
    Join Date
    Aug 2009
    Posts
    8

    Re: Troubles with clBuildProgram...

    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?!?

Similar Threads

  1. clbuildprogram
    By evk8888 in forum OpenCL
    Replies: 0
    Last Post: 01-11-2012, 09:52 AM
  2. OpenGLES 1.0 & troubles with pbuffer - HELP
    By Gizmondetz in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 11-02-2005, 12:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •