0

running an openCl application it gives me this error:

ERROR: clBuildProgram(CL_BUILD_PROGRAM_FAILURE)

this is the kernel definition, one error is in the log2 function,

another error is in char* bits = &(char_array[64*(n/m)*(index-1)+it*64]);

another error is in max[it] = *count

and the last error is in if(max[i] > *result){*result = max[i];}.

could you tell me how to correct the definition? Thanks

__kernel void vadd(
    __global char* char_array,
    int m,
    int n,
    __global long* result)
{ 

    int index = get_global_id(0);
    int max_n = n/m;
    if(index == m-1){
        max_n = n - (n/m)*(m-1);
    }

    int max[ max_n ];
    int offset = log2(m);
    for (int it=0; it < max_n; it++)
    {
        char* bits = &(char_array[64*(n/m)*(index-1)+it*64]);
        int count=0;
        for(int i=offset; i<=64; i++)
        {
            if(bits[i]=='0'){
                count++;
            }else{break;}
        }
        max[it] = count;
    }

    *result = 0;
    for(int i=0; i<max_n;i++)
    {
        if(max[i] > *result){*result = max[i];}
    }
    *result = *result +1;
}
3
  • Would you perhaps simply quote the entire build log? The error messages will save us a lot of time trying to work out what's not right. Commented Feb 4, 2020 at 20:07
  • }catch (cl::Error err) { std::cout << "Exception\n"; std::cerr << "ERROR: " << err.what() << "(" << err_code(err.err()) << ")" << std::endl; this is what i have in the host, and the error reported is all that is given at runtime Commented Feb 4, 2020 at 20:23
  • You can get a detailed compile log by querying the CL_PROGRAM_BUILD_LOG with clGetProgramBuildInfo. Commented Feb 4, 2020 at 20:32

1 Answer 1

1

A mistake on this line:

char* bits = &(char_array[64*(n/m)*(index-1)+it*64]);

is that char* bits when declaring a local variable actually means __private char*, whereas char_array is defined as __global char*. You'll want to make sure that bits uses the same type.

The others aren't immediately obvious to me, but I recommend you add the complete kernel build output to your question as this will help narrow it down.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.