aboutsummaryrefslogtreecommitdiffstats
path: root/test/com/mbien/opencl
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-02-18 01:40:40 +0100
committerMichael Bien <[email protected]>2010-02-18 01:40:40 +0100
commit074e8a18e8f5f77168bde267ab87f3cf285f82be (patch)
tree5dfd0063968fc2ed1b809b86daa247f8cda27fcd /test/com/mbien/opencl
parent62d9a63caad9d614a4a4ca90956b38ff623242a5 (diff)
added putCopyBufferToImage, putCopyImageToBuffer and putMap/UnmapBuffer operations to CLCommandQueue.
added buffer mapping test to CLBufferTest.
Diffstat (limited to 'test/com/mbien/opencl')
-rw-r--r--test/com/mbien/opencl/CLBufferTest.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/com/mbien/opencl/CLBufferTest.java b/test/com/mbien/opencl/CLBufferTest.java
index c6b87290..b6029e3c 100644
--- a/test/com/mbien/opencl/CLBufferTest.java
+++ b/test/com/mbien/opencl/CLBufferTest.java
@@ -1,6 +1,7 @@
package com.mbien.opencl;
import com.mbien.opencl.CLMemory.Mem;
+import com.mbien.opencl.CLMemory.Map;
import com.sun.opengl.util.BufferUtil;
import java.nio.ByteBuffer;
import org.junit.Test;
@@ -91,4 +92,43 @@ public class CLBufferTest {
context.release();
}
+
+ @Test
+ public void mapBufferTest() {
+
+ out.println(" - - - highLevelTest; map buffer test - - - ");
+
+ final int elements = NUM_ELEMENTS;
+ final int sizeInBytes = elements*SIZEOF_INT;
+
+ CLContext context = CLContext.create();
+
+ CLBuffer<?> clBufferA = context.createBuffer(sizeInBytes, Mem.READ_WRITE);
+ CLBuffer<?> clBufferB = context.createBuffer(sizeInBytes, Mem.READ_WRITE);
+
+ CLCommandQueue queue = context.getCLDevices()[0].createCommandQueue();
+
+ // fill only first buffer -> we will copy the payload to the second later.
+ ByteBuffer mappedBufferA = queue.putMapBuffer(clBufferA, Map.READ_WRITE, true);
+ assertEquals(sizeInBytes, mappedBufferA.capacity());
+
+ fillBuffer(mappedBufferA, 12345); // write to A
+
+ queue.putUnmapMemory(clBufferA) // unmap A
+ .putCopyBuffer(clBufferA, clBufferB); // copy A -> B
+
+ // map B for read operations
+ ByteBuffer mappedBufferB = queue.putMapBuffer(clBufferB, Map.READ, true);
+ assertEquals(sizeInBytes, mappedBufferB.capacity());
+
+ out.println("validating computed results...");
+ checkIfEqual(mappedBufferA, mappedBufferB, elements); // A == B ?
+ out.println("results are valid");
+
+ queue.putUnmapMemory(clBufferB); // unmap B
+
+ context.release();
+
+ }
+
}