summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-01-21 14:11:39 +0100
committerMichael Bien <[email protected]>2010-01-21 14:11:39 +0100
commit96251f7aa2770d2d8278afbd6e4b603c24932049 (patch)
tree9e650b567654215393dd2622cfa59febe68c928d /src/com
parent7a009264d53a4f9bc02fc01ea3cb12ef6cf432fe (diff)
more device properties.
Diffstat (limited to 'src/com')
-rw-r--r--src/com/mbien/opencl/CLBuffer.java2
-rw-r--r--src/com/mbien/opencl/CLDevice.java28
-rw-r--r--src/com/mbien/opencl/CLGLContext.java7
-rw-r--r--src/com/mbien/opencl/CLInfoAccessor.java4
4 files changed, 37 insertions, 4 deletions
diff --git a/src/com/mbien/opencl/CLBuffer.java b/src/com/mbien/opencl/CLBuffer.java
index 618cfa96..e42b9064 100644
--- a/src/com/mbien/opencl/CLBuffer.java
+++ b/src/com/mbien/opencl/CLBuffer.java
@@ -21,7 +21,7 @@ public final class CLBuffer<B extends Buffer> extends CLMemory<B> {
static <B extends Buffer> CLBuffer<B> create(CLContext context, B directBuffer, int flags, int glBuffer) {
- if(!directBuffer.isDirect())
+ if(directBuffer != null && !directBuffer.isDirect())
throw new IllegalArgumentException("buffer is not a direct buffer");
CL cl = context.cl;
diff --git a/src/com/mbien/opencl/CLDevice.java b/src/com/mbien/opencl/CLDevice.java
index f1a402be..e8d55eb1 100644
--- a/src/com/mbien/opencl/CLDevice.java
+++ b/src/com/mbien/opencl/CLDevice.java
@@ -2,6 +2,7 @@ package com.mbien.opencl;
import com.sun.gluegen.runtime.PointerBuffer;
import java.nio.Buffer;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
@@ -164,6 +165,16 @@ public final class CLDevice {
}
/**
+ * Returns the maximum number of work-items that can be specified in each
+ * dimension of the work-group.
+ * The minimum value is (1, 1, 1).
+ */
+ public int[] getMaxWorkItemSizes() {
+ int n = (int) deviceInfo.getLong(CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS);
+ return deviceInfo.getInts(n, CL_DEVICE_MAX_WORK_ITEM_SIZES);
+ }
+
+ /**
* Returns the max size in bytes of the arguments that can be passed to a kernel.
* The minimum value is 256.
*/
@@ -417,13 +428,28 @@ public final class CLDevice {
}
- private class CLDeviceInfoAccessor extends CLInfoAccessor {
+ private final class CLDeviceInfoAccessor extends CLInfoAccessor {
@Override
protected int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) {
return cl.clGetDeviceInfo(ID, name, valueSize, value, valueSizeRet);
}
+ private int[] getInts(int n, int key) {
+
+ ByteBuffer buffer = localBB.get();
+ int ret = getInfo(key, buffer.capacity(), buffer, null);
+ CLException.checkForError(ret, "error while asking device for infos");
+
+ int[] array = new int[n];
+ for(int i = 0; i < array.length; i++) {
+ array[i] = (int)buffer.getLong();
+ }
+ buffer.rewind();
+
+ return array;
+ }
+
}
diff --git a/src/com/mbien/opencl/CLGLContext.java b/src/com/mbien/opencl/CLGLContext.java
index 6336dfc8..48efb6c0 100644
--- a/src/com/mbien/opencl/CLGLContext.java
+++ b/src/com/mbien/opencl/CLGLContext.java
@@ -94,6 +94,13 @@ public final class CLGLContext extends CLContext {
return GLObjectType.valueOf(array[0]);
}
+ public int getGLObjectID(CLBuffer<?> buffer) {
+ int[] array = new int[1];
+ int ret = ((CLGLI)cl).clGetGLObjectInfo(buffer.ID, null, 0, array, 0);
+ CLException.checkForError(ret, "error while asking for gl object info");
+ return array[0];
+ }
+
public enum GLObjectType {
GL_OBJECT_BUFFER(CL_GL_OBJECT_BUFFER),
diff --git a/src/com/mbien/opencl/CLInfoAccessor.java b/src/com/mbien/opencl/CLInfoAccessor.java
index 7a303dc3..d2e58f3d 100644
--- a/src/com/mbien/opencl/CLInfoAccessor.java
+++ b/src/com/mbien/opencl/CLInfoAccessor.java
@@ -14,7 +14,7 @@ import static com.mbien.opencl.CLException.*;
*/
abstract class CLInfoAccessor {
- private final static ThreadLocal<ByteBuffer> localBB = new ThreadLocal<ByteBuffer>() {
+ protected final static ThreadLocal<ByteBuffer> localBB = new ThreadLocal<ByteBuffer>() {
@Override
protected ByteBuffer initialValue() {
@@ -22,7 +22,7 @@ abstract class CLInfoAccessor {
}
};
- private final static ThreadLocal<PointerBuffer> localPB = new ThreadLocal<PointerBuffer>() {
+ protected final static ThreadLocal<PointerBuffer> localPB = new ThreadLocal<PointerBuffer>() {
@Override
protected PointerBuffer initialValue() {