5 ms·
Numpy is Fortran btw.
by adastra22 4y ago
Numpy is Fortran btw.
- remram 4y agoFrom numpy.org: > The core of NumPy is well-optimized C code.
- taeric 4y agoAmusingly, "well-optimized C code" includes calling out to fortran libraries. :D https://numpy.org/doc/1.13/user/building.html https://numpy.org/doc/1.13/user/building.html
- cfcf14 4y agoIt's turtles all the way down, except for the final turtle, which is Fortran...
- bee_rider 4y agoThe last turtle is probably assembly, or at least intrinsics, in most good BLAS implementations. Probably called from C, because that’s easier in C. The nice thing about Fortran is that you get something almost as good, but a normal engineer can write it. There are more C programmers than Fortran programmers, but there are more Fortran programmers than there are C programmers who can write really good assembly kernels. And all the C programmers in that last group are already working on vendor BLAS implementations.
- whimsicalism 4y agoThat's a 6 year old documentation page, modern numpy does not use fortran in any way except that maybe you have a particular BLAS reference implementation.
- adastra22 4y agoNumpy is basically a wrapper to BLAS and LAPACK though, so it seems a bit odd to ignore the fact that those system libraries are usually written in Fortran.
- whimsicalism 4y agoThe reference implementation is written in Fortran, but I'm not sure about the implementations actually used. OpenBLAS has fortran components, but I believe cuBLAS and MKL are vast majority C/C++.
- taeric 4y agoThis is a very fair challenge. My understanding was that the main ones in use were fortran and it is very interesting to see that may not be the case. Love to see any benchmark or other comparisons on the options, if you know of any good links.
- adastra22 4y agocuBLAS is not Fortran because it targets NVIDIA GPUs. Despite what the grandparent says, MKL does include some Fortran in its codebase. Most other vendor-provided BLAS and LAPACK libraries are based on the reference Fortran implementation. Even OpenBLAS, the open-source reimplementation, has large parts written in Fortran.
- taeric 4y agoI did link to the old one.... but if you follow the link to the new, it still has that section? I'm confused.
- whimsicalism 4y agoThe old one says you need a fortran compiler to build numpy, the other one explicitly says you don't need a fortran compiler to build numpy.
- taeric 4y agoThe new one says it auto selects. I don't think they got rid of using the fortran if it is there. They just automated a lot of that in the build.
- milancurcic 4y agoThe well-optimized part is C calling Fortran. :)
- whimsicalism 4y agono?
- taeric 4y agoIf you are using any of the faster libraries for it, it is? Right?
- whimsicalism 4y agoI don't believe that numpy requires any fortran [0] and most BLAS implementations are not written in Fortran either. [0]: https://github.com/search?q=repo%3Anumpy%2Fnumpy+path%3A**%2F*.f&type=code&ref=advsearch https://github.com/search?q=repo%3Anumpy%2Fnumpy+path%3A**%2...
- adastra22 4y agoMost BLAS and LAPACK implementations are written in Fortran. There are some C/C++ alternatives, but those are the exceptions (even if some are widely used in the FOSS community) and they still don’t benchmark as well even in 2023.
- whimsicalism 4y agocuBLAS benchmarks pretty well :) but sure, I am not super familiar with the state of CPU BLAS frameworks so I will take your word for it.
- bee_rider 4y agoThe good BLAS libraries are MKL and BLIS nowadays, I’m pretty sure. BLIS is C and assembly if I remember correctly. MKL is a big library, Wikipedia lists the languages used as C, C++, Fortran, and I think it is also pretty well known that they’ve sprinkled some magic assembly in there.
- 4y ago
- deleted 4y ago[deleted]
- bee_rider 4y agoNumpy is most importantly BLAS and LAPACK, which can be implemented in any language. The best CPU version is probably still MKL, which is a mix of Fortran, C, and assembly. C is used for these kinds of projects because it is easy to sprinkle assembly into C. Fortran solves a particular problem: produce a pretty good binary from readable code that a normal PHD student or engineer can write. This is not really the problem that a tuned BLAS/LAPACK library has to face, vendors throw very experienced folks at these libraries to chase after those last 5% performance boosts that Fortran leaves on the table.