aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/mbien
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/mbien')
-rw-r--r--src/com/mbien/opencl/CLKernel.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/com/mbien/opencl/CLKernel.java b/src/com/mbien/opencl/CLKernel.java
index 544e2752..87474878 100644
--- a/src/com/mbien/opencl/CLKernel.java
+++ b/src/com/mbien/opencl/CLKernel.java
@@ -24,6 +24,8 @@ public class CLKernel implements CLResource {
private final CLProgram program;
private final CL cl;
+ private int argIndex;
+
CLKernel(CLProgram program, long id) {
this.ID = id;
this.program = program;
@@ -49,6 +51,37 @@ public class CLKernel implements CLResource {
numArgs = (int)longArray[0];
}
+
+ public CLKernel putArg(CLBuffer<?> value) {
+ setArg(argIndex++, value);
+ return this;
+ }
+
+ public CLKernel putArg(int value) {
+ setArg(argIndex++, value);
+ return this;
+ }
+
+ public CLKernel putArg(long value) {
+ setArg(argIndex++, value);
+ return this;
+ }
+
+ public CLKernel putArg(float value) {
+ setArg(argIndex++, value);
+ return this;
+ }
+
+ public CLKernel putArg(double value) {
+ setArg(argIndex++, value);
+ return this;
+ }
+
+ public CLKernel putArgs(CLBuffer<?>... values) {
+ setArgs(argIndex, values);
+ argIndex += values.length;
+ return this;
+ }
public CLKernel setArg(int argumentIndex, CLBuffer<?> value) {
setArgument(argumentIndex, CPU.is32Bit()?4:8, wrap(value.ID));
@@ -75,6 +108,17 @@ public class CLKernel implements CLResource {
return this;
}
+ public CLKernel setArgs(CLBuffer<?>... values) {
+ setArgs(0, values);
+ return this;
+ }
+
+ private final void setArgs(int startIndex, CLBuffer<?>... values) {
+ for (int i = 0; i < values.length; i++) {
+ setArg(i+startIndex, values[i]);
+ }
+ }
+
private final void setArgument(int argumentIndex, int size, Buffer value) {
if(argumentIndex >= numArgs || argumentIndex < 0) {
throw new IndexOutOfBoundsException("kernel "+ toString() +" has "+numArgs+
@@ -105,6 +149,11 @@ public class CLKernel implements CLResource {
return BufferFactory.newDirectByteBuffer(8).putLong(value).rewind();
}
+ public CLKernel rewind() {
+ argIndex = 0;
+ return this;
+ }
+
/**
* Releases all resources of this kernel from its context.
*/