3 ms·
> The classic example of surprising optimization is perhaps matrix multiplication in Fortran: > At some point in history, when you wrote the straightforward,
by mmarx 6y ago
> The classic example of surprising optimization is perhaps matrix multiplication in Fortran:
> At some point in history, when you wrote the straightforward, primitive three-nested-loops version of matrix multiplication your code ran much faster than when you tried to implement one of the more sophisticated algorithms.
It might also have been due to Fortran using column-major matrix layout; if you try to implement a sophisticated multiplication algorithm that is optimised for row-major matrices, then that will be slower (indeed, also the row-major three-nested-loops version is already quite a bit slower). Another thing is that the sophisticated algorithms usually have some constant overhead that makes them shine only on sufficiently large matrices.