From 7c7146428a0584ad38f036d24a70c15f700f9a8e Mon Sep 17 00:00:00 2001 From: Wade Walker Date: Sun, 20 Sep 2015 15:09:04 -0500 Subject: Add ability to access newer CLImpl versions for devices Added a CLPlatform method to return a CLImpl version specific to a device. This lets the user get a CLImpl12 or CLImpl20 instance which they could then cast to the right type and use to access newer CL functions than those in the default CLImpl11 object. --- src/com/jogamp/opencl/CLPlatform.java | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/com/jogamp/opencl/CLPlatform.java') diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java index f0faa0fb..11a562c5 100644 --- a/src/com/jogamp/opencl/CLPlatform.java +++ b/src/com/jogamp/opencl/CLPlatform.java @@ -47,7 +47,10 @@ import com.jogamp.opencl.llb.CLMemObjBinding; import com.jogamp.opencl.spi.CLPlatformInfoAccessor; import com.jogamp.opencl.util.CLUtil; import com.jogamp.opencl.llb.impl.CLImpl11; +import com.jogamp.opencl.llb.impl.CLImpl12; +import com.jogamp.opencl.llb.impl.CLImpl20; import com.jogamp.opencl.spi.CLAccessorFactory; +import com.jogamp.opencl.spi.CLInfoAccessor; import com.jogamp.opencl.util.Filter; import java.nio.IntBuffer; @@ -248,13 +251,32 @@ public class CLPlatform { } /** - * Returns the low level binding interface to the OpenCL APIs. + * Returns the low level binding interface to the OpenCL APIs. This interface is always for OpenCL 1.1. */ public static CL getLowLevelCLInterface() { initialize(); return cl; } + /** + * Returns the low level binding interface to the OpenCL APIs for the specified device. This interface + * is the newest one the device supports. + */ + public static CL getLowLevelCLInterfaceForDevice(final long device) { + initialize(); + + CLInfoAccessor deviceInfo = defaultFactory.createDeviceInfoAccessor(cl, device); + CLVersion version = new CLVersion(deviceInfo.getString(CL_DEVICE_VERSION)); + + if(version.isEqual(CLVersion.CL_1_2)) + return new CLImpl12(); + + if(version.isEqual(CLVersion.CL_2_0)) + return new CLImpl20(); + + return cl; + } + /** * Hint to allow the implementation to release the resources allocated by the OpenCL compiler. * Calls to {@link CLProgram#build()} after unloadCompiler will reload the compiler if necessary. -- cgit v1.2.3