summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--test/com/mbien/opencl/HighLevelBindingTest.java14
5 files changed, 51 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() {
diff --git a/test/com/mbien/opencl/HighLevelBindingTest.java b/test/com/mbien/opencl/HighLevelBindingTest.java
index 171c972f..2197e22a 100644
--- a/test/com/mbien/opencl/HighLevelBindingTest.java
+++ b/test/com/mbien/opencl/HighLevelBindingTest.java
@@ -5,6 +5,7 @@ import com.mbien.opencl.CLCommandQueue.Mode;
import com.mbien.opencl.CLDevice.FPConfig;
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.util.Arrays;
import java.util.EnumSet;
import java.util.Map;
import org.junit.BeforeClass;
@@ -76,11 +77,24 @@ public class HighLevelBindingTest {
out.println(" global mem cache size: "+device.getGlobalMemCachSize());
out.println(" global mem cache type: "+device.getGlobalMemCacheType());
out.println(" constant buffer size: "+device.getMaxConstantBufferSize());
+ out.println(" error correction support: "+device.isErrorCorrectionSupported());
out.println(" queue properties: "+device.getQueueProperties());
out.println(" clock: "+device.getMaxClockFrequency()+" MHz");
out.println(" timer res: "+device.getProfilingTimerResolution()+" ns");
out.println(" max work group size: "+device.getMaxWorkGroupSize());
out.println(" max compute units: "+device.getMaxComputeUnits());
+ out.println(" max work item dimensions: "+device.getMaxWorkItemDimensions());
+ out.println(" max work item sizes: "+Arrays.toString(device.getMaxWorkItemSizes()));
+ out.println(" compiler available: "+device.isCompilerAvailable());
+ out.println(" image support: "+device.isImageSupportAvailable());
+ out.println(" max read image args: "+device.getMaxReadImageArgs());
+ out.println(" max write image args: "+device.getMaxWriteImageArgs());
+ out.println(" max image2d dimensions: "+Arrays.asList(device.getMaxImage2dWidth(), device.getMaxImage2dHeight()));
+ out.println(" max image3d dimensions: "+Arrays.asList(device.getMaxImage2dWidth(), device.getMaxImage2dHeight(), device.getMaxImage3dDepth()));
+ out.println(" number of address bits: "+device.getAddressBits());
+ out.println(" half FP available: "+device.isHalfFPAvailable());
+ out.println(" double FP available: "+device.isDoubleFPAvailable());
+ out.println(" little endian: "+device.isLittleEndianAvailable());
out.println(" half FP config: "+device.getHalfFPConfig());
out.println(" single FP config: "+device.getSingleFPConfig());
out.println(" double FP config: "+device.getDoubleFPConfig());