Thanks for the quick answer.
I already read the documentation of clGetProgramInfo, but since I am using only one device I thought I didnt have to retrieve the number of devices and the associated device IDs. But I did try it anyway the way it is described in the link you posted and I get the same error again. Since I am only using one device the size of the binary file buffer didnt change with that method. That is the way I am currently trying it:
int ret;
// Retrieve count of devices
ByteBuffer numDevicesBuf = BufferUtils.createByteBuffer(8);
ret = CL10.clGetProgramInfo(program, CL10.CL_PROGRAM_NUM_DEVICES, numDevicesBuf.capacity(), numDevicesBuf, null);
checkCLError(ret);
int numDevices = numDevicesBuf.getInt();
// Retrieve device ids
ByteBuffer deviceIdBuf = BufferUtils.createByteBuffer(8 * numDevices);
ret = CL10.clGetProgramInfo(program, CL10.CL_PROGRAM_DEVICES, deviceIdBuf.capacity(), deviceIdBuf, null);
checkCLError(ret);
List<Long> deviceIds = new ArrayList<>();
for(int i = 0; i < numDevices; i++) deviceIds.add(deviceIdBuf.getLong());
// Retrieve binary size of devices
ByteBuffer binarySizesBuf = BufferUtils.createByteBuffer(8 * numDevices);
ret = CL10.clGetProgramInfo(program, CL10.CL_PROGRAM_BINARY_SIZES, binarySizesBuf.capacity(), binarySizesBuf, null);
checkCLError(ret);
List<Long> binarySizes = new ArrayList<>();
long binarySize = 0;
for(int i = 0; i < numDevices; i++) {
binarySizes.add(binarySizesBuf.getLong());
binarySize += binarySizes.get(i);
}
// Retrieve binary files
ByteBuffer binaryBuf = BufferUtils.createByteBuffer((int) binarySize);
ret = CL10.clGetProgramInfo(program, CL10.CL_PROGRAM_BINARIES, binarySize, binaryBuf, null);
checkCLError(ret);
I am still unsure about the last part. I know that clGetProgramInfo with CL_PROGRAM_BINARIES is returning an array .Is it then the right way to have a single ByteBuffer "binaryBuf" with the size of all binary files together?
I saw in your provided example, that you just need pass the pointer, but how should it be implemented in Java then?