luhenry commented on pull request #30810: URL: https://github.com/apache/spark/pull/30810#issuecomment-832774216
> However, it is strange that you're not providing benchmarks against machine-optimised MKL (or otherwise) backends as described in http://fommil.com/scalax14/#/ You can find the comparison to machine-optimised MKL and OpenBLAS in https://github.com/apache/spark/pull/32415. There, the `javaBLAS` on JDK 16 is using the Vector API. You can see the performance is equivalent or better on most level-1 and level-2 operations but still lacks on level-3 operations (there is a write-up why at https://mail.openjdk.java.net/pipermail/panama-dev/2021-January/011930.html). > The f2j backend is just the fallback and could be replaced in the most part (e.g. dgemm) with 10 lines of java code. Yep, agreed. That's what I did for some operations in `javaBLAS`. I get some decent speedups over f2j for some of the operations and even matching the native implementations in some cases. > Lots of benchmarks over at https://github.com/fommil/matrix-toolkits-java as another consumer of netlib-java that address your comments about "memory copying" (which is incorrect). I'll definitely look into these higher-level benchmarks, thanks for the pointer! And you're right, my comment about memory copying was based on the wrong assumption that JNI doesn't support passing java heap memory to native libraries without copying. By using [`Get/ReleasePrimitiveArrayCritical`](https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#GetPrimitiveArrayCritical_ReleasePrimitiveArrayCritical), you can do just that. That is however something that is not possible with the [Foreign Linker API](https://openjdk.java.net/jeps/412) without using a`MemorySegment` backed by native memory, and which would be very invasive for Spark (and not compatible with Java 8 nor 11). A future avenue of improvement will be to support Sparse Matrix/Vector operations in `dev.ludovic.netlib` directly so that we can take advantage of native libraries that do provide such routines, or fall back to a hand-optimized pure-java fallback. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
