int pbSize = NativeSizeBuffer.elementSize();
int deviceCount = binaries.size();
CachedBufferFactory bf = CachedBufferFactory.create(binarySize + pbSize*deviceCount*3 + 4, true);
NativeSizeBuffer devices = NativeSizeBuffer.wrap(bf.newDirectByteBuffer(deviceCount*pbSize));
PointerBuffer codeBuffers = PointerBuffer.wrap(bf.newDirectByteBuffer(deviceCount*pbSize));
NativeSizeBuffer lengths = NativeSizeBuffer.wrap(bf.newDirectByteBuffer(deviceCount*pbSize));
int i = 0;
for (Map.Entry<CLDevice, byte[]> entry : entries) {
byte[] bytes = entry.getValue();
CLDevice device = entry.getKey();
devices.put(device.ID);
lengths.put(bytes.length);
codeBuffers.referenceBuffer(i, bf.newDirectByteBuffer(bytes));
i++;
}
devices.rewind();
lengths.rewind();
IntBuffer errBuffer = bf.newDirectIntBuffer(1);
// IntBuffer status = newDirectByteBuffer(binaries.size()*4).asIntBuffer();
CLProgramBinding binding = context.getPlatform().getProgramBinding();
long id = binding.clCreateProgramWithBinary(context.ID, devices.capacity(), devices, lengths, codeBuffers, /*status*/null, errBuffer);