aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLProgram.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-02-24 17:59:23 +0100
committerMichael Bien <[email protected]>2010-02-24 17:59:23 +0100
commit2694d25e5ce59c4f4741b60242331d56601f90d1 (patch)
treea87802dcea13c761e8400e53353f822bb6139c77 /src/com/mbien/opencl/CLProgram.java
parentdc4fc464ea969614e08c81dbaeefdaaff1673296 (diff)
initial import of CLProgramBuilder.
Diffstat (limited to 'src/com/mbien/opencl/CLProgram.java')
-rw-r--r--src/com/mbien/opencl/CLProgram.java38
1 files changed, 18 insertions, 20 deletions
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;
@@ -238,6 +247,13 @@ public class CLProgram extends CLObject implements CLResource {
}
/**
+ * 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.
*/
public CLKernel createCLKernel(String kernelName) {
@@ -256,24 +272,6 @@ public class CLProgram extends CLObject implements CLResource {
}
/**
- * 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.
*/
public Map<String, CLKernel> createCLKernels() {
@@ -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()}<br>
* 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()}.<br>
+ * double precision but {@link CLDevice.FPConfig#DENORM} is not present in the set returned by {@link CLDevice#getDoubleFPConfig()}.<br>
* 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.
*/