array
plb2
Our great sponsors
array | plb2 | |
---|---|---|
5 | 7 | |
188 | 236 | |
- | - | |
6.9 | 9.5 | |
4 months ago | about 2 months ago | |
C++ | C | |
Apache License 2.0 | Creative Commons Zero v1.0 Universal |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
array
-
Einsum in 40 Lines of Python
I wrote a library in C++ (I know, probably a non-starter for most reading this) that I think does most of what you want, as well as some other requests in this thread (generalized to more than just multiply-add): https://github.com/dsharlet/array?tab=readme-ov-file#einstei....
A matrix multiply written with this looks like this:
enum { i = 2, j = 0, k = 1 };
-
Benchmarking 20 programming languages on N-queens and matrix multiplication
I should have mentioned somewhere, I disabled threading for OpenBLAS, so it is comparing one thread to one thread. Parallelism would be easy to add, but I tend to want the thread parallelism outside code like this anyways.
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...
-
A basic introduction to NumPy's einsum
If you are looking for something like this in C++, here's my attempt at implementing it: https://github.com/dsharlet/array#einstein-reductions
It doesn't do any automatic optimization of the loops like some of the projects linked in this thread, but, it provides all the tools needed for humans to express the code in a way that a good compiler can turn it into really good code.
plb2
-
Byte-Sized Swift: Building Tiny Games for the Playdate
https://github.com/attractivechaos/plb2 - limited but broad comparison across a large number of languages. Swift and Nim both compare favourably to C.
-
The One Billion Row Challenge in Go: from 1m45s to 4s in nine solutions
https://github.com/attractivechaos/plb2/blob/master/README.m...
Synthetic benchmarks aside, I think as far as average (spring boots of the world) code goes, Go beats Java almost every time, often in less lines than the usual pom.xml
-
Python 3.13 Gets a JIT
I wouldn't be so enthusiastic. Look at other languages that have JIT now: Ruby and PHP. After years of efforts, they are still an order of magnitude slower than V8 and even PyPy [1]. It seems to me that you need to design a JIT implementation from ground up to get good performance – V8, Dart, LuaJIT and PyPy are like this; if you start with a pure interpreter, it may be difficult to speed it up later.
[1] https://github.com/attractivechaos/plb2
-
Benchmarking 20 programming languages on N-queens and matrix multiplication
A 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.
What are some alternatives?
optimizing-the-memory-layout-of-std-tuple - Optimizing the memory layout of std::tuple
c-examples - Example C code
NumPy - The fundamental package for scientific computing with Python.
laser - The HPC toolbox: fused matrix multiplication, convolution, data-parallel strided tensor primitives, OpenMP facilities, SIMD, JIT Assembler, CPU detection, state-of-the-art vectorized BLAS for floats and integers
cadabra2 - A field-theory motivated approach to computer algebra.
weave - A state-of-the-art multithreading runtime: message-passing based, fast, scalable, ultra-low overhead
alphafold2 - To eventually become an unofficial Pytorch implementation / replication of Alphafold2, as details of the architecture get released
tarantool - Get your data in RAM. Get compute close to data. Enjoy the performance.
Einsum.jl - Einstein summation notation in Julia
blis - BLAS-like Library Instantiation Software Framework
related_post_gen - Data Processing benchmark featuring Rust, Go, Swift, Zig, Julia etc.