summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLKernel.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2009-10-22 01:26:53 +0200
committerMichael Bien <[email protected]>2009-10-22 01:26:53 +0200
commitb3881a0924ecbe17cf27cededeae8df40b2d6933 (patch)
treea2ae7930eca5d771ab89fddd1a9e62802b6ffac9 /src/com/mbien/opencl/CLKernel.java
parentfe1e2739bf7596bc488de977166603edd18c41fb (diff)
api cleanup and refactoring.
Diffstat (limited to 'src/com/mbien/opencl/CLKernel.java')
-rw-r--r--src/com/mbien/opencl/CLKernel.java37
1 files changed, 30 insertions, 7 deletions
diff --git a/src/com/mbien/opencl/CLKernel.java b/src/com/mbien/opencl/CLKernel.java
index 9f184ce4..dcf00c9a 100644
--- a/src/com/mbien/opencl/CLKernel.java
+++ b/src/com/mbien/opencl/CLKernel.java
@@ -1,6 +1,7 @@
package com.mbien.opencl;
import com.sun.gluegen.runtime.BufferFactory;
+import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import static com.mbien.opencl.CLException.*;
@@ -36,25 +37,47 @@ public class CLKernel {
}
- public CLKernel setArg(int argumentIndex, int argumentSize, CLBuffer value) {
- int ret = cl.clSetKernelArg(ID, argumentIndex, argumentSize, wrapLong(value.ID));
+ public CLKernel setArg(int argumentIndex, CLBuffer value) {
+ int ret = cl.clSetKernelArg(ID, argumentIndex, 8, wrap(value.ID));
checkForError(ret, "error on clSetKernelArg");
return this;
}
- public CLKernel setArg(int argumentIndex, int argumentSize, long value) {
- int ret = cl.clSetKernelArg(ID, argumentIndex, argumentSize, wrapLong(value));
+ public CLKernel setArg(int argumentIndex, int value) {
+ int ret = cl.clSetKernelArg(ID, argumentIndex, 4, wrap(value));
checkForError(ret, "error on clSetKernelArg");
return this;
}
- private final ByteBuffer wrapLong(long value) {
- return (ByteBuffer) BufferFactory.newDirectByteBuffer(8).putLong(value).rewind();
+ public CLKernel setArg(int argumentIndex, long value) {
+ int ret = cl.clSetKernelArg(ID, argumentIndex, 8, wrap(value));
+ checkForError(ret, "error on clSetKernelArg");
+ return this;
+ }
+
+ public CLKernel setArg(int argumentIndex, float value) {
+ int ret = cl.clSetKernelArg(ID, argumentIndex, 4, wrap(value));
+ checkForError(ret, "error on clSetKernelArg");
+ return this;
+ }
+
+ public CLKernel setArg(int argumentIndex, double value) {
+ int ret = cl.clSetKernelArg(ID, argumentIndex, 8, wrap(value));
+ checkForError(ret, "error on clSetKernelArg");
+ return this;
+ }
+
+ private final Buffer wrap(double value) {
+ return BufferFactory.newDirectByteBuffer(8).putDouble(value).rewind();
+ }
+
+ private final Buffer wrap(long value) {
+ return BufferFactory.newDirectByteBuffer(8).putLong(value).rewind();
}
public void release() {
int ret = cl.clReleaseKernel(ID);
- program.kernelReleased(this);
+ program.onKernelReleased(this);
checkForError(ret, "can not release kernel");
}