Breeze slower with netlib than without it

106 views
Skip to first unread message

Ivan Nikolaev

unread,
Aug 20, 2015, 11:58:30 AM8/20/15
to Scala Breeze

Hello everyone,

I tried posting this once, but it never appeared.

I am learning how to use breeze and have stumbled upon surprising results.
I am doing some simple matrix/vector addition and multiplication operations,
as well as calculating exp and vector sum. When I load netlib-java library
through maven, I get significantly worse performance than without it.
Also, when I use an array of vectors instead of a matrix I get better performance,
which is something that my matlab experience tells me should be the other way 
around.

I am running all this on a MacBook pro with  2.3 GHz Intel Core i7 processor.

Here are the run results:

Without netlib:
Aug 20, 2015 2:58:04 PM com.github.fommil.netlib.BLAS <clinit>
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeSystemBLAS
Aug 20, 2015 2:58:04 PM com.github.fommil.netlib.BLAS <clinit>
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeRefBLAS
Vector version took 26.927885357 seconds
Matrix version took 87.750030486 seconds

With netlib:
Aug 20, 2015 3:02:04 PM com.github.fommil.jni.JniLoader liberalLoad
INFO: successfully loaded /var/folders/w6/gnnw541s7v548y5yqd9sqfvc0000gn/T/jniloader8864377321849022943netlib-native_system-osx-x86_64.jnilib
Vector version runs: 148.106227193 seconds
Matrix version runs: 240.031840978 seconds

For comparison, a mex function in Matlab that performs the same calculation:
Elapsed time is 15.725586 seconds.


Any help would be greatly appreciated. Attached is the scala object that I
use to measure performance.

I am going to have to do a lot of optimisation in breeze, if you have any tips for
useful resources, please tell.


Best regards,
Ivan
GaussMixtureTransform.scala

Daniel Korzekwa

unread,
Oct 4, 2015, 11:42:10 AM10/4/15
to Scala Breeze
try samples(*, ::) instead of samples(::, *) inside of def samplesTransform(samples: DenseMatrix[Double].....

It should be 50% faster, breeze uses column wise representation.

It is a response from some guy to my question on scala vs octave performance I posted on stackoverflow:
"Never quite sure why people think that dedicated library functions in Octave, Matlab, and Mathematica would be in a standard programming language. If they were it would essentially make those products redundant!"

Maybe he is right (:, hope not,, I wish we had in Scala all the goodness of R and Octave/Matlab for statistical and numerical processing. I wish David had 10 bothers or sisters who could help him, eeehh..
Reply all
Reply to author
Forward
0 new messages