summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/jogamp/opencl/CLPlatform.java35
-rw-r--r--src/com/jogamp/opencl/JoclVersion.java8
-rw-r--r--test/com/jogamp/opencl/gl/CLGLTest.java3
-rw-r--r--test/com/jogamp/opencl/test/util/MiscUtils.java8
-rw-r--r--test/com/jogamp/opencl/test/util/UITestCase.java3
5 files changed, 32 insertions, 25 deletions
diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java
index 8e31b74a..d63f6708 100644
--- a/src/com/jogamp/opencl/CLPlatform.java
+++ b/src/com/jogamp/opencl/CLPlatform.java
@@ -68,6 +68,9 @@ import static com.jogamp.opencl.llb.CL.*;
*
* optional eager initialization:
* <p><pre>
+ * if( !CLPlatform.isAvailable() ) {
+ * return; // abort
+ * }
* try{
* CLPlatform.initialize();
* }catch(JogampRuntimeException ex) {
@@ -77,6 +80,9 @@ import static com.jogamp.opencl.llb.CL.*;
*
* Example initialization:
* <p><pre>
+ * if( !CLPlatform.isAvailable() ) {
+ * return; // abort
+ * }
* CLPlatform platform = CLPlatform.getDefault(type(GPU));
*
* if(platform == null) {
@@ -94,6 +100,7 @@ import static com.jogamp.opencl.llb.CL.*;
* CLPlatform is threadsafe.
*
* @author Michael Bien, et al.
+ * @see #isAvailable()
* @see #initialize()
* @see #getDefault()
* @see #listCLPlatforms()
@@ -135,8 +142,15 @@ public class CLPlatform {
}
/**
+ * @returns true if OpenCL is available on this machine,
+ * i.e. all native libraries could be loaded (CL and CL/JNI).
+ */
+ public static boolean isAvailable() { return CLAbstractImpl.isAvailable(); }
+
+ /**
* Eagerly initializes JOCL. Subsequent calls do nothing.
* @throws JogampRuntimeException if something went wrong in the initialization (e.g. OpenCL lib not found).
+ * @see #isAvailable()
*/
public static void initialize() throws JogampRuntimeException {
initialize(null);
@@ -147,9 +161,9 @@ public class CLPlatform {
* Eagerly initializes JOCL. Subsequent calls do nothing.
* @param factory CLAccessorFactory used for creating the bindings.
* @throws JogampRuntimeException if something went wrong in the initialization (e.g. OpenCL lib not found).
+ * @see #isAvailable()
*/
synchronized static void initialize(final CLAccessorFactory factory) throws JogampRuntimeException {
-
if(cl != null) {
return;
}
@@ -162,19 +176,10 @@ public class CLPlatform {
}
}
- try {
- if( null == CLAbstractImpl.getCLProcAddressTable() ) {
- throw new JogampRuntimeException("JOCL ProcAddressTable is NULL");
- }
- cl = new CLImpl();
- }catch(final UnsatisfiedLinkError ex) {
- System.err.println(JoclVersion.getInstance().getAllVersions(null).toString());
- throw ex;
- }catch(final Exception ex) {
- System.err.println(JoclVersion.getInstance().getAllVersions(null).toString());
- throw new JogampRuntimeException("JOCL initialization error.", ex);
+ if( !CLAbstractImpl.isAvailable() ) {
+ throw new JogampRuntimeException("JOCL is not available");
}
-
+ cl = new CLImpl();
}
/**
@@ -188,7 +193,6 @@ public class CLPlatform {
/**
* Returns the default OpenCL platform or null when no platform found.
*/
- @SuppressWarnings("unchecked")
public static CLPlatform getDefault(final Filter<CLPlatform>... filter) {
final CLPlatform[] platforms = listCLPlatforms(filter);
if(platforms.length > 0) {
@@ -221,7 +225,6 @@ public class CLPlatform {
* @param filter Acceptance filter for the returned platforms.
* @throws CLException if something went wrong initializing OpenCL
*/
- @SuppressWarnings("unchecked")
public static CLPlatform[] listCLPlatforms(final Filter<CLPlatform>... filter) {
initialize();
@@ -297,7 +300,6 @@ public class CLPlatform {
/**
* Lists all physical devices available on this platform matching the given {@link Filter}.
*/
- @SuppressWarnings("unchecked")
public CLDevice[] listCLDevices(final Filter<CLDevice>... filters) {
initialize();
@@ -393,7 +395,6 @@ public class CLPlatform {
* The device speed is estimated by calculating the product of
* MAX_COMPUTE_UNITS and MAX_CLOCK_FREQUENCY.
*/
- @SuppressWarnings("unchecked")
public CLDevice getMaxFlopsDevice(final Filter<CLDevice>... filter) {
return findMaxFlopsDevice(listCLDevices(filter));
}
diff --git a/src/com/jogamp/opencl/JoclVersion.java b/src/com/jogamp/opencl/JoclVersion.java
index 15e868cf..3519add0 100644
--- a/src/com/jogamp/opencl/JoclVersion.java
+++ b/src/com/jogamp/opencl/JoclVersion.java
@@ -247,8 +247,12 @@ public class JoclVersion extends JogampVersion {
// System.err.println(NativeWindowVersion.getInstance());
final JoclVersion v = JoclVersion.getInstance();
System.err.println(v.toString());
- System.err.println(v.getOpenCLTextInfo(null).toString());
- // System.err.println(v.getOpenCLHtmlInfo(null).toString());
+ if( CLPlatform.isAvailable() ) {
+ System.err.println(v.getOpenCLTextInfo(null).toString());
+ // System.err.println(v.getOpenCLHtmlInfo(null).toString());
+ } else {
+ System.err.println("JOCL/OpenCL not available");
+ }
}
}
diff --git a/test/com/jogamp/opencl/gl/CLGLTest.java b/test/com/jogamp/opencl/gl/CLGLTest.java
index 62e2b2bb..c7905352 100644
--- a/test/com/jogamp/opencl/gl/CLGLTest.java
+++ b/test/com/jogamp/opencl/gl/CLGLTest.java
@@ -234,10 +234,7 @@ public class CLGLTest extends UITestCase {
@Test(timeout=15000)
public void textureSharing() {
-
out.println(" - - - glcl; textureSharing - - - ");
- if(MiscUtils.isOpenCLUnavailable())
- return;
initGL();
makeGLCurrent();
diff --git a/test/com/jogamp/opencl/test/util/MiscUtils.java b/test/com/jogamp/opencl/test/util/MiscUtils.java
index 85798a06..9cd625b8 100644
--- a/test/com/jogamp/opencl/test/util/MiscUtils.java
+++ b/test/com/jogamp/opencl/test/util/MiscUtils.java
@@ -93,8 +93,12 @@ public class MiscUtils {
* @return true if OpenCL is not available for this operating system, CPU architecture, et cetera.
* This is meant to be a check that there can't possibly be a driver installed because
* nobody makes one, not just a check that we didn't see one.
+ * <p>
+ * To check whether an OpenCL implementation/library has actually been loaded,
+ * use {@link CLAbstractImpl#isAvailable()}.
+ * </p>
*/
- public static final boolean isOpenCLUnavailable() {
- return !CLAbstractImpl.isAvailable() && knownOSWithoutCLImpl.contains(Platform.getOSType());
+ public static final boolean isKnownOSWithoutCLImpl() {
+ return knownOSWithoutCLImpl.contains(Platform.getOSType());
}
}
diff --git a/test/com/jogamp/opencl/test/util/UITestCase.java b/test/com/jogamp/opencl/test/util/UITestCase.java
index b27f2061..c3c59f3b 100644
--- a/test/com/jogamp/opencl/test/util/UITestCase.java
+++ b/test/com/jogamp/opencl/test/util/UITestCase.java
@@ -36,6 +36,7 @@ import java.util.List;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.locks.SingletonInstance;
+import com.jogamp.opencl.CLPlatform;
import org.junit.Assume;
import org.junit.Before;
@@ -126,7 +127,7 @@ public abstract class UITestCase {
@Before
public void setUp() {
System.err.print("++++ UITestCase.setUp: "+getFullTestName(" - "));
- final boolean isOpenCLUnavailable = MiscUtils.isOpenCLUnavailable();
+ final boolean isOpenCLUnavailable = !CLPlatform.isAvailable();
final boolean abortTest = isOpenCLUnavailable || !testSupported;
if( abortTest ) {
if( isOpenCLUnavailable ) {