I was running some performance tests on <https://g...
# mathematics
a
I was running some performance tests on https://github.com/JetBrains-Research/viktor (it adds native SIMD support to simple matrix operations) with GraalVM. While without GraalVM, native SIMD is slightly faster (less than 2 times), with it, JVM runs two times faster without native boost (kmath
RealField
). It is not a conclussion, we need to test it further, but I think it is time to forget "native means fast". I've already showed some tests, where kotlin code runs faster than numpy.
👍 1
a
viktor
maintainer here. it would certainly be nice to see the benchmarks in question. :)) and the architecture used to run them (arch, OS, SIMD extension set).
a
I've just run those simple tests: https://github.com/mipt-npm/kmath/blob/dev/examples/src/main/kotlin/scientifik/kmath/structures/VictorTest.kt Windows 10 on AMD64. I've run them on AdoptOpenJDK12 and on GraalVM-19.3-11. The result on OpenJDK is expected - Viktor runs about 1.5 times faster. Not a proper JMH test, mind you, so we need to be careful about it, but it is consistent with your benchmarks. On GraalVM, my inlined functions produce about two times better result than Viktor. In any case, I am doing an integration of Viktor to kmath API, so it will be possible to decide on specific backend when needed.
Sadly, the most critical operations are not element-by-element additiona, but matrix inversion. It is hard to do fast without library support and it is the primary bottleneck as far as I can understand. I did not found any API for it in Viktor.
a
@altavir that's because viktor is not specifically designed for linear algebra tasks. it doesn't have built-in matrix multiplication, inversion, determinant and things like that. the primary bottleneck is our specific case was array logarithm/exponent and log-addition.
@altavir out of curiosity, can you run a similar test for logarithm and exponent operations? also, what SIMD extension set does your CPU support? AVX or SSE2?
a
Not sure, it is AMD FX8000 serries
FX8350 to be specific
I have not tried actual logariphm/exponent addition, but I can add specific checks later. Kmath is not optimized for those kind of things, but we need to check it.
@Aleksei Dievskii could you write a piece of code you would like to compare. We need proper JMH of course, but it is a little bit complicated at the moment in kotlin since kotlinx-benchmarks is not very stable yet.
You seem to have two different accounts on slack...
a
I created a new one for this workspace. I was operating under assumption that different workspaces are separate and require separate accounts.
a
You mean channels? Different workspaces indeed have different accounts.
a
no, this is
kotlinlang
workspace, and my main Slack activity is in
jetbrains
workspace.
a
There is a way to connect workspaces now. Maybe they are somehow connected
I can run test on intell processor now if my work computer is not turned off.
a
I don't seem to own the second account. at least I don't receive the messages directed to it.
a
I mean this one: @dievsky
a
me too.
it doesn't seem to be connected to me in any capacity (except the name).
if GraalVM is so smart, it should SIMDize array logarithm just as well.
and an appropriate version for the
NDField
(you do seem to have a general-purpose
map
).
a
Map is a little bit tricky because of it should be inlined for primitives. But as long as we are using only
Double
everything should work correctly.