summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/demos
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-01-18 15:31:25 +0100
committerMichael Bien <[email protected]>2010-01-18 15:31:25 +0100
commit53a2ed4e0537787e9043634cd5c088eecee8979d (patch)
tree64a6f56e4d1c8e73fe709c82420712757fd5be8e /src/com/mbien/opencl/demos
parentcdb97544aee4ede51d5cf9356c0a21e6b6e71cdc (diff)
updated demos due to api changes.
Diffstat (limited to 'src/com/mbien/opencl/demos')
-rw-r--r--src/com/mbien/opencl/demos/hellojocl/HelloJOCL.java22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/com/mbien/opencl/demos/hellojocl/HelloJOCL.java b/src/com/mbien/opencl/demos/hellojocl/HelloJOCL.java
index e68acf3..115278a 100644
--- a/src/com/mbien/opencl/demos/hellojocl/HelloJOCL.java
+++ b/src/com/mbien/opencl/demos/hellojocl/HelloJOCL.java
@@ -10,7 +10,7 @@ import java.nio.FloatBuffer;
import java.util.Random;
import static java.lang.System.*;
-import static com.mbien.opencl.CLBuffer.Mem.*;
+import static com.mbien.opencl.CLMemory.Mem.*;
/**
* Hello Java OpenCL example. Adds all elements of buffer A to buffer B
@@ -37,18 +37,16 @@ public class HelloJOCL {
CLBuffer<FloatBuffer> clBufferC = context.createFloatBuffer(globalWorkSize, WRITE_ONLY);
out.println("used device memory: "
- + (clBufferA.buffer.capacity()+clBufferB.buffer.capacity()+clBufferC.buffer.capacity())*4/1000000 +"MB");
+ + (clBufferA.getSize()+clBufferB.getSize()+clBufferC.getSize())/1000000 +"MB");
// fill read buffers with random numbers (just to have test data; seed is fixed -> results will not change between runs).
- fillBuffer(clBufferA.buffer, 12345);
- fillBuffer(clBufferB.buffer, 67890);
+ fillBuffer(clBufferA.getBuffer(), 12345);
+ fillBuffer(clBufferB.getBuffer(), 67890);
- // get a reference to the kernel functon with the name 'VectorAdd' and map the buffers to its input parameters.
- CLKernel kernel = program.getCLKernels().get("VectorAdd");
- kernel.setArg(0, clBufferA)
- .setArg(1, clBufferB)
- .setArg(2, clBufferC)
- .setArg(3, elementCount);
+ // get a reference to the kernel functon with the name 'VectorAdd'
+ // and map the buffers to its input parameters.
+ CLKernel kernel = program.getCLKernel("VectorAdd");
+ kernel.putArgs(clBufferA, clBufferB, clBufferC).putArg(elementCount);
// create command queue on fastest device.
CLCommandQueue queue = context.getMaxFlopsDevice().createCommandQueue();
@@ -67,8 +65,8 @@ public class HelloJOCL {
// print first few elements of the resulting buffer to the console.
out.println("a+b=c results snapshot: ");
for(int i = 0; i < 10; i++)
- out.print(clBufferC.buffer.get() + ", ");
- out.println("...; " + clBufferC.buffer.remaining() + " more");
+ out.print(clBufferC.getBuffer().get() + ", ");
+ out.println("...; " + clBufferC.getBuffer().remaining() + " more");
out.println("computation took: "+(time/1000000)+"ms");