From 7c83da1d2e3e8d122e562408a63a13928cc97c83 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Mon, 22 Feb 2010 12:47:41 +0100 Subject: several small refactorings, api and javadoc improvements. added automatically generated specialized CLExceptions for each known OpenCL error. added get/set Properties to CLCommandQueue. --- test/com/mbien/opencl/CLBufferTest.java | 12 +++--- test/com/mbien/opencl/CLCommandQueueTest.java | 8 ++-- test/com/mbien/opencl/HighLevelBindingTest.java | 51 +++++++++++++++++-------- 3 files changed, 45 insertions(+), 26 deletions(-) (limited to 'test') diff --git a/test/com/mbien/opencl/CLBufferTest.java b/test/com/mbien/opencl/CLBufferTest.java index f768c5ae..39f85a75 100644 --- a/test/com/mbien/opencl/CLBufferTest.java +++ b/test/com/mbien/opencl/CLBufferTest.java @@ -33,7 +33,7 @@ public class CLBufferTest { // fill only first read buffer -> we will copy the payload to the second later. fillBuffer(clBufferA.buffer, 12345); - CLCommandQueue queue = context.getCLDevices()[0].createCommandQueue(); + CLCommandQueue queue = context.getDevices()[0].createCommandQueue(); // asynchronous write of data to GPU device, blocking read later to get the computed results back. queue.putWriteBuffer(clBufferA, false) // write A @@ -62,7 +62,7 @@ public class CLBufferTest { // fill only first read buffer -> we will copy the payload to the second later. fillBuffer(buffer, 12345); - CLCommandQueue queue = context.getCLDevices()[0].createCommandQueue(); + CLCommandQueue queue = context.getDevices()[0].createCommandQueue(); Mem[] bufferConfig = new Mem[] {Mem.COPY_BUFFER, Mem.USE_BUFFER}; @@ -78,11 +78,11 @@ public class CLBufferTest { .putReadBuffer(clBufferB, true) // read B .finish(); - assertEquals(2, context.getCLMemoryObjects().size()); + assertEquals(2, context.getMemoryObjects().size()); clBufferA.release(); - assertEquals(1, context.getCLMemoryObjects().size()); + assertEquals(1, context.getMemoryObjects().size()); clBufferB.release(); - assertEquals(0, context.getCLMemoryObjects().size()); + assertEquals(0, context.getMemoryObjects().size()); // uploading worked when a==b. out.println("validating computed results..."); @@ -121,7 +121,7 @@ public class CLBufferTest { clBufferB = context.createByteBuffer(sizeInBytes, Mem.READ_WRITE, Mem.USE_BUFFER); } - CLCommandQueue queue = context.getCLDevices()[0].createCommandQueue(); + CLCommandQueue queue = context.getDevices()[0].createCommandQueue(); // fill only first buffer -> we will copy the payload to the second later. ByteBuffer mappedBufferA = queue.putMapBuffer(clBufferA, Map.READ_WRITE, true); diff --git a/test/com/mbien/opencl/CLCommandQueueTest.java b/test/com/mbien/opencl/CLCommandQueueTest.java index b52ef5ed..2cf9c1bf 100644 --- a/test/com/mbien/opencl/CLCommandQueueTest.java +++ b/test/com/mbien/opencl/CLCommandQueueTest.java @@ -26,7 +26,7 @@ public class CLCommandQueueTest { //CLCommandQueueEnums EnumSet queueMode = Mode.valuesOf(CL.CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL.CL_QUEUE_PROFILING_ENABLE); - assertTrue(queueMode.contains(Mode.OUT_OF_ORDER_EXEC_MODE)); + assertTrue(queueMode.contains(Mode.OUT_OF_ORDER_MODE)); assertTrue(queueMode.contains(Mode.PROFILING_MODE)); assertNotNull(Mode.valuesOf(0)); @@ -69,7 +69,7 @@ public class CLCommandQueueTest { CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build(); CLKernel vectorAddKernel = program.createCLKernel("VectorAddGM").setArg(3, elements); - CLCommandQueue queue = context.getCLDevices()[0].createCommandQueue(); + CLCommandQueue queue = context.getDevices()[0].createCommandQueue(); final CLEventList events = new CLEventList(2); @@ -126,7 +126,7 @@ public class CLCommandQueueTest { CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build(); CLKernel vectorAddKernel = program.createCLKernel("VectorAddGM").setArg(3, elements); - CLCommandQueue queue = context.getCLDevices()[0].createCommandQueue(Mode.PROFILING_MODE); + CLCommandQueue queue = context.getDevices()[0].createCommandQueue(Mode.PROFILING_MODE); queue.putWriteBuffer(clBufferA, true) // write A .putWriteBuffer(clBufferB, true);// write B @@ -165,7 +165,7 @@ public class CLCommandQueueTest { CLContext context = CLContext.create(); - CLDevice[] devices = context.getCLDevices(); + CLDevice[] devices = context.getDevices(); if (devices.length < 2) { out.println("aborting test... need at least 2 devices"); diff --git a/test/com/mbien/opencl/HighLevelBindingTest.java b/test/com/mbien/opencl/HighLevelBindingTest.java index 21014e8a..3a75e03c 100644 --- a/test/com/mbien/opencl/HighLevelBindingTest.java +++ b/test/com/mbien/opencl/HighLevelBindingTest.java @@ -1,7 +1,10 @@ package com.mbien.opencl; import com.mbien.opencl.CLMemory.Mem; -import com.mbien.opencl.CLCommandQueue.Mode; +import com.mbien.opencl.CLSampler.AddressingMode; +import com.mbien.opencl.CLSampler.FilteringMode; +import com.mbien.opencl.CLImageFormat.ChannelOrder; +import com.mbien.opencl.CLImageFormat.ChannelType; import com.mbien.opencl.CLDevice.FPConfig; import com.mbien.opencl.CLDevice.GlobalMemCacheType; import com.mbien.opencl.CLDevice.LocalMemType; @@ -62,6 +65,22 @@ public class HighLevelBindingTest { assertEquals(e, Mem.valueOf(e.CONFIG)); } + // CLSampler enums + for (AddressingMode e : AddressingMode.values()) { + assertEquals(e, AddressingMode.valueOf(e.MODE)); + } + for (FilteringMode e : FilteringMode.values()) { + assertEquals(e, FilteringMode.valueOf(e.MODE)); + } + + // CLImage enums + for (ChannelOrder e : ChannelOrder.values()) { + assertEquals(e, ChannelOrder.valueOf(e.ORDER)); + } + for (ChannelType e : ChannelType.values()) { + assertEquals(e, ChannelType.valueOf(e.TYPE)); + } + } @@ -142,32 +161,32 @@ public class HighLevelBindingTest { CLContext c = CLContext.create(); assertNotNull(c); - assertEquals(deviceCount, c.getCLDevices().length); + assertEquals(deviceCount, c.getDevices().length); c.release(); c = CLContext.create(platform); assertNotNull(c); - assertEquals(deviceCount, c.getCLDevices().length); + assertEquals(deviceCount, c.getDevices().length); c.release(); c = CLContext.create(firstDevice); assertNotNull(c); - assertEquals(1, c.getCLDevices().length); + assertEquals(1, c.getDevices().length); c.release(); c = CLContext.create(CLDevice.Type.ALL); assertNotNull(c); - assertEquals(deviceCount, c.getCLDevices().length); + assertEquals(deviceCount, c.getDevices().length); c.release(); c = CLContext.create(platform, firstDevice); assertNotNull(c); - assertEquals(1, c.getCLDevices().length); + assertEquals(1, c.getDevices().length); c.release(); c = CLContext.create(platform, CLDevice.Type.ALL); assertNotNull(c); - assertEquals(deviceCount, c.getCLDevices().length); + assertEquals(deviceCount, c.getDevices().length); c.release(); } @@ -180,7 +199,7 @@ public class HighLevelBindingTest { CLPlatform[] clPlatforms = CLPlatform.listCLPlatforms(); CLContext context = CLContext.create(clPlatforms[0]); - CLDevice[] contextDevices = context.getCLDevices(); + CLDevice[] contextDevices = context.getDevices(); out.println("context devices:"); for (CLDevice device : contextDevices) { @@ -251,22 +270,22 @@ public class HighLevelBindingTest { out.print(dest.getInt()+", "); out.println("...; "+dest.remaining()/SIZEOF_INT + " more"); - assertTrue(3 == context.getCLMemoryObjects().size()); + assertTrue(3 == context.getMemoryObjects().size()); clBufferA.release(); - assertTrue(2 == context.getCLMemoryObjects().size()); + assertTrue(2 == context.getMemoryObjects().size()); - assertTrue(2 == context.getCLMemoryObjects().size()); + assertTrue(2 == context.getMemoryObjects().size()); clBufferB.release(); - assertTrue(1 == context.getCLMemoryObjects().size()); + assertTrue(1 == context.getMemoryObjects().size()); - assertTrue(1 == context.getCLMemoryObjects().size()); + assertTrue(1 == context.getMemoryObjects().size()); clBufferC.release(); - assertTrue(0 == context.getCLMemoryObjects().size()); + assertTrue(0 == context.getMemoryObjects().size()); - assertTrue(1 == context.getCLPrograms().size()); + assertTrue(1 == context.getPrograms().size()); program.release(); - assertTrue(0 == context.getCLPrograms().size()); + assertTrue(0 == context.getPrograms().size()); context.release(); } -- cgit v1.2.3