From 96251f7aa2770d2d8278afbd6e4b603c24932049 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Thu, 21 Jan 2010 14:11:39 +0100 Subject: more device properties. --- src/com/mbien/opencl/CLDevice.java | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/com/mbien/opencl/CLDevice.java') 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; @@ -163,6 +164,16 @@ public final class CLDevice { return (int) deviceInfo.getLong(CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS); } + /** + * 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; + } + } -- cgit v1.2.3