Earlier quoted context omitted.
...and many jitted vms do not even reach a stable point at all, there was a big paper on this a couple of years ago.
This? https://tratt.net/laurie/blog/2018/why_arent_more_users_more...
Benchmarking 20 programming languages on N-queens and matrix multiplication
161–170 of 194 posts
Re: Benchmarking 20 programming languages on N-queens and matrix multiplication
#162Why is c# so slow for Matmul compared to java?
I believe because the C# version has been written using rectangular arrays. This requires every array access to use a multiplication. The Java version uses array-of-arrays and hoisting the inner array out before accessing it in the inner loop. C# also has arrays-of-arrays, and could (should) be written in the same manner.
Re: Benchmarking 20 programming languages on N-queens and matrix multiplication
#163Why is c# so slow for Matmul compared to java?
I believe because the C# version has been written using rectangular arrays. This requires every array access to use a multiplication. The Java version uses array-of-arrays and hoisting the inner array out before accessing it in the inner loop. C# also has arrays-of-arrays, and could (should) be written in the same manner.
Re: Benchmarking 20 programming languages on N-queens and matrix multiplication
#164Earlier quoted context omitted.
Yes, but the author claims the longest JIT warmup is 0.3 seconds, so it's not an important issue in these benchmarks that take several seconds.
0.3s is significant for a task that only takes 1.14s
Maybe that was PyPy with program times >5 seconds.
Re: Benchmarking 20 programming languages on N-queens and matrix multiplication
#165How come not all benchmarks appear on all languages? For example, Zig's bar appears to be lower than C's by virtue of sudoku and bedconv being missing.
Re: Benchmarking 20 programming languages on N-queens and matrix multiplication
#166Earlier quoted context omitted.
This is really overstating how hard it is to compete with matrix multiply libraries. The main reason those libraries are so big and have had so much work invested in them is their generality: they're reasonably fast for almost any kind of inputs. If you have a specific problem with constraints you can exploit (e.g. known fixed dimensions, sparsity patterns, data layouts, type conversions, etc.), it's not hard at all…
> This is really overstating how hard it is to compete with matrix multiply libraries. I'll file this under "talk is cheap". :) I tried it last year and got within 50% of BLAS. Getting above that is tons of work. Which you have to repeat for every processor model, NUMA, and every combination of matrix type (long thin, short wide, etc).
The less involved versions still get ~70%.
But this is also quite general. I’m claiming you can beat BLAS if you have some unique knowledge of the problem that you can exploit. For example, some kinds of sparsity can be implemented within the above example code yet still far outperform the more general sparsity supported by MKL and similar.
Re: Benchmarking 20 programming languages on N-queens and matrix multiplication
#167Re: Benchmarking 20 programming languages on N-queens and matrix multiplication
#168Earlier quoted context omitted.
> This is really overstating how hard it is to compete with matrix multiply libraries. I'll file this under "talk is cheap". :) I tried it last year and got within 50% of BLAS. Getting above that is tons of work. Which you have to repeat for every processor model, NUMA, and every combination of matrix type (long thin, short wide, etc).
This gets to 90% of BLAS: https://github.com/dsharlet/array/blob/38f8ce332fc4e26af0832... The less involved versions still get ~70%. But this is also quite general. I’m claiming you can beat BLAS if you have some unique knowledge of the problem that you can exploit. For example, some kinds of sparsity can be implemented within the above example code yet still far outperform the more general sparsity supported by MKL…
Re: Benchmarking 20 programming languages on N-queens and matrix multiplication
#169Earlier quoted context omitted.
This gets to 90% of BLAS: https://github.com/dsharlet/array/blob/38f8ce332fc4e26af0832... The less involved versions still get ~70%. But this is also quite general. I’m claiming you can beat BLAS if you have some unique knowledge of the problem that you can exploit. For example, some kinds of sparsity can be implemented within the above example code yet still far outperform the more general sparsity supported by MKL…
I don't believe you. OpenBLAS is multithreaded but the code you posted is single-threaded. The inner kernel isn't very well optimized either. So, no way.
As for the inner loop not being well optimized... the disassembly looks like the same basic thing as OpenBLAS. There's disassembly in the comments of that file to show what code it generates, I'd love to know what you think is lacking! The only difference between the one I linked and this is prefetching and outer loop ordering: https://github.com/dsharlet/array/blob/master/examples/linea...
Re: Benchmarking 20 programming languages on N-queens and matrix multiplication
#170A curious thing about Swift: after https://github.com/attractivechaos/plb2/pull/23 , the matrix multiplication example is comparable to C and Rust. However, I don’t see a way to idiomatically optimise the sudoku example, whose main overhead is allocating several arrays each time solve() is called. Apparently, in Swift there is no such thing as static array allocation. That’s very unfortunate.
There are only 20 thousand array allocations in total, not a lot. Javascript also has these many arrays allocated/deallocated but it is 4 times as fast.