Differences between netlib-java?

599 views
Skip to first unread message

Ben Mabey

unread,
Oct 25, 2011, 2:11:53 PM10/25/11
to jblas...@googlegroups.com
Hi,
I am researching my options for using BLAS and LAPACK on the JVM.  I've had my eye on the jblas project for a while and it seems like it does everything I would need.  I recently stumbled across these options though:

http://code.google.com/p/netlib-java/
http://code.google.com/p/matrix-toolkits-java/ (an API that wraps the above project)


From what I can tell jblas packages the native deps to avoid JNI compilation hassles on the user's end (yay!). jblas also provides a nice high-level API similar to the matrix-toolkits-java project (I'd imagine- I haven't looked at the matrix-toolkits-java API closely).

netlib-java's main goal seems to be to allow users to switch between a pure java-based implementation (http://sourceforge.net/projects/f2j/) and the actual BLAS libraries.  This seems like a worthwhile goal as they point out/claim that " native libs only out-perform the Java implementation if specific hardware is used or matrices are larger than 1000 x 1000 elements".  In other words, you can take the JNI cost-hit when you need to but otherwise stay in JVM-land.  As far as I can tell netlib-java doesn't pre-package native deps though like jblas does.

So, based on the little research I've done if I want to use the native BLAS libs via JNI jblas will make my life easier.  However, if I want the flexibility to switch over to JVM based calculations in other circumstances netlib-java may be a better fit.  Does this sound like a fair conclusion?  Or are there other details about jblas that I should be considering?

Thanks,
Ben



Mikio Braun

unread,
Oct 25, 2011, 2:46:44 PM10/25/11
to jblas...@googlegroups.com
Hi Ben,

yes, in a nutshell what you said is probably correct.

However, I'm not sure whether mtj or netlib can dynamically switch
between native and Java code. My impression was that it either loads
the native code or the Java code. Also, the point at which it makes
sense to use the native routines is much lower than you would think.
In the end, it depends a lot on what kind of application you have in
mind, and the typical sizes of your vectors, and the typical
operations. If it's mostly small (n < 10) vectors and operations like
vector addition or matrix-vector multiplication then you'd be fine
with a pure Java solution. If you have larger matrices (say 100x100)
and are also looking into more complex operations like
eigendecompositions, SVD, QR, etc., then the native code will be much
much faster.

Finally, jblas also doesn't use native code for all operations. For
operations where the number of operations is the same as the number of
elements, the operations are computed in Java because it's much faster
than first copying the stuff.

My recommendation would be to think about what kinds of operations you
are interested in and run a few benchmarks between the candidates.
This will also give you a bit of a feel for the interfaces and whether
you like them or not. With jblas I tried to run a very minimalistic
approach without many interfaces, and using a lot of overloading to
make it easy to express operations. Other libraries have different
approaches. The downside of jblas is that there is little
interoperability between float and double matrices, which is probably
ok because you'll just use either one anyway (meaning it's not that
easy to add a double matrix to a float matrix, for example).

Hope this helps,

-M

> --
> You received this message because you are subscribed to the Google Groups
> "jblas-users" group.
> To post to this group, send email to jblas...@googlegroups.com.
> To unsubscribe from this group, send email to
> jblas-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/jblas-users?hl=en.
>

--
Dr. Mikio Braun, Beckerstr. 11, 12157 Berlin
Privat: 030 / 42 10 56 42, Büro: 030 / 314 78627, Handy: 0172 / 97 45 676

Ben Mabey

unread,
Oct 25, 2011, 10:46:39 PM10/25/11
to jblas-users
Thanks for the fast reply Mikio.

Yeah, I think you are right about netlib-java not being able to switch
dynamically. For my immediate need I already know that I'm dealing
with large matrices that would benefit from the native speedup.
(Although, I'm just doing simple operations.. no decomps or anything
at the moment.) I suspect jblas will be the better fit here but I'll
run some benchmarks to verify. I'll ping the list if I have any other
questions.

Thanks again for the fast reply and the library!

-Ben
> >http://code.google.com/p/matrix-toolkits-java/(an API that wraps the above
Reply all
Reply to author
Forward
0 new messages