diff options
author | Michael Bien <[email protected]> | 2010-02-01 01:09:18 +0100 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-02-01 01:09:18 +0100 |
commit | e4e7dc4e7a63206c091cd3288adc6a7346f74191 (patch) | |
tree | ab2435f774da803489fd58612e6b1f22a3e46cee /src/com/mbien/opencl/CLPlatform.java | |
parent | 2015fa5cd47b9be234f30e4b98d06b83486e4fb2 (diff) |
trivial bugfixes, typo and javadoc warning fixes.
began to switch to gluegen's libloading infrastructure.
added CL extensions accessors to CLPlatform.
optimized isFooEnabled() methods for CLCommandQueue.
Diffstat (limited to 'src/com/mbien/opencl/CLPlatform.java')
-rw-r--r-- | src/com/mbien/opencl/CLPlatform.java | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/com/mbien/opencl/CLPlatform.java b/src/com/mbien/opencl/CLPlatform.java index fc1b78f3..2f3cbf54 100644 --- a/src/com/mbien/opencl/CLPlatform.java +++ b/src/com/mbien/opencl/CLPlatform.java @@ -2,9 +2,14 @@ package com.mbien.opencl; import com.mbien.opencl.impl.CLImpl; import com.sun.gluegen.runtime.PointerBuffer; +import com.sun.gluegen.runtime.ProcAddressHelper; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; +import java.util.Collections; +import java.util.HashSet; +import java.util.Scanner; +import java.util.Set; import static com.mbien.opencl.CLException.*; import static com.mbien.opencl.CL.*; @@ -22,9 +27,12 @@ public final class CLPlatform { private static final CL cl; + private Set<String> extensions; + static{ - System.loadLibrary("gluegen-rt"); - System.loadLibrary("jocl"); + NativeLibLoader.loadJOCL(); +// System.loadLibrary("gluegen-rt"); +// ProcAddressHelper.resetProcAddressTable(table, null); cl = new CLImpl(); } @@ -186,6 +194,32 @@ public final class CLPlatform { } /** + * Returns true if the extension is supported on this platform. + */ + public boolean isExtensionAvailable(String extension) { + return getExtensions().contains(extension); + } + + /** + * Returns all platform extension names as unmodifiable Set. + */ + public Set<String> getExtensions() { + + if(extensions == null) { + extensions = new HashSet<String>(); + String ext = getInfoString(CL_PLATFORM_EXTENSIONS); + Scanner scanner = new Scanner(ext); + + while(scanner.hasNext()) + extensions.add(scanner.next()); + + extensions = Collections.unmodifiableSet(extensions); + } + + return extensions; + } + + /** * Returns a info string in exchange for a key (CL_PLATFORM_*). */ public String getInfoString(int key) { |