summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLContext.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-01-19 00:14:28 +0100
committerMichael Bien <[email protected]>2010-01-19 00:14:28 +0100
commit21f0d9231227a4d2c96cb70b5061c18145591fba (patch)
tree392c64edb0571127fb83ccb003d491f179a0efa2 /src/com/mbien/opencl/CLContext.java
parent09ac312a0645bd0d9adff580f29f20382dfbf8c9 (diff)
temporary dissabled non direct NIO binding for methods containing long[] since its broken on 32bit systems.
refactored high level binding to use direct NIO exclusively. temporary dissabled low level binding junit tests. green bar on 32 and 64 bit systems.
Diffstat (limited to 'src/com/mbien/opencl/CLContext.java')
-rw-r--r--src/com/mbien/opencl/CLContext.java14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/com/mbien/opencl/CLContext.java b/src/com/mbien/opencl/CLContext.java
index 3db9be2d..6fbad0df 100644
--- a/src/com/mbien/opencl/CLContext.java
+++ b/src/com/mbien/opencl/CLContext.java
@@ -4,6 +4,7 @@ import com.mbien.opencl.CLMemory.Mem;
import com.mbien.opencl.CLSampler.AddressingMode;
import com.mbien.opencl.CLSampler.FilteringMode;
import com.sun.gluegen.runtime.CPU;
+import com.sun.gluegen.runtime.PointerBuffer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -58,13 +59,13 @@ public class CLContext implements CLResource {
if (devices == null) {
int sizeofDeviceID = CPU.is32Bit() ? 4 : 8;
- long[] longBuffer = new long[1];
+ PointerBuffer deviceCount = PointerBuffer.allocateDirect(1);
- int ret = cl.clGetContextInfo(ID, CL.CL_CONTEXT_DEVICES, 0, null, longBuffer, 0);
+ int ret = cl.clGetContextInfo(ID, CL.CL_CONTEXT_DEVICES, 0, null, deviceCount);
checkForError(ret, "can not enumerate devices");
- ByteBuffer deviceIDs = ByteBuffer.allocate((int) longBuffer[0]).order(ByteOrder.nativeOrder());
- ret = cl.clGetContextInfo(ID, CL.CL_CONTEXT_DEVICES, deviceIDs.capacity(), deviceIDs, null, 0);
+ ByteBuffer deviceIDs = ByteBuffer.allocateDirect((int)deviceCount.get()).order(ByteOrder.nativeOrder());
+ ret = cl.clGetContextInfo(ID, CL.CL_CONTEXT_DEVICES, deviceIDs.capacity(), deviceIDs, null);
checkForError(ret, "can not enumerate devices");
devices = new CLDevice[deviceIDs.capacity() / sizeofDeviceID];
@@ -166,15 +167,12 @@ public class CLContext implements CLResource {
if(platforms.length > 0)
platform = platforms[0];
}
-// System.out.println(platform.ID);
-// System.out.println((int)platform.ID);
Buffer properties = null;
if(platform != null) {
if(CPU.is32Bit()){
- int id = (int)platform.ID;// (int)(platform.ID & 0x00000000FFFFFFFFL);
properties = ByteBuffer.allocate(4*3).order(ByteOrder.nativeOrder())
- .putInt(CL.CL_CONTEXT_PLATFORM).putInt(id).putInt(0); // 0 terminated array
+ .putInt(CL.CL_CONTEXT_PLATFORM).putInt((int)platform.ID).putInt(0); // 0 terminated array
}else{
properties = LongBuffer.allocate(3)
.put(CL.CL_CONTEXT_PLATFORM).put(platform.ID).put(0); // 0 terminated array