Repository: incubator-systemml Updated Branches: refs/heads/master 47c2dd10f -> aa6d38c94
[MINOR] Show native library paths only when log4j is set debug or lower level Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/aa6d38c9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/aa6d38c9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/aa6d38c9 Branch: refs/heads/master Commit: aa6d38c94b632d7fb09869a78887df8485ddeaf3 Parents: 47c2dd1 Author: Niketan Pansare <[email protected]> Authored: Tue May 2 17:32:53 2017 -0700 Committer: Niketan Pansare <[email protected]> Committed: Tue May 2 17:32:53 2017 -0700 ---------------------------------------------------------------------- .../org/apache/sysml/utils/NativeHelper.java | 30 +++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/aa6d38c9/src/main/java/org/apache/sysml/utils/NativeHelper.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/utils/NativeHelper.java b/src/main/java/org/apache/sysml/utils/NativeHelper.java index 303b7a8..7de52fd 100644 --- a/src/main/java/org/apache/sysml/utils/NativeHelper.java +++ b/src/main/java/org/apache/sysml/utils/NativeHelper.java @@ -115,22 +115,24 @@ public class NativeHelper { String blasPathAndHint = ""; // ------------------------------------------------------------ // This logic gets the list of native libraries that are loaded - try { - java.lang.reflect.Field loadedLibraryNamesField = ClassLoader.class.getDeclaredField("loadedLibraryNames"); - loadedLibraryNamesField.setAccessible(true); - @SuppressWarnings("unchecked") - Vector<String> libraries = (Vector<String>) loadedLibraryNamesField.get(ClassLoader.getSystemClassLoader()); - LOG.debug("List of native libraries loaded:" + libraries); - for(String library : libraries) { - if(library.endsWith("libmkl_rt.so")) - blasPathAndHint = " from the path " + library; - else if(library.endsWith("libopenblas.so")) { - blasPathAndHint = " from the path " + library + ". Hint: Please make sure that the libopenblas.so is built with GNU OpenMP threading (ldd " + library + " | grep libgomp)."; + if(LOG.isDebugEnabled()) { + // Only perform the checking of library paths when DEBUG is enabled to avoid runtime overhead. + try { + java.lang.reflect.Field loadedLibraryNamesField = ClassLoader.class.getDeclaredField("loadedLibraryNames"); + loadedLibraryNamesField.setAccessible(true); + @SuppressWarnings("unchecked") + Vector<String> libraries = (Vector<String>) loadedLibraryNamesField.get(ClassLoader.getSystemClassLoader()); + LOG.debug("List of native libraries loaded:" + libraries); + for(String library : libraries) { + if(library.contains("libmkl_rt") || library.contains("libopenblas")) { + blasPathAndHint = " from the path " + library; + break; + } } + } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { + LOG.debug("Error while finding list of native libraries:" + e.getMessage()); } - } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { - LOG.debug("Error while finding list of native libraries:" + e.getMessage()); - } + } // ------------------------------------------------------------ LOG.info("Using native blas: " + blasType + blasPathAndHint);
