summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-02-19 22:16:40 +0100
committerMichael Bien <[email protected]>2010-02-19 22:16:40 +0100
commited40efbf71daaee371d7eb334b0b7a00919548bc (patch)
tree986ae5fad1b2b82fd898f9da4aec9abd39bfbb09 /test
parenta49b22397ae525e9b659a112aa11e4647c18c214 (diff)
fixed CLBufferTest.mapBufferTest() for non CPU contexts.
Diffstat (limited to 'test')
-rw-r--r--test/com/mbien/opencl/CLBufferTest.java21
1 files changed, 18 insertions, 3 deletions
diff --git a/test/com/mbien/opencl/CLBufferTest.java b/test/com/mbien/opencl/CLBufferTest.java
index b6029e3c..f768c5ae 100644
--- a/test/com/mbien/opencl/CLBufferTest.java
+++ b/test/com/mbien/opencl/CLBufferTest.java
@@ -101,10 +101,25 @@ public class CLBufferTest {
final int elements = NUM_ELEMENTS;
final int sizeInBytes = elements*SIZEOF_INT;
- CLContext context = CLContext.create();
+ CLContext context = null;
+ CLBuffer<?> clBufferA = null;
+ CLBuffer<?> clBufferB = null;
+
+ // We will have to allocate mappable NIO memory on non CPU contexts
+ // since we can't map e.g GPU memory.
+ if(CLPlatform.getDefault().listCLDevices(CLDevice.Type.CPU).length > 0) {
+
+ context = CLContext.create(CLDevice.Type.CPU);
- CLBuffer<?> clBufferA = context.createBuffer(sizeInBytes, Mem.READ_WRITE);
- CLBuffer<?> clBufferB = context.createBuffer(sizeInBytes, Mem.READ_WRITE);
+ clBufferA = context.createBuffer(sizeInBytes, Mem.READ_WRITE);
+ clBufferB = context.createBuffer(sizeInBytes, Mem.READ_WRITE);
+ }else{
+
+ context = CLContext.create();
+
+ clBufferA = context.createByteBuffer(sizeInBytes, Mem.READ_WRITE, Mem.USE_BUFFER);
+ clBufferB = context.createByteBuffer(sizeInBytes, Mem.READ_WRITE, Mem.USE_BUFFER);
+ }
CLCommandQueue queue = context.getCLDevices()[0].createCommandQueue();