summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLDevice.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/mbien/opencl/CLDevice.java')
-rw-r--r--src/com/mbien/opencl/CLDevice.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/com/mbien/opencl/CLDevice.java b/src/com/mbien/opencl/CLDevice.java
new file mode 100644
index 00000000..58d35fa9
--- /dev/null
+++ b/src/com/mbien/opencl/CLDevice.java
@@ -0,0 +1,42 @@
+package com.mbien.opencl;
+
+import java.nio.ByteBuffer;
+
+/**
+ *
+ * @author Michael Bien
+ */
+public class CLDevice {
+
+ private final CL cl;
+ private final long deviceID;
+
+ CLDevice(CL cl, long id) {
+ this.cl = cl;
+ this.deviceID = id;
+ }
+
+ /**
+ * Returns the name of this device.
+ */
+ public String getName() {
+ return getInfoString(CL.CL_DEVICE_NAME);
+ }
+
+ public String getInfoString(int key) {
+
+ long[] longBuffer = new long[1];
+ ByteBuffer bb = ByteBuffer.allocate(512);
+
+ int ret = cl.clGetDeviceInfo(deviceID, key, bb.capacity(), bb, longBuffer, 0);
+
+ if(CL.CL_SUCCESS != ret)
+ throw new CLException(ret, "can not receive info string");
+
+ return new String(bb.array(), 0, (int)longBuffer[0]);
+
+ }
+
+// ret = cl.clGetDeviceInfo(device, CL.CL_DEVICE_TYPE, bb.capacity(), bb, longBuffer, 0);
+// assertEquals(CL.CL_SUCCESS, ret);
+}