summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLKernel.java
diff options
context:
space:
mode:
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);
+ }
}