summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/jogamp/opencl/CLPlatform.java24
-rw-r--r--src/com/jogamp/opencl/CLVersion.java3
-rw-r--r--src/com/jogamp/opencl/util/CLInfo.java2
-rw-r--r--test/com/jogamp/opencl/LowLevelBindingTest.java13
4 files changed, 39 insertions, 3 deletions
diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java
index f0faa0f..11a562c 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,7 +251,7 @@ 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();
@@ -256,6 +259,25 @@ public class CLPlatform {
}
/**
+ * 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.
*/
diff --git a/src/com/jogamp/opencl/CLVersion.java b/src/com/jogamp/opencl/CLVersion.java
index 3a48f0b..fc2419c 100644
--- a/src/com/jogamp/opencl/CLVersion.java
+++ b/src/com/jogamp/opencl/CLVersion.java
@@ -45,6 +45,9 @@ public class CLVersion implements Comparable<CLVersion> {
public final static CLVersion CL_1_0 = new CLVersion("OpenCL 1.0");
public final static CLVersion CL_1_1 = new CLVersion("OpenCL 1.1");
+ public final static CLVersion CL_1_2 = new CLVersion("OpenCL 1.2");
+ public final static CLVersion CL_2_0 = new CLVersion("OpenCL 2.0");
+ public final static CLVersion CL_2_1 = new CLVersion("OpenCL 2.1");
/**
* The full version String is defined as:
diff --git a/src/com/jogamp/opencl/util/CLInfo.java b/src/com/jogamp/opencl/util/CLInfo.java
index e6d55b5..cd97d6e 100644
--- a/src/com/jogamp/opencl/util/CLInfo.java
+++ b/src/com/jogamp/opencl/util/CLInfo.java
@@ -58,7 +58,7 @@ public class CLInfo {
// binding
sb.append("CL_BINDING_UNAVAILABLE_FUNCTIONS: ");
- sb.append(((CLImpl11) CLPlatform.getLowLevelCLInterface()).getAddressTable().getNullPointerFunctions());
+ sb.append(CLImpl11.getAddressTable().getNullPointerFunctions());
sb.append("\n");
// OpenCL
diff --git a/test/com/jogamp/opencl/LowLevelBindingTest.java b/test/com/jogamp/opencl/LowLevelBindingTest.java
index 84aaa73..39482aa 100644
--- a/test/com/jogamp/opencl/LowLevelBindingTest.java
+++ b/test/com/jogamp/opencl/LowLevelBindingTest.java
@@ -32,6 +32,8 @@ import java.util.Random;
import com.jogamp.common.nio.PointerBuffer;
import com.jogamp.opencl.llb.impl.BuildProgramCallback;
+import com.jogamp.opencl.llb.impl.CLImpl12;
+import com.jogamp.opencl.llb.impl.CLImpl20;
import com.jogamp.opencl.llb.CL;
import com.jogamp.opencl.llb.CLContextBinding;
import com.jogamp.opencl.llb.CLDeviceBinding;
@@ -166,7 +168,16 @@ public class LowLevelBindingTest extends UITestCase {
checkForError(ret);
out.println(" device: " + clString2JavaString(bb, (int)longBuffer.get(0)));
- ret = cl.clGetDeviceInfo(device, CLDeviceBinding.CL_DEVICE_TYPE, bb.capacity(), bb, longBuffer);
+ // get the CL interface with version specific to this device
+ CL deviceInterface = CLPlatform.getLowLevelCLInterfaceForDevice(device);
+ if(deviceInterface instanceof CLImpl12)
+ out.println(" CL impl: 1.2");
+ else if(deviceInterface instanceof CLImpl20)
+ out.println(" CL impl: 2.0");
+ else
+ out.println(" CL impl: 1.1");
+
+ ret = deviceInterface.clGetDeviceInfo(device, CLDeviceBinding.CL_DEVICE_TYPE, bb.capacity(), bb, longBuffer);
checkForError(ret);
out.println(" type: " + CLDevice.Type.valueOf(bb.get()));
bb.rewind();