aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLKernel.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-01-14 17:38:34 +0100
committerMichael Bien <[email protected]>2010-01-14 17:38:34 +0100
commit9e650242da44a939e6a4c1e3c06d77c2e668a3e0 (patch)
treeb0272560299430beb79915c9f701994bc40a10d5 /src/com/mbien/opencl/CLKernel.java
parent9343c3ef5829f74207a8d220cb3b082211b910f2 (diff)
cleaned up NioDirectOnly list, added clSetKernelArg to list.
added experimental QueueBarrier for easy synchronization between multiple concurrent CLCommandQueues. refactored CLCommandQueue, added putTask(). added another concurrency JUnit test.
Diffstat (limited to 'src/com/mbien/opencl/CLKernel.java')
-rw-r--r--src/com/mbien/opencl/CLKernel.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/com/mbien/opencl/CLKernel.java b/src/com/mbien/opencl/CLKernel.java
index e7ac4b4d..2115a9f8 100644
--- a/src/com/mbien/opencl/CLKernel.java
+++ b/src/com/mbien/opencl/CLKernel.java
@@ -26,12 +26,15 @@ public class CLKernel implements CLResource {
private final CLProgram program;
private final CL cl;
+ private final ByteBuffer buffer;
+
private int argIndex;
CLKernel(CLProgram program, long id) {
this.ID = id;
this.program = program;
this.cl = program.context.cl;
+ this.buffer = BufferFactory.newDirectByteBuffer(8);
long[] longArray = new long[1];
@@ -136,19 +139,19 @@ public class CLKernel implements CLResource {
}
private final Buffer wrap(float value) {
- return BufferFactory.newDirectByteBuffer(4).putFloat(value).rewind();
+ return buffer.putFloat(value).rewind();
}
private final Buffer wrap(double value) {
- return BufferFactory.newDirectByteBuffer(8).putDouble(value).rewind();
+ return buffer.putDouble(value).rewind();
}
private final Buffer wrap(int value) {
- return BufferFactory.newDirectByteBuffer(4).putInt(value).rewind();
+ return buffer.putInt(value).rewind();
}
private final Buffer wrap(long value) {
- return BufferFactory.newDirectByteBuffer(8).putLong(value).rewind();
+ return buffer.putLong(value).rewind();
}
public CLKernel rewind() {
@@ -196,5 +199,12 @@ public class CLKernel implements CLResource {
hash = 43 * hash + (this.program != null ? this.program.hashCode() : 0);
return hash;
}
+
+ CLKernel copy() {
+ int[] err = new int[1];
+ long newID = cl.clCreateKernel(program.ID, name, err, 0);
+ checkForError(err[0], "can not copy kernel");
+ return new CLKernel(program, newID);
+ }
}