netlib-java icon indicating copy to clipboard operation
netlib-java copied to clipboard

Native/system BLAS on Android

Open ibrahima opened this issue 9 years ago • 3 comments

Hi, I'm wondering how I might go about using netlib-java or its derivatives with native libraries on Android and if you had any tips. I see that you've ported it to Raspberry Pi so that seems promising for Android, but since you usually don't have a build environment on Android itself we have to cross compile, which makes things complicated. I've tried the braindead step of just grabbing ARM versions of libblas.so and liblapack.so from Ubuntu repos (I guess using ATLAS) and sticking them in /system/lib but this doesn't work. Do I need gfortran as well? Do you have any suggestions on how to debug the JNI native library loading process so I can see what it's doing? I'm trying to see if I can do something cool with breeze on Android and the F2J implementation works for now but obviously it's much slower than I'd want to actually use for a proper app.

Thanks!

ibrahima avatar May 15 '15 23:05 ibrahima

Android isn't real java so I honestly don't know. You might be best doing some performance tests first of DGEMM in Java and then from a C app just to get an idea of the potential benefits to see if it is worthwhile. RPi was worth it because java was really slow at the time but Google might have invested a lot in making their virtual machine really good.

fommil avatar May 16 '15 08:05 fommil

Well, I don't know how "real" Android's Java is but it does support JNI. I did manage to get openblas built for Android so I'll try and see how DGEMM performance looks for F2J vs the native implementation. My initial test of some random matrix code was like 1000x slower on Android vs PC so I figured there must be some performance to be gained by using a native implementation but I guess comparing Broadwell vs Snapdragon is never going to be a close comparison. I tried sticking openblas in the library directory symlinked to libblas.so.3 but it doesn't seem to load correctly without really telling me why (it loads fine when I force it to load via System.loadLibrary()). I might want to rebuild the JNI library but I get errors like the following when attempting to use maven to compile:

[ERROR] Plugin com.github.fommil.netlib:generator:1.2-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.github.fommil.netlib:generator:jar:1.2-SNAPSHOT: Failure to find com.github.fommil.netlib:generator:pom:1.2-SNAPSHOT in https://oss.sonatype.org/content/repositories/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of sonatype-plugins-snapshots has elapsed or updates are forced -> [Help 1]

How should I go about building netlib-java?

ibrahima avatar Jun 22 '15 01:06 ibrahima

It's documented in the pom files. Sorry, it's quite a painful process and honestly I'm only going to dive into it on a commercial basis because it's not something that I need.

fommil avatar Jun 22 '15 06:06 fommil