aboutsummaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2009-10-22 13:03:53 +0200
committerMichael Bien <[email protected]>2009-10-22 13:03:53 +0200
commit503845224a820c0b9ce9204aa6215519f6b93c36 (patch)
treeb675747824468377685a4e6408a269b43b78c9f1 /src/com
parentb3881a0924ecbe17cf27cededeae8df40b2d6933 (diff)
32bit compatibility.
Diffstat (limited to 'src/com')
-rw-r--r--src/com/mbien/opencl/CLBuffer.java4
-rw-r--r--src/com/mbien/opencl/CLContext.java10
-rw-r--r--src/com/mbien/opencl/CLKernel.java3
-rw-r--r--src/com/mbien/opencl/CLProgram.java5
4 files changed, 14 insertions, 8 deletions
diff --git a/src/com/mbien/opencl/CLBuffer.java b/src/com/mbien/opencl/CLBuffer.java
index 7dcd2928..185389c3 100644
--- a/src/com/mbien/opencl/CLBuffer.java
+++ b/src/com/mbien/opencl/CLBuffer.java
@@ -77,12 +77,14 @@ public class CLBuffer {
}
static int flagsToInt(MEM[] flags) {
- int clFlags = CL.CL_MEM_READ_WRITE;
+ int clFlags = 0;
if(flags != null) {
for (int i = 0; i < flags.length; i++) {
clFlags |= flags[i].CL_FLAG;
}
}
+ if(clFlags == 0)
+ clFlags = CL.CL_MEM_READ_WRITE;
return clFlags;
}
diff --git a/src/com/mbien/opencl/CLContext.java b/src/com/mbien/opencl/CLContext.java
index 7eaada8c..a82092bb 100644
--- a/src/com/mbien/opencl/CLContext.java
+++ b/src/com/mbien/opencl/CLContext.java
@@ -2,6 +2,7 @@ package com.mbien.opencl;
import com.mbien.opencl.CLBuffer.MEM;
import com.sun.gluegen.runtime.BufferFactory;
+import com.sun.gluegen.runtime.CPU;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -217,7 +218,7 @@ public final class CLContext {
if(devices == null) {
- int sizeofDeviceID = 8; // TODO doublecheck deviceID size on 32 bit systems
+ int sizeofDeviceID = CPU.is32Bit()?4:8;
long[] longBuffer = new long[1];
@@ -231,9 +232,10 @@ public final class CLContext {
checkForError(ret, "can not enumerate devices");
devices = new CLDevice[deviceIDs.capacity()/sizeofDeviceID];
- for (int i = 0; i < devices.length; i++)
- devices[i] = new CLDevice(this, deviceIDs.getLong()); // TODO doublecheck deviceID size on 32 bit systems
-
+ for (int i = 0; i < devices.length; i++) {
+ devices[i] = new CLDevice(this,
+ CPU.is32Bit()?deviceIDs.getInt():deviceIDs.getLong());
+ }
}
return devices;
diff --git a/src/com/mbien/opencl/CLKernel.java b/src/com/mbien/opencl/CLKernel.java
index dcf00c9a..838f5969 100644
--- a/src/com/mbien/opencl/CLKernel.java
+++ b/src/com/mbien/opencl/CLKernel.java
@@ -1,6 +1,7 @@
package com.mbien.opencl;
import com.sun.gluegen.runtime.BufferFactory;
+import com.sun.gluegen.runtime.CPU;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -38,7 +39,7 @@ public class CLKernel {
}
public CLKernel setArg(int argumentIndex, CLBuffer value) {
- int ret = cl.clSetKernelArg(ID, argumentIndex, 8, wrap(value.ID));
+ int ret = cl.clSetKernelArg(ID, argumentIndex, CPU.is32Bit()?4:8, wrap(value.ID));
checkForError(ret, "error on clSetKernelArg");
return this;
}
diff --git a/src/com/mbien/opencl/CLProgram.java b/src/com/mbien/opencl/CLProgram.java
index 566ae6b2..70656373 100644
--- a/src/com/mbien/opencl/CLProgram.java
+++ b/src/com/mbien/opencl/CLProgram.java
@@ -1,5 +1,6 @@
package com.mbien.opencl;
+import com.sun.gluegen.runtime.CPU;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Collections;
@@ -158,10 +159,10 @@ public class CLProgram {
ret = cl.clGetProgramInfo(ID, CL.CL_PROGRAM_DEVICES, bb.capacity(), bb, null, 0);
checkForError(ret, "on clGetProgramInfo");
- int count = bb.capacity() / 8; // TODO sizeof cl_device
+ int count = bb.capacity() / (CPU.is32Bit()?4:8);
CLDevice[] devices = new CLDevice[count];
for (int i = 0; i < count; i++) {
- devices[i] = context.getCLDevice(bb.getLong());
+ devices[i] = context.getCLDevice(CPU.is32Bit()?bb.getInt():bb.getLong());
}
return devices;