I'm not getting acceptable performance from existing sparse matrix libraries in Java and am starting to think the only way to improve this is with a native library. There are plenty of native matrix libraries with support for sparse matrices and a few have Java bindings. However, they require copying data between the JVM and the native lib.
I'd like to propose something different, a native extension for Vectorz which can perform costly operations with native code but without copying data back and forth between the JVM and native lib. This would be implemented by subclassing matrix classes and overriding selected methods to call native functions. The native functions would be implemented with JNI and use GetDoubleArrayElements and/or GetDoubleArrayCritical to access double arrays without the overhead of copying the elements. The JNI docs (http://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#array_operations) state that whether an array is copied is dependent on the particular JVM. So more work is necessary to determine if this is possible on Oracle's JVM (HotSpot).
I'm going to do another profiling session with SparseRowMatrix and SparseColumnMatrix from Vectorz in case I missed bottlenecks in my program code or in Vectorz. But any feedback is appreciated in the meantime before this work might begin.-MattP.S. Mike, apologies if this is antithetical to Vectorz. =)
On Thursday, 8 January 2015 06:38:49 UTC+8, Matt Revelle wrote:
I'm going to do another profiling session with SparseRowMatrix and SparseColumnMatrix from Vectorz in case I missed bottlenecks in my program code or in Vectorz. But any feedback is appreciated in the meantime before this work might begin.-MattP.S. Mike, apologies if this is antithetical to Vectorz. =)Not at all - I have considered doing something similar myself, although I was planning to do it for GPU rather than regular native code (possibly using JCublas). I don't *personally* think the difference between Vectorz and native code (maybe 2x?) is significant for the kind of work that I do, but ~10-100x improvements from utilising the GPU is potentially interesting.In both cases, the right thing would be to make a new library with both Vectorz and whatever native code is required as a dependency. The new classes should then still be fully compatible with vectorz-clj (as long as the relevant AMatrix / AVector interfaces are fully implemented)
--
You received this message because you are subscribed to a topic in the Google Groups "Numerical Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/numerical-clojure/NUO57KoLx20/unsubscribe.
To unsubscribe from this group and all its topics, send an email to numerical-cloj...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.