diff options
Diffstat (limited to 'src/com/jogamp/opencl/util')
-rw-r--r-- | src/com/jogamp/opencl/util/CLPlatformFilters.java | 48 | ||||
-rw-r--r-- | src/com/jogamp/opencl/util/Filter.java | 18 |
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); + +} |