I have several functions doing matrix computations using MathNet Numerics + Intel MKL provider. The matrices are not too large, something like 40x100, and the operations involve some pseudoinverses, eigenvalues, and similar linear algebra stuff.
However, having created a small benchmark app to just run the calculation 1000 times, it turns out that our new Intel Xeon Gold 6226R (16 core, 32 threads) runs the calculations 2x slower than my old i7 7700HQ (4 core, 8 thread) laptop, and slower than basically all 5-6 year old PCs I could test.
I have tried both "native Intel MKL" and "managed" multi-threaded providers. MKL is ~2x slower, while the managed one is perhaps 10% faster.
Furthermore, when running the test on my i7 laptop, I get ~80% CPU utilization and it runs at ~3.5GHz. But the Xeon lowers the frequency to around ~2GHz and then uses ~30-40% utilization. Both the laptop (Windows 10) and the server (Windows Server 2019) are set to High Performance mode.
I am pretty sure that there should be some trick I am missing here?
(Update)
In case someone has this same issue, it's possible to disable AVX512 by setting the MKL_ENABLE_INSTRUCTIONS
env. variable to AVX2
. This speeds up MKL a bit on Xeon:
SET MKL_ENABLE_INSTRUCTIONS=AVX2
But this still doesn't make it as fast as the i7.
The only way where the Xeon can beat the i7 if I disable MKL and use the MathNet Numerics managed provider, and then also use a Parallel.For
loop to run all in parallel. In that case, Xeon is ~30% faster, although admittedly its CPU usage still doesn't get over 40% (the i7 CPU is maxed out).
Still a bit disappointing considering how many extra cores it provides.