aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLCommandQueue.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2009-11-05 02:52:26 +0100
committerMichael Bien <[email protected]>2009-11-05 02:52:26 +0100
commit3d8df0c175ff84ac7b42e0ee5f247099b953514a (patch)
tree41b8a9a7e3b366938919efb75ab38599fc1d8c5b /src/com/mbien/opencl/CLCommandQueue.java
parent0eebae54517e816aaeb36495dfdbdc1b6d03bfba (diff)
bug fixes in buffer handling.
Diffstat (limited to 'src/com/mbien/opencl/CLCommandQueue.java')
-rw-r--r--src/com/mbien/opencl/CLCommandQueue.java45
1 files changed, 41 insertions, 4 deletions
diff --git a/src/com/mbien/opencl/CLCommandQueue.java b/src/com/mbien/opencl/CLCommandQueue.java
index d58cc162..991b0088 100644
--- a/src/com/mbien/opencl/CLCommandQueue.java
+++ b/src/com/mbien/opencl/CLCommandQueue.java
@@ -1,5 +1,6 @@
package com.mbien.opencl;
+import java.nio.Buffer;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
@@ -37,7 +38,7 @@ public class CLCommandQueue {
int ret = cl.clEnqueueWriteBuffer(
ID, writeBuffer.ID, blockingWrite ? CL.CL_TRUE : CL.CL_FALSE,
- 0, writeBuffer.buffer.capacity(), writeBuffer.buffer,
+ 0, writeBuffer.getSizeInBytes(), writeBuffer.buffer,
// 0, null, null); //TODO solve NPE in gluegen when PointerBuffer == null (fast dircet memory path)
0, null, 0, null, 0); //TODO events
@@ -51,7 +52,7 @@ public class CLCommandQueue {
int ret = cl.clEnqueueReadBuffer(
ID, readBuffer.ID, blockingRead ? CL.CL_TRUE : CL.CL_FALSE,
- 0, readBuffer.buffer.capacity(), readBuffer.buffer,
+ 0, readBuffer.getSizeInBytes(), readBuffer.buffer,
// 0, null, null); //TODO solve NPE in gluegen when PointerBuffer == null (fast dircet memory path)
0, null, 0, null, 0); //TODO events
@@ -61,6 +62,20 @@ public class CLCommandQueue {
return this;
}
+ public CLCommandQueue putReadBuffer(CLBuffer<?> readBuffer, Buffer buffer, boolean blockingRead) {
+
+ int ret = cl.clEnqueueReadBuffer(
+ ID, readBuffer.ID, blockingRead ? CL.CL_TRUE : CL.CL_FALSE,
+ 0, readBuffer.getSizeInBytes(), buffer,
+// 0, null, null); //TODO solve NPE in gluegen when PointerBuffer == null (fast dircet memory path)
+ 0, null, 0, null, 0); //TODO events
+
+ if(ret != CL.CL_SUCCESS)
+ throw new CLException(ret, "can not enqueue ReadBuffer: " + readBuffer);
+
+ return this;
+ }
+
public CLCommandQueue putBarrier() {
int ret = cl.clEnqueueBarrier(ID);
checkForError(ret, "can not enqueue Barrier");
@@ -130,7 +145,7 @@ public class CLCommandQueue {
return this;
}
*/
-
+
public CLCommandQueue putNDRangeKernel(CLKernel kernel, int workDimension, long globalWorkOffset, long globalWorkSize, long localWorkSize) {
return this.putNDRangeKernel(
kernel, workDimension,
@@ -142,7 +157,7 @@ public class CLCommandQueue {
public CLCommandQueue putNDRangeKernel(CLKernel kernel, int workDimension, long[] globalWorkOffset, long[] globalWorkSize, long[] localWorkSize) {
int ret = cl.clEnqueueNDRangeKernel(
- ID, kernel.ID, 1,
+ ID, kernel.ID, workDimension,
globalWorkOffset, 0,
globalWorkSize, 0,
localWorkSize, 0,
@@ -156,6 +171,28 @@ public class CLCommandQueue {
return this;
}
+
+ public CLCommandQueue putAcquireGLObject(long glObject) {
+ CLGLI xl = (CLGLI) cl;
+ int ret = xl.clEnqueueAcquireGLObjects(ID, 1, new long[] {glObject}, 0, 0, null, 0, null, 0);
+
+ if(ret != CL.CL_SUCCESS)
+ throw new CLException(ret, "can not aquire GLObject: " + glObject);
+
+ return this;
+ }
+
+ public CLCommandQueue putReleaseGLObject(long glObject) {
+ CLGLI xl = (CLGLI) cl;
+ int ret = xl.clEnqueueReleaseGLObjects(ID, 1, new long[] {glObject}, 0, 0, null, 0, null, 0);
+
+ if(ret != CL.CL_SUCCESS)
+ throw new CLException(ret, "can not release GLObject: " + glObject);
+
+ return this;
+ }
+
+
public CLCommandQueue finish() {
int ret = cl.clFinish(ID);
checkForError(ret, "can not finish command queue");