A Supercomputer?
The widely-accepted ranking of supercomputers is that given in the Top 500 list. This list is published twice each year, and first appeared in June 1993. It was based on an older list published by Dongerra in 1987.
So what is the Top 500 list? It simply ranks computers by performance on a single benchmark, Linpack. And what is Linpack? It is a benchmark to solve a set of simultaneous linear equations, such as
x + y + 2z = 6 2x - 3y - z = 2 -x + 2y - 3z = 4
The vendor is free to choose the size of the problem. The original 1987 list fixed it at a set of a thousand equations and hence a thousand variables (rather than the three in the above example). The use of double precision arithmetic is expected.
So that the result can be checked easily, the coefficients on the
left-hand side are generated randomly, but the constants on the
right-hand side are then calculated with all the unknowns set to
one. So the correct answer is that all the unknowns, expressed as a
vector x[0] to x[n-1], are one.
Linpack on Pi
Can we run Linpack on a Raspberry Pi? Yes! Linpack is available in
many languages, and here we will run it in Python. (As the timed
part of Linpack in Python is a single call
to numpy.linalg.solve, there should be very little
overhead from Python's interpreter.)
~$ mkdir linpack ~$ cd linpack ~/linpack$ curl -O http://www.sci-pi.org.uk/bench/linpack.py ~/linpack$ chmod +x linpack.py ~/linpack$ ./linpack.py Running Linpack 2000 x 2000 Residual is 4.256150987203e-12 Normalised residual is 19.171851934146027 Machine epsilon is 2.22e-16 x[0]-1 is 1.0795808691455022e-12 x[n-1]-1 is -7.106537580625627e-13 Time is 6.576431035995483 MFLOPS: 812.1933164201133
So above we made a new directory, changed directory to work within it, downloaded a copy of the Linpack benchmark, marked it as an executable file, and executed it. We achieved, on a standard Pi 4, in 2020, 812 MFLOPS, and that was my introduction to Linpack on a Raspberry Pi.
But using a Pi 5, and moving forward to 2024, the result is significantly better.
Time is 0.29621195793151855 MFLOPS: 18032.132701976196
Is the Pi 5 hardware really over twenty times faster than the Pi 4 hardware? No. Most of that factor of twenty comes from software improvements.
Software Experiments
The maths libraries which Linpack almost always ultimately uses are called LAPACK and BLAS. LAPACK, the Linear Algebra PACKage, itself calls BLAS, the Basic Linear Algebra Subprograms. This pair has become a standard, and the reference version is freely distributed by Netlib. The reference version is very useful in being clear, concise and correct. However, it is also serial (i.e. never makes use of more than one CPU core), and is not optimised for caches. People have put considerable time into producing speed-optimised versions BLAS. Many hardware vendors have optimised BLAS libraries, such as Intel's Math Kernel Library (MKL) and Apple's Accelerate Framework. There is also an open-source project supporting many different CPUs called OpenBLAS.
In 2020, the Raspberry Pi defaulted to the reference Netlib version of BLAS. But depending on what other packages are installed, it might defaults to the optimised OpenBLAS version.
$ update-alternatives --display liblapack.so.3-aarch64-linux-gnu link currently points to /usr/lib/aarch64-linux-gnu/openblas-pthread/liblapack.so.3 /usr/lib/aarch64-linux-gnu/lapack/liblapack.so.3 - priority 10 /usr/lib/aarch64-linux-gnu/openblas-pthread/liblapack.so.3 - priority 100
When running the Debian 12-based Raspberry Pi OS 5.x, I wrote:
$ time ./linpack.py 5000 Running Linpack 5000 x 5000 [...] Time is 3.4322800636291504 MFLOPS: 24293.860578838445 real 0m4.361s user 0m13.879s sys 0m0.783s
That the time command reports the "user" time as being
greater than the "real" (i.e. wallclock) time is a good indication
that multiple cores were being used. The user time is the total
amount of core time accumulated.
$ time OMP_NUM_THREADS=1 ./linpack.py 5000 [...] Time is 5.923848867416382 MFLOPS: 14075.871143839631 real 0m6.799s user 0m6.567s sys 0m0.232s
Prefixing the command with OMP_NUM_THREADS=1 makes it
use just a single core. Notice it is not four times slower. It is
only about twice as slow. Writing code which scale perfectly, that
is, runs n times faster on n cores, is hard.
The version of Python with the Debian 12 version of Raspberry Pi OS is firmly configured to use OpenBLAS only. The old version I tried on the Pi 4 in 2020 was more flexible. Its 812 MFLOPS score on the 2000x2000 problem size and single-core Netlib code improved to around 9,900 MFLOPS using the OpenBLAS code and all four cores with a 5000x5000 matrix, suggesting that the Pi 5 is about 2.5 times faster on this test.
But now we have the Debian Trixie based Raspberry Pi OS 6.x. Its python will run with the Netlib or OpenBLAS versions of Linpack, and its OpenBLAS version regards the 5000x5000 problem as being too small to bother using multiple cores for. So, if one wishes to see a fast result:
$ sudo apt-get install libopenblas0 $ ./linpack.py 10000
It will take around 25 seconds, but one might see results as high as 30 GFLOPS.
Did we do well?
The first Top500 list in June 1993 had, as its top entry, a 1024-core machine which managed 59.7 GFLOPS. The rules of the Top500 list allow one to increase the problem size to increase one's score. At a size of 10,000x10,000 the Pi 5 scores 28.4 GFLOPS, which would put it in fifth place.
In general, the bigger the problem size the higher the parallelisation efficiency and thus the higher the MFLOPS score, although the total number of floating point operations will increase as the cube of the linear dimension of the problem size. The limit will be the amount of memory one has. A 10,000x10,000 calculation requires storing 100,000,000 double-precision numbers, each of eight bytes, so around 0.8GB. A 20,000x20,000 run will need at least 3.2GB. Unfortunately two arrays of this size are used, so only Pis with 8GB can run the 20k size. Those with 4GB may be stuck at about 14k.
But even a 14k size in python is sufficient for 31.1 GFLOPS, moving up to second place in the June 1993 Top 500 list. The 20k size gives 32.8 GFLOPS, and moving to Fortran a small improvement resulting in 36.2 GFLOPS.
So in terms of supercomputers, the Pi 5 would be in the world's top ten until November 1994 inclusive. The Pi 4 would be in the top twenty-five in June 1993. The Pi 5; would still be on the November 1999 Top500 list.
When compared to desktop computers, the first Intel CPU to be able to score around 10 GFLOPS on Linpack was the dual-core Pentium D, launched in 2005. Scores around the low to mid thirties in GFLOPS would be achieved by Intel's first quad core CPUs, starting with the Core2 QX6700 in November 2006, which had a release price of $999. In July 2007 the similar performance could be achieved from a Q6700 at $530, and by November 2008 the price for a quad core Intel CPU had dropped to $224 for the Q8300. These CPUs were all rated at 95W or more for the CPU alone, whereas a Pi 5 is under a quarter of that for the whole computer if it has no external peripherals.
Unsurprisingly more modern desktop and laptop computers are much faster. A current (2024) six-core Intel or AMD CPU would be expected to score around 300 GFLOPS. The original M1 Apple CPU in the 2020 Mac Mini manages just over 200 GFLOPS.
Theoretical Limit
Most of the operations in Linpack can be expressed as fused multiply-adds (FMAs), i.e. in the form a=a+b*c. There are two FMA units in the in the A72 core in the Pi 4, and each can start one FMA operation every clock cycle. As each FMA contains two operations, that is four operations per clock cycle. At the 1.5GHz clock rate of the Pi 4, 6 GFLOPS per core, or 24 GFLOPS for all four cores. The observed maximum of around 10 GFLOPS is thus around 40% of peak theoretical performance.
The FMA units in the A76 core in the Pi 5 can operate on vectors consisting of two double-precision scalars, giving them twice the performance. Coupled with the higher clock speed of 2.4GHz, this gives a peak of 19.2 GFLOPS per core, or 76.8 GFLOPS for all four cores. The observed maximum of around 33 GFLOPS is again around 40% of peak theoretical performance. The serial performance of 14 GFLOPS is over 70% of the theoretical peak, and increasing the serial problem size to 10,000 results in 14.7 GFLOPS, 75% of the theoretical peak.
The parallel scaling is poor.
$ OMP_NUM_THREADS=1 ./linpack.py 10000 MFLOPS: 14731 $ OMP_NUM_THREADS=2 ./linpack.py 10000 MFLOPS: 25987 $ OMP_NUM_THREADS=3 ./linpack.py 10000 MFLOPS: 28550 $ OMP_NUM_THREADS=4 ./linpack.py 10000 MFLOPS: 27907
So the speedups on two, three and four cores are 1.7x, 1.9x and 1.9x. Poor, but better than the scaling of the Stream benchmark.