top | item 46836773

(no title)

fph | 1 month ago

If you try profiling almost any program that does linear algebra (something that uses Numpy, for instance), you will see a lot of calls and CPU time in functions with names like DGETRF or SGESVX. These obscure names stand for stuff like Single-precision GEneral matrix Solve Vector eXtended; i.e., solve a linear system of equations with a full, dense matrix. Why are they so difficult to parse? Couldn't they come up with a friendlier name?

They come from Lapack, the standard linear algebra foundation library, which is written in Fortran 77. That library was first written in 1992, when the Fortran 90 standard was still new and not supported everywhere, so they stuck with the earlier version. Lapack has become the standard library for dense non-parallel linear algebra; it is still maintained and updated, but the basic math algorithms haven't changed much, so there was no need to replace it entirely. Today there are also processor-specific libraries like MKL or Apple Accelerate, but they still all follow the same Lapack API.

When Fortran-77 was standardized, they decided to keep function names at most 6 letter long, to "ensure portability". I.e., they wanted to support certain compilers and architectures that were already considered old in 1977.

TL;DR: if you can't read easily those flame graphs today, it's because of backward compatibility with certain mainframes that probably date back to the late 1960s.

discuss

order

aebtebeten|29 days ago

In particular, 6-letter long function names may have been convenient on mainframes that used 6-bit alphanumerics in 36-bit words, the 36-bits having been backward compatible with 10-decimal-digit electromechanical calculators.

https://en.wikipedia.org/wiki/36-bit_computing#History

EDIT: I had thought 10 digits of precision were required for certain calculations, but the WP article points out that they may have just corresponded to the operators having had 10 digits on 2 hands, in which case we're being backwards compatible with Hox genes, specifically Hoxd, and tetrapod pentadactyly is backwards compatible to hundreds of millions of years:

https://www.popsci.com/science/why-five-fingers-toes/

nyrikki|29 days ago

Had more to do with punch cards and flexowriter tapes and octal, which predates large word sizes or even mainframes. Note the following from the MIDAS macro assembler [0]

Fortran predates this and was a different lineage than IBM, but not how six char symbols were a request

> The MACRO language had been used on the TX-0 for some three years previous to the writing of MIDAS. Hence, MIDAS incorporates most, of the features which have been requested by users of MACRO, such as more flexible macro Instructions, six character symbols and relocation.

Note that when porting b to the pdp-11, which was ascii vs the earlier FIODEC/flexowriter 6 bit paper tapes is why c case statements fall through, they used it to allow lower case commands in ed as an example.

Flexowriters are 1940s iirc, and TX-0 through the early pdps were octal so it makes sense to grow in multiples of the 3.3 bit lines of paper tape

[0] http://bitsavers.org/pdf/mit/rle_pdp1/memos/PDP-1_MIDAS.pdf

jsrcout|29 days ago

At my first job circa 1990, our codebase was constrained to 6-character function names in the core libraries, which had to run on many platforms including mainframes. If I recall correctly, you could have longer names, but only the first 6 characters were significant to the linker.

Never thought about why that might be other than "yeah, memory is expensive".

AnimalMuppet|29 days ago

Wasn't there a very similar library earlier than 1992? I seem to recall Linpack back in the early 1980s that sounded very similar.

fph|29 days ago

That is correct, I did not mention Linpack. It had different function names than Lapack though (while the naming scheme was similar, and still constrained to 6 letters); for instance DGETRF was named DGEFA in Linpack. [1]

[1]: https://netlib.org/linpack/dgefa.f

buescher|29 days ago

Yes. Lapack was the successor to linpack and I seem to recall some of the linpack routines going back much further than the eighties. MATLAB (which existed before the commercial release in 1984) was built on linpack.

KineticLensman|1 month ago

Cue obligatory reference to the programmer archaeologists in Vernor Vinge's novel A Deepness in the Sky. Their job, on starships, is to safely bodge the multiple strata of software that have accreted since Mankind left Earth, centuries before.

jsrcout|29 days ago

I'm pretty sure we've achieved that already, centuries ahead of schedule :-)