@Override public Program createProgramFromSourceCode(String sourceCode) { LOG.log(Level.FINE, "Create program from source:\n{0}", sourceCode); Utils.errorBuffer.rewind(); CLProgram p = CL10.clCreateProgramWithSource(context, sourceCode, Utils.errorBuffer); Utils.checkError(Utils.errorBuffer, "clCreateProgramWithSource"); return new LwjglProgram(p, this); }
private String Log() { StringBuilder str = new StringBuilder(); for (LwjglDevice device : context.getDevices()) { long d = device.getDevice(); str.append(device.getName()).append(":\n"); //str.append(Info.clGetProgramBuildInfoStringASCII(program, d, CL10.CL_PROGRAM_BUILD_LOG)); //This throws an IllegalArgumentException in Buffer.limit() str.append(Log(d)); str.append('\n'); } return str.toString(); }
@Override public Program createProgramFromSourceCode(String sourceCode) { LOG.log(Level.FINE, "Create program from source:\n{0}", sourceCode); Utils.errorBuffer.rewind(); long p = CL10.clCreateProgramWithSource(context, sourceCode, Utils.errorBuffer); Utils.checkError(Utils.errorBuffer, "clCreateProgramWithSource"); return new LwjglProgram(p, this); }
@Override public void build(String args, Device... devices) throws KernelCompilationException { PointerBuffer deviceList = null; if (devices != null) { deviceList = PointerBuffer.allocateDirect(devices.length); deviceList.rewind(); for (Device d : devices) { deviceList.put(((LwjglDevice) d).getDevice()); } deviceList.flip(); } int ret = CL10.clBuildProgram(program, deviceList, args, null, 0); if (ret != CL10.CL_SUCCESS) { String log = Log(); LOG.log(Level.WARNING, "Unable to compile program:\n{0}", log); if (ret == CL10.CL_BUILD_PROGRAM_FAILURE) { throw new KernelCompilationException("Failed to build program", ret, log); } else { Utils.checkError(ret, "clBuildProgram"); } } else { LOG.log(Level.INFO, "Program compiled:\n{0}", Log()); } }
@Override public Program createProgramFromBinary(ByteBuffer binaries, Device device) { Utils.errorBuffer.rewind(); Utils.tempBuffers[0].b16i.rewind(); CLProgram p = CL10.clCreateProgramWithBinary(context, ((LwjglDevice) device).device, binaries, Utils.tempBuffers[0].b16i, Utils.errorBuffer); Utils.checkError(Utils.errorBuffer, "clCreateProgramWithBinary"); Utils.checkError(Utils.tempBuffers[0].b16i, "clCreateProgramWithBinary"); return new LwjglProgram(p, this); }
@Override public void build(String args, Device... devices) throws KernelCompilationException { PointerBuffer deviceList = null; if (devices != null) { deviceList = PointerBuffer.allocateDirect(devices.length); deviceList.rewind(); for (Device d : devices) { deviceList.put(((LwjglDevice) d).device.getPointer()); } deviceList.flip(); } int ret = CL10.clBuildProgram(program, deviceList, args, null); if (ret != CL10.CL_SUCCESS) { String log = Log(); LOG.log(Level.WARNING, "Unable to compile program:\n{0}", log); if (ret == CL10.CL_BUILD_PROGRAM_FAILURE) { throw new KernelCompilationException("Failed to build program", ret, log); } else { Utils.checkError(ret, "clBuildProgram"); } } else { LOG.log(Level.INFO, "Program compiled:\n{0}", Log()); } }
@Override public Program createProgramFromBinary(ByteBuffer binaries, Device device) { Utils.errorBuffer.rewind(); Utils.tempBuffers[0].b16i.rewind(); Utils.pointerBuffers[0].rewind(); Utils.pointerBuffers[0].put(0, ((LwjglDevice) device).getDevice()); long p = CL10.clCreateProgramWithBinary(context, Utils.pointerBuffers[0], binaries, Utils.tempBuffers[0].b16i, Utils.errorBuffer); Utils.checkError(Utils.errorBuffer, "clCreateProgramWithBinary"); Utils.checkError(Utils.tempBuffers[0].b16i, "clCreateProgramWithBinary"); return new LwjglProgram(p, this); }
private String Log() { StringBuilder str = new StringBuilder(); for (LwjglDevice device : context.getDevices()) { long d = device.getDevice(); str.append(device.getName()).append(":\n"); //str.append(Info.clGetProgramBuildInfoStringASCII(program, d, CL10.CL_PROGRAM_BUILD_LOG)); //This throws an IllegalArgumentException in Buffer.limit() str.append(Log(d)); str.append('\n'); } return str.toString(); }
@Override public Program createProgramFromSourceCode(String sourceCode) { LOG.log(Level.FINE, "Create program from source:\n{0}", sourceCode); Utils.errorBuffer.rewind(); long p = CL10.clCreateProgramWithSource(context, sourceCode, Utils.errorBuffer); Utils.checkError(Utils.errorBuffer, "clCreateProgramWithSource"); return new LwjglProgram(p, this); }
@Override public void build(String args, Device... devices) throws KernelCompilationException { PointerBuffer deviceList = null; if (devices != null) { deviceList = PointerBuffer.allocateDirect(devices.length); deviceList.rewind(); for (Device d : devices) { deviceList.put(((LwjglDevice) d).getDevice()); } deviceList.flip(); } int ret = CL10.clBuildProgram(program, deviceList, args, null, 0); if (ret != CL10.CL_SUCCESS) { String log = Log(); LOG.log(Level.WARNING, "Unable to compile program:\n{0}", log); if (ret == CL10.CL_BUILD_PROGRAM_FAILURE) { throw new KernelCompilationException("Failed to build program", ret, log); } else { Utils.checkError(ret, "clBuildProgram"); } } else { LOG.log(Level.INFO, "Program compiled:\n{0}", Log()); } }
@Override public Program createProgramFromBinary(ByteBuffer binaries, Device device) { Utils.errorBuffer.rewind(); Utils.tempBuffers[0].b16i.rewind(); Utils.pointerBuffers[0].rewind(); Utils.pointerBuffers[0].put(0, ((LwjglDevice) device).getDevice()); long p = CL10.clCreateProgramWithBinary(context, Utils.pointerBuffers[0], binaries, Utils.tempBuffers[0].b16i, Utils.errorBuffer); Utils.checkError(Utils.errorBuffer, "clCreateProgramWithBinary"); Utils.checkError(Utils.tempBuffers[0].b16i, "clCreateProgramWithBinary"); return new LwjglProgram(p, this); }