diff options
author | Michael Bien <[email protected]> | 2009-10-21 17:17:21 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2009-10-21 17:17:21 +0200 |
commit | fe1e2739bf7596bc488de977166603edd18c41fb (patch) | |
tree | 6e847eec358365efa98cc74d2a843f5c6e6cfb38 /src/com | |
parent | abe0135b4457d4c4ff722b0f39a47cad6c178f7e (diff) |
added CopyBuffer implementation to CLCommandQueue and and test method to HighLevelBindingTest.
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/mbien/opencl/CLCommandQueue.java | 83 | ||||
-rw-r--r-- | src/com/mbien/opencl/CLContext.java | 5 |
2 files changed, 84 insertions, 4 deletions
diff --git a/src/com/mbien/opencl/CLCommandQueue.java b/src/com/mbien/opencl/CLCommandQueue.java index b0a6980f..7d1d09f9 100644 --- a/src/com/mbien/opencl/CLCommandQueue.java +++ b/src/com/mbien/opencl/CLCommandQueue.java @@ -30,8 +30,8 @@ public class CLCommandQueue { int ret = cl.clEnqueueWriteBuffer( ID, writeBuffer.ID, blockingWrite ? CL.CL_TRUE : CL.CL_FALSE, 0, writeBuffer.buffer.capacity(), writeBuffer.buffer, - 0, null, 0, - null, 0 ); +// 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 WriteBuffer: " + writeBuffer); @@ -44,8 +44,8 @@ public class CLCommandQueue { int ret = cl.clEnqueueReadBuffer( ID, readBuffer.ID, blockingRead ? CL.CL_TRUE : CL.CL_FALSE, 0, readBuffer.buffer.capacity(), readBuffer.buffer, - 0, null, 0, - null, 0 ); +// 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); @@ -53,6 +53,81 @@ public class CLCommandQueue { return this; } + public CLCommandQueue putBarrier() { + int ret = cl.clEnqueueBarrier(ID); + checkForError(ret, "can not enqueue Barrier"); + return this; + } + + public CLCommandQueue putCopyBuffer(CLBuffer src, CLBuffer dest, long bytesToCopy) { + int ret = cl.clEnqueueCopyBuffer( + ID, src.ID, dest.ID, src.buffer.position(), dest.buffer.position(), bytesToCopy, +// 0, null, null); //TODO solve NPE in gluegen when PointerBuffer == null + 0, null, 0, null, 0); //TODO events + checkForError(ret, "can not copy Buffer"); + return this; + } + + //TODO implement remaining methods + /* + public CLCommandQueue putCopyImage() { + + return this; + } + public CLCommandQueue putCopyBufferToImage() { + + return this; + } + public CLCommandQueue putCopyImageToBuffer() { + + return this; + } + public CLCommandQueue putMarker() { + + return this; + } + + public CLCommandQueue putWriteImage() { + + return this; + } + + public CLCommandQueue putReadImage() { + + return this; + } + + public CLCommandQueue putTask() { + + return this; + } + + public CLBuffer putMapBuffer() { + + return null; + } + + public CLCommandQueue putMapImage() { + + return this; + } + + public CLCommandQueue putUnmapMemObject() { + + return this; + } + + public CLCommandQueue putWaitForEvents() { + + return this; + } +*/ + +// public CLCommandQueue putNDRangeKernel(CLKernel kernel, int workDimension, long globalWorkOffset, long globalWorkSize, long localWorkSize) { +// return this.putNDRangeKernel(kernel, workDimension, +// new long[] {globalWorkOffset}, new long[] {globalWorkSize}, new long[] {localWorkSize}); +// } + public CLCommandQueue putNDRangeKernel(CLKernel kernel, int workDimension, long[] globalWorkOffset, long[] globalWorkSize, long[] localWorkSize) { int ret = cl.clEnqueueNDRangeKernel( diff --git a/src/com/mbien/opencl/CLContext.java b/src/com/mbien/opencl/CLContext.java index db32a446..76fbc2ee 100644 --- a/src/com/mbien/opencl/CLContext.java +++ b/src/com/mbien/opencl/CLContext.java @@ -1,5 +1,6 @@ package com.mbien.opencl; +import com.sun.gluegen.runtime.BufferFactory; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -104,6 +105,10 @@ public final class CLContext { return buffer; } + public CLBuffer createBuffer(int flags, int size) { + return createBuffer(flags, BufferFactory.newDirectByteBuffer(size)); + } + CLCommandQueue createCommandQueue(CLDevice device, long properties) { CLCommandQueue queue = new CLCommandQueue(this, device, properties); |