From d2050aea14e6ab1a6429eab56f0612c2deb6184f Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Sun, 8 Nov 2009 21:48:29 +0100 Subject: improved Exception handling in CLProgram and CLKernel. introduced CLResource interface for releasable resources. CLProgram is now rebuildable. --- test/com/mbien/opencl/HighLevelBindingTest.java | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'test/com/mbien') diff --git a/test/com/mbien/opencl/HighLevelBindingTest.java b/test/com/mbien/opencl/HighLevelBindingTest.java index edeedc6b..2a8807ad 100644 --- a/test/com/mbien/opencl/HighLevelBindingTest.java +++ b/test/com/mbien/opencl/HighLevelBindingTest.java @@ -225,5 +225,45 @@ public class HighLevelBindingTest { out.println("results are valid"); } + + @Test + public void rebuildProgramTest() throws IOException { + + out.println(" - - - highLevelTest; rebuild program test - - - "); + + CLContext context = CLContext.create(); + CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")); + + try{ + program.getCLKernels(); + fail("expected exception but got none :("); + }catch(CLException ex) { + out.println("got expected exception:\n"+ex.getMessage()); + assertTrue(ex.errorcode == CL.CL_INVALID_PROGRAM_EXECUTABLE); + } + + program.build(); + assertTrue(program.isExecutable()); + out.println(program.getBuildStatus()); + + Map kernels = program.getCLKernels(); + assertNotNull(kernels); + assertTrue("kernel map is empty", kernels.size() > 0); + + // rebuild + // 1. release kernels (internally) + // 2. build program + program.build(); + assertTrue(program.isExecutable()); + out.println(program.getBuildStatus()); + + // try again with rebuilt program + kernels = program.getCLKernels(); + assertNotNull(kernels); + assertTrue("kernel map is empty", kernels.size() > 0); + assertTrue(kernels.size() > 0); + + context.release(); + } } -- cgit v1.2.3