Here is the function declaration in OpenCL 1.2. I have chosen only one GPU device with CL_DEVICE_TYPE_GPU for the whole program.
cl_int clGetProgramInfo (cl_program program,
cl_program_info param_name,
size_t param_value_size,
void *param_value,
size_t *param_value_size_ret)
err = clGetProgramInfo(program, CL_PROGRAM_BINARIES,
programSize, binary, &retSize);
After this call, I get ELF in binary[0]. However, binary[1-3] are set to 0x0, which are NULL pointers.
I just wonder, what is the root cause. This program work well on other platforms. Clinfo output is in the attachment.
Solved! Go to Solution.
Hi felix,
1. clGetProgramInfo with CL_PROGRAM_BINARIES needs a pointer to an array which u declared correct. But the size of this array should be equal to number of GPU devices. As you mentioned that you are using only one GPU device so instead of allocating 4 pointers for binary, you should use only 1 pointer.
2. The third argument of clGetProgramInfo is used to specify the size in bytes of memory pointed by binary. And hence change
err = clGetProgramInfo(program, CL_PROGRAM_BINARIES,
programSize, binary, &retSize); with
-->>
err = clGetProgramInfo(program, CL_PROGRAM_BINARIES,
n*sizeof(unsigned char *), binary, &retSize); //where n is number of GPU devices (in your case, it should be 1).
Modify your program accordingly, and post here if you still have some issue.
Thanks,
AMD_Support
Hi felix,
1. clGetProgramInfo with CL_PROGRAM_BINARIES needs a pointer to an array which u declared correct. But the size of this array should be equal to number of GPU devices. As you mentioned that you are using only one GPU device so instead of allocating 4 pointers for binary, you should use only 1 pointer.
2. The third argument of clGetProgramInfo is used to specify the size in bytes of memory pointed by binary. And hence change
err = clGetProgramInfo(program, CL_PROGRAM_BINARIES,
programSize, binary, &retSize); with
-->>
err = clGetProgramInfo(program, CL_PROGRAM_BINARIES,
n*sizeof(unsigned char *), binary, &retSize); //where n is number of GPU devices (in your case, it should be 1).
Modify your program accordingly, and post here if you still have some issue.
Thanks,
AMD_Support
It is the solution. Thank you very much.
The root cause is that I misunderstanding the third argument of clGetProgramInfo. When I change it to n*sizeof(unsigned char *), the program works.
I use four pointers to illustrate the problem. You could ignore it.