summaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/opencl/util
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-09-21 00:48:32 +0200
committerMichael Bien <[email protected]>2010-09-21 00:48:32 +0200
commitd2f1955832dda891cb6d711c43bcb59e7199a38c (patch)
treec1f4087ec751de624ff50e5812dddeeb1e1e478b /src/com/jogamp/opencl/util
parenta5b0d5948765a1695d9c02a30be599f905152668 (diff)
initial import of utility API for filtering platforms.
Diffstat (limited to 'src/com/jogamp/opencl/util')
-rw-r--r--src/com/jogamp/opencl/util/CLPlatformFilters.java48
-rw-r--r--src/com/jogamp/opencl/util/Filter.java18
2 files changed, 66 insertions, 0 deletions
diff --git a/src/com/jogamp/opencl/util/CLPlatformFilters.java b/src/com/jogamp/opencl/util/CLPlatformFilters.java
new file mode 100644
index 00000000..a1279f10
--- /dev/null
+++ b/src/com/jogamp/opencl/util/CLPlatformFilters.java
@@ -0,0 +1,48 @@
+package com.jogamp.opencl.util;
+
+import com.jogamp.opencl.CLDevice;
+import com.jogamp.opencl.CLPlatform;
+import com.jogamp.opencl.CLVersion;
+import java.util.Arrays;
+
+/**
+ * Pre-defined filters.
+ * @author Michael Bien
+ * @see CLPlatform#getDefault(com.jogamp.opencl.util.Filter<com.jogamp.opencl.CLPlatform>[])
+ * @see CLPlatform#listCLPlatforms(com.jogamp.opencl.util.Filter<com.jogamp.opencl.CLPlatform>[])
+ */
+public class CLPlatformFilters {
+
+ /**
+ * Accepts all platforms supporting at least the given OpenCL spec version.
+ */
+ public static Filter<CLPlatform> version(final CLVersion version) {
+ return new Filter<CLPlatform>() {
+ public boolean accept(CLPlatform item) {
+ return item.isAtLeast(version);
+ }
+ };
+ }
+
+ /**
+ * Accepts all platforms containing devices of the given type.
+ */
+ public static Filter<CLPlatform> type(final CLDevice.Type type) {
+ return new Filter<CLPlatform>() {
+ public boolean accept(CLPlatform item) {
+ return item.listCLDevices(type).length > 0;
+ }
+ };
+ }
+
+ /**
+ * Accepts all platforms containing devices of the given extensions.
+ */
+ public static Filter<CLPlatform> extensions(final String... extensions) {
+ return new Filter<CLPlatform>() {
+ public boolean accept(CLPlatform item) {
+ return item.getExtensions().containsAll(Arrays.asList(extensions));
+ }
+ };
+ }
+}
diff --git a/src/com/jogamp/opencl/util/Filter.java b/src/com/jogamp/opencl/util/Filter.java
new file mode 100644
index 00000000..a1bd57a2
--- /dev/null
+++ b/src/com/jogamp/opencl/util/Filter.java
@@ -0,0 +1,18 @@
+/*
+ * Created on Sunday, September 19 2010
+ */
+
+package com.jogamp.opencl.util;
+
+/**
+ *
+ * @author Michael Bien
+ */
+public interface Filter<I> {
+
+ /**
+ * Returns true only if the item should be accepted.
+ */
+ public boolean accept(I item);
+
+}