aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2009-12-02 14:49:41 +0100
committerMichael Bien <[email protected]>2009-12-02 14:49:41 +0100
commit72203a5d1f8896463ded10d1b21ca116621d1900 (patch)
tree93472cac4c61381ea9cdc48bbe97a59b2cd6f64b /src
parent7c7f5070dcbcc37afe36a4744161157cac49997c (diff)
fixed gcc setup on mac.
updated native taglet toc url. fixed small bug in cl char[] -> String conversion.
Diffstat (limited to 'src')
-rw-r--r--src/com/mbien/opencl/CLDevice.java2
-rw-r--r--src/com/mbien/opencl/CLException.java20
-rw-r--r--src/com/mbien/opencl/CLKernel.java2
-rw-r--r--src/com/mbien/opencl/CLPlatform.java2
-rw-r--r--src/com/mbien/opencl/CLProgram.java6
-rw-r--r--src/com/mbien/opencl/CLUtils.java13
6 files changed, 24 insertions, 21 deletions
diff --git a/src/com/mbien/opencl/CLDevice.java b/src/com/mbien/opencl/CLDevice.java
index 78f0f7bf..c6a632aa 100644
--- a/src/com/mbien/opencl/CLDevice.java
+++ b/src/com/mbien/opencl/CLDevice.java
@@ -338,7 +338,7 @@ public final class CLDevice {
checkForError(ret, "can not receive device info string");
- return new String(bb.array(), 0, (int)longBuffer[0]);
+ return CLUtils.clString2JavaString(bb.array(), (int)longBuffer[0]);
}
diff --git a/src/com/mbien/opencl/CLException.java b/src/com/mbien/opencl/CLException.java
index db4426f8..9e8adb77 100644
--- a/src/com/mbien/opencl/CLException.java
+++ b/src/com/mbien/opencl/CLException.java
@@ -1,27 +1,17 @@
package com.mbien.opencl;
/**
- * Main Exception type for runtime OpenCL errors and unsuccessfull function calls (e.g. returning other values than CL_SUCCESS).
+ * Main Exception type for runtime OpenCL errors and unsuccessful function calls (e.g. returning other values than CL_SUCCESS).
* @author Michael Bien
*/
public class CLException extends RuntimeException {
public final int errorcode;
-// public CLException(Throwable cause) {
-// super(cause);
-// }
-//
-// public CLException(String message, Throwable cause) {
-// super(message, cause);
-// }
-//
-// public CLException(String message) {
-// super(message);
-// }
+ private final static String ERROR_CODE_DOC = "http://www.khronos.org/opencl/sdk/1.0/docs/man/xhtml/errors.html";
public CLException(int error, String message) {
- super(identifyError(error) + ": " + message);
+ super(message + "\nerror: " + identifyError(error) + " (man page: "+ERROR_CODE_DOC+")");
errorcode = error;
}
@@ -177,9 +167,9 @@ public class CLException extends RuntimeException {
// return "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR";
default:
- return "unknown cause: error " + error;
+ return "unknown cause: code" + error;
}
}
-}
+} \ No newline at end of file
diff --git a/src/com/mbien/opencl/CLKernel.java b/src/com/mbien/opencl/CLKernel.java
index cadc635d..544e2752 100644
--- a/src/com/mbien/opencl/CLKernel.java
+++ b/src/com/mbien/opencl/CLKernel.java
@@ -40,7 +40,7 @@ public class CLKernel implements CLResource {
ret = cl.clGetKernelInfo(ID, CL.CL_KERNEL_FUNCTION_NAME, bb.capacity(), bb, null, 0);
checkForError(ret, "error while asking for kernel function name");
- this.name = new String(bb.array(), 0, bb.capacity()).trim();
+ this.name = CLUtils.clString2JavaString(bb.array(), bb.capacity());
// get number of arguments
ret = cl.clGetKernelInfo(ID, CL.CL_KERNEL_NUM_ARGS, 0, null, longArray, 0);
diff --git a/src/com/mbien/opencl/CLPlatform.java b/src/com/mbien/opencl/CLPlatform.java
index f1ecdd86..a0c69084 100644
--- a/src/com/mbien/opencl/CLPlatform.java
+++ b/src/com/mbien/opencl/CLPlatform.java
@@ -152,7 +152,7 @@ public final class CLPlatform {
int ret = cl.clGetPlatformInfo(ID, key, bb.capacity(), bb, longBuffer, 0);
checkForError(ret, "can not receive info string");
- return new String(bb.array(), 0, (int)longBuffer[0]);
+ return CLUtils.clString2JavaString(bb.array(), (int)longBuffer[0]);
}
@Override
diff --git a/src/com/mbien/opencl/CLProgram.java b/src/com/mbien/opencl/CLProgram.java
index 57c242ba..86d573e1 100644
--- a/src/com/mbien/opencl/CLProgram.java
+++ b/src/com/mbien/opencl/CLProgram.java
@@ -97,7 +97,7 @@ public class CLProgram implements CLResource {
ret = cl.clGetProgramBuildInfo(ID, device, flag, bb.capacity(), bb, null, 0);
checkForError(ret, "on clGetProgramBuildInfo");
- return new String(bb.array(), 0, (int)longArray[0]);
+ return CLUtils.clString2JavaString(bb.array(), (int)longArray[0]);
}
private final String getProgramInfoString(int flag) {
@@ -112,7 +112,7 @@ public class CLProgram implements CLResource {
ret = cl.clGetProgramInfo(ID, flag, bb.capacity(), bb, null, 0);
checkForError(ret, "on clGetProgramInfo");
- return new String(bb.array(), 0, (int)longArray[0]);
+ return CLUtils.clString2JavaString(bb.array(), (int)longArray[0]);
}
// private int getProgramInfoInt(int flag) {
@@ -184,7 +184,7 @@ public class CLProgram implements CLResource {
int ret = cl.clBuildProgram(ID, deviceIDs, options, null, null);
if(ret != CL.CL_SUCCESS) {
- checkForError(ret, "\n"+getBuildLog());
+ throw new CLException(ret, "\n"+getBuildLog());
}
return this;
diff --git a/src/com/mbien/opencl/CLUtils.java b/src/com/mbien/opencl/CLUtils.java
new file mode 100644
index 00000000..c19292b6
--- /dev/null
+++ b/src/com/mbien/opencl/CLUtils.java
@@ -0,0 +1,13 @@
+package com.mbien.opencl;
+
+/**
+ *
+ * @author Michael Bien
+ */
+class CLUtils {
+
+ public static String clString2JavaString(byte[] chars, int clLength) {
+ return clLength==0 ? "" : new String(chars, 0, clLength-1);
+ }
+
+}