fommil / matrix-toolkits-java

:rocket: High Performance Linear Algebra OOP
GNU Lesser General Public License v3.0
360 stars 104 forks source link

Fail to replace netlib-java DLL by MKL #93

Closed SG38 closed 7 years ago

SG38 commented 7 years ago

Hello, I appreciate your work, thank you for that work. Under Windows (64), I try to replace the netlib-native_ref-win-x86_64-1.1.dll by mkl_rt.dll to use BLAS dgemv by doing in Java:

Properties props = System.getProperties(); props.setProperty("com.github.fommil.netlib.NativeSystemBLAS.natives", "mkl_rt.dll"); props.setProperty("com.github.fommil.netlib.NativeSystemLAPACK.natives", "mkl_rt.dll");

The MKL dll is loaded. However, the Java claims: java.lang.UnsatisfiedLinkError: com.github.fommil.netlib.NativeSystemBLAS.dgemv(Ljava/lang/String;IID[DI[DID[DI)V at com.github.fommil.netlib.NativeSystemBLAS.dgemv(Native Method) at no.uib.cipr.matrix.DenseMatrix.multAdd(DenseMatrix.java:397) ...

I must add, that I have uncommented the code in the pom.xml to allow to load the native library.

Is there a chance to succeed? Thank you very much.

fommil commented 7 years ago

This doesn't look like a bug in netlib-java, it looks more like a support request for your machine.

Unfortunately I simply don't have the time to help out with these sorts of requests without a commercial contract in place. Most of the information that you need to solve this problem is available in the README and a seasoned GNU/Linux admin would be able to solve it for you. I'm not interested in making any more binary builds available for custom distributions.

If you'd be interested in getting your organisation to sponsor me to work on the netlib-java roadmap, to add support for additional native libraries or hardware (e.g. graphics cards and FPGAs) that is something I'd be interested in on a commercial basis.

fommil commented 7 years ago

also note, your question is answered specifically in the README

VerliererK commented 7 years ago

I have built successfully. You don't have setProperty. The easy way is to copy mkl_rt.dll into both libblas3.dll and liblapack3.dll, so that native_system can find it and other 5 dlls in your path: libiomp5md.dll mkl_avx2.dll mkl_core.dll mkl_intel_thread.dll mkl_rt.dll

Call System.loadlibrary("mkl_rt") in your code first, otherwise it would have an error: Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll.

My Cpu is i5-4570, maybe you have to copy another DLL if you are using i7. I can use matrix multiplication and svd decomposition with MKL. Surprisingly, svd with MKL is faster than openBLAS.:smile: