Skip to content

Commit

Permalink
* Add "org.bytedeco.javacpp.openblas.load" system property to use li…
Browse files Browse the repository at this point in the history
…braries from Accelerate, etc (pull #444)
  • Loading branch information
saudet committed Feb 2, 2018
1 parent 7cbfa5a commit 553517a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Add "org.bytedeco.javacpp.openblas.load" system property to use libraries from Accelerate, etc ([pull #444](https://github.com/bytedeco/javacpp-presets/pull/444))
* Upgrade presets for TensorFlow 1.5.0
* Include `facemark.hpp`, `facemarkLBF.hpp`, `facemarkAAM.hpp`, `face_alignment.hpp` from the `opencv_face` module
* Add `AxpyLayer` to presets for Caffe ([pull #508](https://github.com/bytedeco/javacpp-presets/pull/508))
Expand Down
6 changes: 4 additions & 2 deletions openblas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Java API documentation is available here:

∗ The JNI bindings actually link with [Intel MKL](https://software.intel.com/intel-mkl) instead if found on the "java.library.path", unless the "org.bytedeco.javacpp.openblas.nomkl" system property is set to "true".

It also possible to make the bindings use another arbitrary library in "java.library.path" by specifying it with the "org.bytedeco.javacpp.openblas.load" system property. For example, to use the BLAS library from the [Accelerate framework](https://developer.apple.com/documentation/accelerate) on Mac OS X, we can pass options such as `-Djava.library.path=/usr/lib/ -Dorg.bytedeco.javacpp.openblas.load=blas`.


Sample Usage
------------
Expand All @@ -36,15 +38,15 @@ We can use [Maven 3](http://maven.apache.org/) to download and install automatic
<modelVersion>4.0.0</modelVersion>
<groupId>org.bytedeco.javacpp-presets.openblas</groupId>
<artifactId>openblas</artifactId>
<version>1.4</version>
<version>1.4.1-SNAPSHOT</version>
<properties>
<exec.mainClass>ExampleDGELSrowmajor</exec.mainClass>
</properties>
<dependencies>
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>openblas-platform</artifactId>
<version>0.2.20-1.4</version>
<version>0.2.20-1.4.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Expand Down
2 changes: 1 addition & 1 deletion openblas/src/main/java/org/bytedeco/javacpp/openblas.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Targeted by JavaCPP version 1.4: DO NOT EDIT THIS FILE
// Targeted by JavaCPP version 1.4.1-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.javacpp;

Expand Down
19 changes: 17 additions & 2 deletions openblas/src/main/java/org/bytedeco/javacpp/presets/openblas.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Iterator;
import java.util.List;
import org.bytedeco.javacpp.ClassProperties;
import org.bytedeco.javacpp.Loader;
import org.bytedeco.javacpp.LoadEnabled;
import org.bytedeco.javacpp.annotation.Platform;
import org.bytedeco.javacpp.annotation.Properties;
Expand All @@ -40,9 +41,9 @@
include = {"openblas_config.h", "cblas.h", "blas_extra.h", "lapacke_config.h", "lapacke_mangling.h", "lapacke.h", "lapacke_utils.h"},
link = "openblas@.0", resource = {"include", "lib"},
preload = {"iomp5", "mkl_avx", "mkl_avx2", "mkl_avx512", "mkl_avx512_mic", "mkl_def", "mkl_mc", "mkl_mc3", "mkl_core", "mkl_gnu_thread",
"mkl_intel_lp64", "mkl_intel_thread", "mkl_rt", "mkl_rt#openblas@.0", "gcc_s@.1", "quadmath@.0", "gfortran@.3"}, compiler = "fastfpu",
"mkl_intel_lp64", "mkl_intel_thread", "mkl_rt", "mkl_rt#openblas@.0", "gcc_s@.1", "quadmath@.0", "gfortran@.3"},
preloadpath = {"/opt/intel/lib/", "/opt/intel/mkl/lib/"}),
@Platform(value = "android", include = {"openblas_config.h", "cblas.h", "blas_extra.h" /* no LAPACK */}, link = "openblas", preload = "", compiler = "fastfpu"),
@Platform(value = "android", include = {"openblas_config.h", "cblas.h", "blas_extra.h" /* no LAPACK */}, link = "openblas", preload = ""),
@Platform(value = "macosx", link = "openblas",
preload = {"iomp5", "mkl_avx", "mkl_avx2", "mkl_avx512", "mkl_avx512_mic", "mkl_def", "mkl_mc", "mkl_mc3", "mkl_core", "mkl_gnu_thread",
"mkl_intel_lp64", "mkl_intel_thread", "mkl_rt", "mkl_rt#openblas", "gcc_s@.1", "quadmath@.0", "gfortran@.3"}),
Expand All @@ -61,6 +62,7 @@
public class openblas implements LoadEnabled, InfoMapper {

@Override public void init(ClassProperties properties) {
// let users disable loading of MKL
String s = System.getProperty("org.bytedeco.javacpp.openblas.nomkl", "false").toLowerCase();
if (s.equals("true") || s.equals("t") || s.equals("")) {
List<String> preloads = properties.get("platform.preload");
Expand All @@ -72,6 +74,19 @@ public class openblas implements LoadEnabled, InfoMapper {
}
}
}
// let users enable loading of arbitrary library (for Accelerate, etc)
String lib = System.getProperty("org.bytedeco.javacpp.openblas.load", "").toLowerCase();
if (lib.length() > 0) {
String platform = Loader.getPlatform();
List<String> preloads = properties.get("platform.preload");
if (platform.startsWith("linux")) {
preloads.add(0, lib + "#openblas@.0");
} else if (platform.startsWith("macosx")) {
preloads.add(0, lib + "#openblas");
} else if (platform.startsWith("windows")) {
preloads.add(0, lib + "#libopenblas");
}
}
}

@Override public void map(InfoMap infoMap) {
Expand Down

0 comments on commit 553517a

Please sign in to comment.