diff options
author | Wade Walker <[email protected]> | 2016-04-17 19:30:53 -0500 |
---|---|---|
committer | Wade Walker <[email protected]> | 2016-04-17 19:30:53 -0500 |
commit | 7a26673570fd77839672d472b04dbd509395de5b (patch) | |
tree | cd3b2302fa9b24c026e17bd5f5531ad3cc0db192 /test | |
parent | a6b1054ff294a4208a5fec4a4de728be6505b0b4 (diff) |
Add new kernel workgroup info functions to CLKernel
Added workgroup info functions for OpenCL 1.1, since that's the version
the CL Java objects currently wraps. Also added a test that shows how to
query values from version 1.2 and later.
Diffstat (limited to 'test')
-rw-r--r-- | test/com/jogamp/opencl/CLProgramTest.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/com/jogamp/opencl/CLProgramTest.java b/test/com/jogamp/opencl/CLProgramTest.java index ae09d2c..56289e5 100644 --- a/test/com/jogamp/opencl/CLProgramTest.java +++ b/test/com/jogamp/opencl/CLProgramTest.java @@ -31,6 +31,7 @@ package com.jogamp.opencl; import com.jogamp.opencl.test.util.UITestCase; import com.jogamp.opencl.util.CLBuildConfiguration; import com.jogamp.opencl.util.CLProgramConfiguration; +import com.jogamp.common.nio.Buffers; import com.jogamp.opencl.CLProgram.Status; import com.jogamp.opencl.util.CLBuildListener; import com.jogamp.opencl.llb.CL; @@ -41,6 +42,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.nio.ByteBuffer; import java.util.Map; import java.util.concurrent.CountDownLatch; @@ -52,7 +54,11 @@ import org.junit.runners.MethodSorters; import static org.junit.Assert.*; import static java.lang.System.*; +import static com.jogamp.common.os.Platform.is32Bit; +import static com.jogamp.opencl.CLException.newException; import static com.jogamp.opencl.CLProgram.CompilerOptions.*; +import static com.jogamp.opencl.llb.CL12.CL_KERNEL_GLOBAL_WORK_SIZE; +import static com.jogamp.opencl.llb.CL.CL_SUCCESS; /** * @@ -370,6 +376,46 @@ public class CLProgramTest extends UITestCase { } + /** + * Test of getting new kernel work group information, including those from OpenCL versions newer than 1.1. + */ + @Test + public void test22KerneWorkGrouplInfo() { + final CLContext context = CLContext.create(); + + try{ + final CLProgram program = context.createProgram(test20KernelSource).build(); + assertTrue(program.isExecutable()); + + final CLKernel kernel = program.createCLKernel("foo"); + assertNotNull(kernel); + + final long pwgsm = kernel.getPreferredWorkGroupSizeMultiple(context.getDevices()[0]); + out.println("preferred workgroup size multiple: " + pwgsm); + + final long pms = kernel.getPrivateMemSize(context.getDevices()[0]); + out.println("private mem size: " + pms); + + if( context.getDevices()[0].getCVersion().isAtLeast(1, 2) ) { + CL deviceInterface = CLPlatform.getLowLevelCLInterfaceForDevice(context.getDevices()[0].ID); + + ByteBuffer buffer = Buffers.newDirectByteBuffer((is32Bit()?4:8)*3); + final int ret = deviceInterface.clGetKernelWorkGroupInfo(kernel.ID, context.getDevices()[0].ID, CL_KERNEL_GLOBAL_WORK_SIZE, (is32Bit()?4:8)*3, buffer, null); + if(ret != CL_SUCCESS) { + throw newException(ret, "Error while asking for CL_KERNEL_GLOBAL_WORK_SIZE of " + kernel + " on "+ context.getDevices()[0]); + } + + if(is32Bit()) { + out.println("kernel global work size: " + buffer.getInt(0) + ", " + buffer.getInt(4) + ", " + buffer.getInt(8) ); + }else { + out.println("kernel global work size: " + buffer.getLong(0) + ", " + buffer.getLong(8) + ", " + buffer.getLong(16) ); + } + } + }finally{ + context.release(); + } + } + // @Test public void test60Load() throws IOException, ClassNotFoundException, InterruptedException { for(int i = 0; i < 100; i++) { |