View Full Version : Get binary of kernel - clGetProgramInfo

09-14-2012, 01:41 PM

thank anyone who can help me.

I need that my code run without be compiled in execution time.

When i run the host code, in this line a error of access in memory occurs.

errcode = clGetProgramInfo(program, CL_PROGRAM_BINARIES, binary_sizes[0] * sizeof(size_t), teste_aloprado,&quantidadecopiadaparamvalue);

The all code of that i tried follows:

errcode = clGetProgramInfo(program, CL_PROGRAM_BINARY_SIZES,num_dispositivos * sizeof(size_t), binary_sizes, &quantidadecopiadaparamvalue);
cout << "\nForam copiados: " << quantidadecopiadaparamvalue << "\n";

if( errcode == CL_SUCCESS )
cout << "\nA quantidade de Bytes é: " << binary_sizes[0];
cout << "\nNão retornou a quantidade de bytes.";

char **binary = (char **) malloc(num_dispositivos * sizeof(char*));
for(int i = 0; i < num_dispositivos; i++ )
binary[i] = (char *) malloc(binary_sizes[i] * sizeof(char));
size_t *teste_aloprado = (size_t *) malloc(binary_sizes[0] * sizeof(size_t));
errcode = clGetProgramInfo(program, CL_PROGRAM_BINARIES, binary_sizes[0] * sizeof(size_t), teste_aloprado,&quantidadecopiadaparamvalue);

09-18-2012, 12:06 PM
No one know how to help me?

09-19-2012, 06:28 AM
It would help if you posted the actual error code returned, but it looks like you're passing the wrong arguments. You should be passing binary rather than teste_aloprado, and the size should I think be num_dispositivos * sizeof(unsigned char *).

Technically each time you've used char it should be unsigned char, but in reality I don't think it'll make much difference.

I've written a tool that does this extraction, which you can see at http://gitorious.org/onlineclc/onlinecl ... nlineclc.c (http://gitorious.org/onlineclc/onlineclc/blobs/master/onlineclc.c). It only handles one device, but it might still be useful as sample code.

09-19-2012, 01:45 PM
Very Thanks,

Works fine now

09-28-2012, 11:37 AM

I succeeded get binary and save in a file.

But, in clgetprogramwithbinary and in
sivia = clCreateKernel(program,"sivia",&erro_create_kernel); ,
no error occurs, but when i call to run kernel the error below occurs:

Kernel Sivia deu zebra! -48
Identificacao do erro: CL_INVALID_KERNEL - -48
Error: Runtime failed to load kernels from OCL binary!

Very Thanks,


09-28-2012, 10:57 PM
I realized that i made a mistake.

At first it seems that i caught the binary and put in a file, and after load in a buffer.

When i loaded and made the program object with the binary with clCreateProgramWithBinary no error occurs, but in clCreateKernel(program,"sivia",&erro_create_kernel);


Very Thanks for help

10-01-2012, 08:21 AM
bmerry or other person that can help, what's happening with code?