aboutsummaryrefslogtreecommitdiffstats
path: root/test/com/jogamp/opencl
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2011-07-26 04:00:59 +0200
committerMichael Bien <[email protected]>2011-07-26 04:00:59 +0200
commitc40dfd633ef0f841851ed64c2817a425148378b9 (patch)
treea66f68682a6eb1c62516b6715319ca7a100a2082 /test/com/jogamp/opencl
parent2ad887d6a87e5c11b1e628c4cd44a3ec4efd0bd8 (diff)
initial import of CLWork. Integrated in CLCommandQueue, added junit test.
Diffstat (limited to 'test/com/jogamp/opencl')
-rw-r--r--test/com/jogamp/opencl/CLProgramTest.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/com/jogamp/opencl/CLProgramTest.java b/test/com/jogamp/opencl/CLProgramTest.java
index 3c8ef8ba..47eb42e0 100644
--- a/test/com/jogamp/opencl/CLProgramTest.java
+++ b/test/com/jogamp/opencl/CLProgramTest.java
@@ -29,6 +29,7 @@
package com.jogamp.opencl;
import com.jogamp.common.nio.Buffers;
+import com.jogamp.opencl.CLWork.CLWork1D;
import com.jogamp.opencl.util.CLBuildConfiguration;
import com.jogamp.opencl.util.CLProgramConfiguration;
import com.jogamp.opencl.CLProgram.Status;
@@ -41,6 +42,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
@@ -51,6 +53,8 @@ import org.junit.rules.TemporaryFolder;
import static org.junit.Assert.*;
import static java.lang.System.*;
import static com.jogamp.opencl.CLProgram.CompilerOptions.*;
+import static com.jogamp.opencl.util.CLPlatformFilters.*;
+import static com.jogamp.opencl.CLVersion.*;
/**
*
@@ -416,6 +420,38 @@ public class CLProgramTest {
}
+ @Test
+ public void workTest() throws IOException {
+
+ CLContext context = CLContext.create(CLPlatform.getDefault(version(CL_1_1)));
+
+ try{
+ CLProgram program = context.createProgram(CLProgramTest.class.getResourceAsStream("testkernels.cl")).build();
+
+ CLDevice device = context.getMaxFlopsDevice();
+ out.println(device);
+ CLCommandQueue queue = device.createCommandQueue();
+
+ CLBuffer<IntBuffer> buffer = context.createIntBuffer(20);
+
+ CLWork1D work = CLWork.create1D(program.createCLKernel("add"));
+ work.getKernel().setArgs(buffer, 5, buffer.getNIOCapacity());
+ work.setWorkSize(20, 1).optimizeFor(device);
+
+ queue.putWriteBuffer(buffer, false)
+ .putWork(work)
+ .putReadBuffer(buffer, true);
+
+ while(buffer.getBuffer().hasRemaining()) {
+ assertEquals(5, buffer.getBuffer().get());
+ }
+
+ }finally{
+ context.release();
+ }
+
+ }
+
// @Test
public void loadTest() throws IOException, ClassNotFoundException, InterruptedException {
for(int i = 0; i < 100; i++) {