Re:The GIL and its effects on Python multithreading
by grumpyprole on Wednesday September 29, 2021 @06:16AM
(#28691961)
And Fortran code (many parts of numpy). C doesn't have a complete monopoly on high-performance code.
[ Parent
| on HN ]
Re:The GIL and its effects on Python multithreading
by Qi_ on Wednesday September 29, 2021 @10:17AM
(#28693981)
What is the advantage of Fortran over only C in numpy’s case specifically?
Re:The GIL and its effects on Python multithreading
by staticassertion on Wednesday September 29, 2021 @10:44AM
(#28694319)
Fortran has the more optimized libraries (blas) and is also capable of optimizations that C isn't (guarantees that pointers dont alias).
Re:The GIL and its effects on Python multithreading
by qsort on Wednesday September 29, 2021 @10:58AM
(#28694544)
Modern C has the restrict keyword for that. There isn't any competitive advantage left for Fortran over C or C++, the only reason why Fortran is still part of the modern numeric stack is that BLAS, LAPACK, QUADPACK and friends run the freaking world and nobody is ever going to rewrite them to C without a compelling reason to do so.
Re:The GIL and its effects on Python multithreading
by mumblemumble on Wednesday September 29, 2021 @12:20PM
(#28695844)
Fortran's primary competitive advantage over C and C++ is that it's a conceptually simpler language that's easier for humans to use safely and effectively for numerical computing tasks.
It's not just being tied to BLAS and friends. Fortran lives on in academia, for example, because academics don't necessarily want to put a lot of effort into chasing wild pointers or grokking the standard template library.
For my part, I'm watching LFortran with interest because, when I run up against limitations on what I can do with numpy, I'd much rather turn to Fortran than C, C++, or Rust if at all possible, because Fortran would let me get the job done in less time, and the code would likely be quite a bit more readable.
Re:The GIL and its effects on Python multithreading
by staticassertion on Wednesday September 29, 2021 @12:06PM
(#28695635)
I'm aware of the restrict keyword, though its usage is not typical. It enables an optimization that fortran has by default, that was my point.
And yes, I already said that packages like blas have had massive amounts of work put into them and have lasting power.
Re:The GIL and its effects on Python multithreading
by qsort on Wednesday September 29, 2021 @12:19PM
(#28695831)
I didn't downvote you, if that's what you were hinting at, however your phrasing was more likely to be interpreted as "C can't do that" as opposed to "C doesn't default to that".
It seems we agree, after all.
Re:The GIL and its effects on Python multithreading
by staticassertion on Wednesday September 29, 2021 @10:04PM
(#28702410)
I believe we do.
Re:The GIL and its effects on Python multithreading
by adgjlsfhk1 on Wednesday September 29, 2021 @03:09PM
(#28698406)
Note that while BLAS and friends aren't getting rewritten in C, there is an effort underway to write replacements in Julia. The basic reason is that metaprogramming and better optimization frameworks are making it possible to write these at a higher level where you basically specify a cost model, and generate an optimal method based on that. The big advantage is that this works for more than just standard matrix multiplies. The same framework can give you complex matrices, Integer and boolean matrices, matrices with different algebras (eg max-plus).
Re:The GIL and its effects on Python multithreading
by qsort on Wednesday September 29, 2021 @03:18PM
(#28698535)
That's a cool idea. I don't know how realistic it is to achieve performance parity, but the "generic" functionality is definitely intriguing.
Re:The GIL and its effects on Python multithreading
by adgjlsfhk1 on Wednesday September 29, 2021 @05:22PM
(#28700134)
The initial results are that libraries like LoopVectorization can already generate optimal micro-kernels, and is competitive with MKL (for square matrix-matrix multiplication) up to around size 512. With help on macro-kernel side from Octavian, Julia is able to outperform MKL for sizes up to to 1000 or so (and is about 20% slower for bigger sizes). https://github.com/JuliaLinearAlgebra/Octavian.jl.
Re:The GIL and its effects on Python multithreading
by pjmlp on Wednesday September 29, 2021 @04:29PM
(#28699488)
Except "modern" C does not prevent one to misuse restrict and doing so is UB.
Re:The GIL and its effects on Python multithreading
by brodouevencode on Wednesday September 29, 2021 @02:11PM
(#28697644)
Also, when Travis Oliphant was writing numpy he liked the Fortran implementations of a lot of mathematical functions, so it was an "easy" borrow from there instead of reimplementing.