Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with clBuildProgram #1

Open
vmoprojs opened this issue Jan 3, 2019 · 0 comments
Open

Problem with clBuildProgram #1

vmoprojs opened this issue Jan 3, 2019 · 0 comments

Comments

@vmoprojs
Copy link

vmoprojs commented Jan 3, 2019

Hi,

Thanks for your very helpful examples. I have encountered a problem trying to use the pre built binary.

I successfully create my binary since I get the message PLATFORM [Apple] --> SUCCESS (1).

But, when trying to use the binary, the function clBuildProgram, gives the error code CL_BUILD_PROGRAM_FAILURE. ¿Any advice?

I'm using this code:

int length = int_par[1];
    
    
    
    cl_int err;
    
    // Query platforms and devices
    cl_platform_id platform;
    err = clGetPlatformIDs(1, &platform, NULL);
    
    cl_device_id device;
    err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, 1, &device, NULL);
    
    const cl_context_properties prop[] = {
        CL_CONTEXT_PLATFORM, (cl_context_properties)platform,
        0
    };
    
    // Create context
    cl_context context = clCreateContext(prop, 1, &device, NULL, NULL, &err);
    
    // Create program
    unsigned char* program_file = NULL;
    size_t program_size = 0;
    read_file1(&program_file, &program_size, "Kernel.clbin");
    
    cl_program program =
    clCreateProgramWithBinary(context, 1, &device, &program_size,
                              (const unsigned char **)&program_file,
                              NULL, &err);
   if(err!=CL_SUCCESS) Rprintf("clCreateProgramWithBinary!!!!\n%s\n", err_code(err));
err = clBuildProgram(program, 1, &device, NULL, NULL, NULL);
    
    free(program_file);
    
    if (err != CL_SUCCESS)
    {
        size_t len;
        //char buffer[2048*3000];
        
        Rprintf("Error: Failed to build program executable!\n%s\n", err_code(err));
        clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, NULL, &len);
        //char *buffer = (char *) malloc(len);
        //char *buffer = (char*)calloc(len, sizeof(char));
        char *buffer =calloc(len,sizeof(char));
        //memset(buffer, 0, len);
        clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, len, buffer, NULL);
        SEP;
        
        Rprintf("Build Log:\n%s\n", buffer);
        SEP;
        clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, sizeof(char), buffer, &len);
        Rprintf("Build Status:\n%s\n", buffer);
        SEP;
        clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_OPTIONS, sizeof(char), buffer, &len);
        Rprintf("Build Options:\n%s\n", buffer);
        SEP;
        //return EXIT_FAILURE;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant