Skip to content

Symbol name clash with Matlab's MKL #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
blechta opened this issue Jul 3, 2018 · 3 comments
Closed

Symbol name clash with Matlab's MKL #1

blechta opened this issue Jul 3, 2018 · 3 comments

Comments

@blechta
Copy link
Owner

blechta commented Jul 3, 2018

It turns out that loading built OpenBLAS leads to segfault whenever Matlab wants to use anything from BLAS or LAPACK.

Fortunately one can easily modify symbol names of the OpenBLAS build, using this feature OpenMathLib/OpenBLAS#459, using simple change:

diff --git a/build/share/pardiso_wrappers.conf b/build/share/pardiso_wrappers.conf
index 5e9e33a..a5c8575 100755
--- a/build/share/pardiso_wrappers.conf
+++ b/build/share/pardiso_wrappers.conf
@@ -13,7 +13,7 @@ export MATLABPATH="${PREFIX}/matlab:${MATLABPATH}"
 export LD_LIBRARY_PATH="${PREFIX}/lib:${LD_LIBRARY_PATH}"
 
 # Tell matlab to load OpenBLAS instead of its MKL
-export LD_PRELOAD="${PREFIX}/lib/libopenblas.so"
+export LD_PRELOAD="${PREFIX}/lib/libmatpar_openblas.so"
 
 # Get rid of annoying license message
 export PARDISOLICMESSAGE=1
diff --git a/make_openblas.sh b/make_openblas.sh
index 1883fcc..00e2404 100755
--- a/make_openblas.sh
+++ b/make_openblas.sh
@@ -11,5 +11,5 @@ tar -xzf OpenBLAS-${OPENBLAS_VERSION}.tar.gz
 
 # Build and install OpenBLAS into the build dir
 cd OpenBLAS-${OPENBLAS_VERSION}
-make NO_LAPACKE=1 NO_CBLAS=1 USE_OPENMP=0 USE_THREAD=0
-make install NO_LAPACKE=1 NO_CBLAS=1 NO_STATIC=1 PREFIX="${PREFIX}"
+make NO_LAPACKE=1 NO_CBLAS=1 USE_OPENMP=0 USE_THREAD=0 SYMBOLPREFIX="matpar_"
+make install NO_LAPACKE=1 NO_CBLAS=1 NO_STATIC=1 PREFIX="${PREFIX}" SYMBOLPREFIX="matpar_"

Bad thing is that all symbols in libpardiso600-GNU720-X86-64.so are dynamic. So we can't rename them see, https://stackoverflow.com/a/20599760. We can't also link together libpardiso600-GNU720-X86-64.so and libopenblas, see https://stackoverflow.com/a/924181. It seems like our only option is to ask Pardiso team to provide us either libpardiso.so with prefixed BLAS symbols or give us libpardiso.a.

Other hacking might be possible: http://www.fcollyer.com/2013/01/04/elf-symbol-visibility-and-the-perils-of-name-clashing/.

@RoyiAvital
Copy link

Any chance you build a recipe for Windows?
At least for the MEX?

@blechta
Copy link
Owner Author

blechta commented Aug 13, 2018

Sorry, can't help. I don't have a Windows machine.

@blechta blechta closed this as completed Aug 13, 2018
@blechta
Copy link
Owner Author

blechta commented Aug 13, 2018

Pardiso team is not willing to provide any help fixing the problem. So that leaves these recipes with breaking any functionality in Matlab which uses BLAS/LAPACK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants