diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/com/mbien/opencl/CLBufferTest.java | 21 |
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(); |