summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLDevice.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2009-09-30 17:59:22 +0200
committerMichael Bien <[email protected]>2009-09-30 17:59:22 +0200
commita550876d23b84427667111c5e2700766752b6040 (patch)
treede61e1605ebb782625437f1b8e5888ca54ae6862 /src/com/mbien/opencl/CLDevice.java
parent5db5f6ac97894bcb9804e4bfcc4607cfdae637a6 (diff)
started with high level abstraction.
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);
+}