From 2694d25e5ce59c4f4741b60242331d56601f90d1 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Wed, 24 Feb 2010 17:59:23 +0100 Subject: initial import of CLProgramBuilder. --- src/com/mbien/opencl/CLProgram.java | 38 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'src/com/mbien/opencl/CLProgram.java') diff --git a/src/com/mbien/opencl/CLProgram.java b/src/com/mbien/opencl/CLProgram.java index 829809de..562df69b 100644 --- a/src/com/mbien/opencl/CLProgram.java +++ b/src/com/mbien/opencl/CLProgram.java @@ -206,6 +206,10 @@ public class CLProgram extends CLObject implements CLResource { */ public CLProgram build(String options, CLDevice... devices) { + if(released) { + throw new CLException("can not build a released program"); + } + if(!kernels.isEmpty()) { //No changes to the program executable are allowed while there are //kernel objects associated with a program object. @@ -214,7 +218,7 @@ public class CLProgram extends CLObject implements CLResource { PointerBuffer deviceIDs = null; int count = 0; - if(devices != null) { + if(devices != null && devices.length != 0) { deviceIDs = PointerBuffer.allocateDirect(devices.length); for (int i = 0; i < devices.length; i++) { deviceIDs.put(i, devices[i].ID); @@ -223,6 +227,11 @@ public class CLProgram extends CLObject implements CLResource { count = devices.length; } + // nvidia driver doesn't like empty strings + if(options != null && options.trim().isEmpty()) { + options = null; + } + // invalidate build status buildStatusMap = null; executable = false; @@ -237,6 +246,13 @@ public class CLProgram extends CLObject implements CLResource { return this; } + /** + * Prepares the build for this program by returning a {@link CLProgramBuilder}. + */ + public CLProgramBuilder prepare() { + return new CLProgramBuilder(this); + } + /** * Creates a kernel with the specified kernel name. */ @@ -255,24 +271,6 @@ public class CLProgram extends CLObject implements CLResource { return kernel; } - /** - * Creates n instances of a kernel with the specified kernel name. - */ - /* - public CLKernel[] createCLKernels(String kernelName, int instanceCount) { - - if(released) { - return new CLKernel[0]; - } - - CLKernel[] newKernels = new CLKernel[instanceCount]; - for (int i = 0; i < newKernels.length; i++) { - newKernels[i] = createCLKernel(kernelName); - } - return newKernels; - } - */ - /** * Creates all kernels of this program and stores them a Map with the kernel name as key. */ @@ -596,7 +594,7 @@ public class CLProgram extends CLObject implements CLResource { * This option is ignored for single precision numbers if the device does not support single precision denormalized * numbers i.e. {@link CLDevice.FPConfig#DENORM} is not present in the set returned by {@link CLDevice#getSingleFPConfig()}
* This option is ignored for double precision numbers if the device does not support double precision or if it does support - * double precison but {@link CLDevice.FPConfig#DENORM} is not present in the set returned by {@link CLDevice#getDoubleFPConfig()}.
+ * double precision but {@link CLDevice.FPConfig#DENORM} is not present in the set returned by {@link CLDevice#getDoubleFPConfig()}.
* This flag only applies for scalar and vector single precision floating-point variables and computations on * these floating-point variables inside a program. It does not apply to reading from or writing to image objects. */ -- cgit v1.2.3