cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

ствнислав
Journeyman III

My first program from OpenCL

Jump to solution

Hello. This is my first program from OpenCL, but dosn't work. Help me pls. What's wrong with this?


clBuildProgram(program1, 0, NULL, clcompileflags, NULL, NULL); return error code -11

PS: sorry for my bad english

Tags (1)
0 Likes
1 Solution

Accepted Solutions
dipak
Staff
Staff

Re: My first program from OpenCL

Jump to solution

Hi,

Welcome to the OpenCL community.

After calling the API clBuildProgram() [ i.e. [line] clerr = clBuildProgram(program1, 0, NULL, clcompileflags, NULL, NULL); ], please call clGetProgramBuildInfo() with param_name CL_PROGRAM_BUILD_LOG (see clGetProgramBuildInfo) to check details of the compilation error.


For your reference, you can add similar to the following code to get the details:

[Note: please replace variables with BOLD letters corresponding to your program variables]

-------------------------------------------------------------------------------------------------------------------------------------

if (clerr!= CL_SUCCESS){

        for (unsigned i=0; i<NUM_DEVICE; i++)

        {

        char *str;

        size_t sstr;

   

        status = clGetProgramBuildInfo(PROGRAM, DEVICE_LIST, CL_PROGRAM_BUILD_LOG, NULL, NULL, &sstr);

        str = (char*)malloc(sstr);

       

        if (str == NULL)

        {exit(-1);}

        status |= clGetProgramBuildInfo(PROGRAM, DEVICE_LIST, CL_PROGRAM_BUILD_LOG, sstr, str, NULL);

        printf("\nBuild Log:\t %s \n", str);

        free(str);

        if (status != CL_SUCCESS)

        {exit(-1);}

        }

     exit(-1);

    }

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Hope you'll be able to debug your kernel code.

Regards,

View solution in original post

0 Likes
2 Replies
nou
Exemplar

Re: My first program from OpenCL

Jump to solution

you don't have newline \n behind that comment in kernel source. your whole kernel code is on single line. best is don't include that comment into kernel source at all. remove quotation marks around it and leave it only as comment in host code. somehow that file have messed encoding.


const char *vaddsrc = "__kernel void vadd(__global float *d_A, __global float *d_B, __global float *d_C)"


"{"


    "unsigned int n;"


    // Ďîëó÷ĺíčĺ óíčęŕëüíîăî čäĺíňčôčęŕňîđŕ đŕáî÷ĺăî ýëĺěĺíňŕ


    "n = get_global_id(0);"


    "d_C = d_A + d_B;"


"}";


0 Likes
dipak
Staff
Staff

Re: My first program from OpenCL

Jump to solution

Hi,

Welcome to the OpenCL community.

After calling the API clBuildProgram() [ i.e. [line] clerr = clBuildProgram(program1, 0, NULL, clcompileflags, NULL, NULL); ], please call clGetProgramBuildInfo() with param_name CL_PROGRAM_BUILD_LOG (see clGetProgramBuildInfo) to check details of the compilation error.


For your reference, you can add similar to the following code to get the details:

[Note: please replace variables with BOLD letters corresponding to your program variables]

-------------------------------------------------------------------------------------------------------------------------------------

if (clerr!= CL_SUCCESS){

        for (unsigned i=0; i<NUM_DEVICE; i++)

        {

        char *str;

        size_t sstr;

   

        status = clGetProgramBuildInfo(PROGRAM, DEVICE_LIST, CL_PROGRAM_BUILD_LOG, NULL, NULL, &sstr);

        str = (char*)malloc(sstr);

       

        if (str == NULL)

        {exit(-1);}

        status |= clGetProgramBuildInfo(PROGRAM, DEVICE_LIST, CL_PROGRAM_BUILD_LOG, sstr, str, NULL);

        printf("\nBuild Log:\t %s \n", str);

        free(str);

        if (status != CL_SUCCESS)

        {exit(-1);}

        }

     exit(-1);

    }

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Hope you'll be able to debug your kernel code.

Regards,

View solution in original post

0 Likes