4 ms·
> Interestingly, C/C++ beats Fortran on all but two of the benchmarks, although they are fairly close on most. I think this is fairly recent that C/C++ wins. I
by dahart 9y ago
> Interestingly, C/C++ beats Fortran on all but two of the benchmarks, although they are fairly close on most.
I think this is fairly recent that C/C++ wins. I don’t know how recent exactly, but I remember a colloquium not too long ago by a compiler researcher who said that cross-compiling to Fortran and then optimizing almost always produced faster code than the C/C++ compiler could. Fortran is apparently easier to optimize.
- quadruplebond 9y agoFor science codes, where Fortran is still used, the most expensive pieces (think DGEMM Kernel) are largely written in architecture dependent ASM anyways so programming language doesn't have that much of an effect on the most time critical pieces of large HPC programs. If a specific function is important enough it will be hand optimized in a way that the language doesn't really matter. Sometimes that means calling MKL, or using Cuda, or writing your own assembly.
- pletnes 9y agoDGEMM doesn’t necessarily win over MATMUL for small matrices. Useful in e.g rotation matrices in finite element codes, and lots of other areas. Since matmul can be done with inlined loops, you also avoid the function call overhead, but it looks like a function call which is good for readability.
- quadruplebond 9y agoYeah small and skinny matrix multiplies are an active area of research.
- deleted 9y ago[deleted]
- nejenendn 9y agoFortran is easier to optimize compared to c/++ if you don’t use restrict for the c end. If you do use restrict (iirc) the compilers are competitive.
- vram22 9y agoIt say something like that here: https://en.wikipedia.org/wiki/Restrict https://en.wikipedia.org/wiki/Restrict
- pjmlp 9y agoKind of, compilers don't enforce correct use of restrict which opens the doors to strange errors, as it is UB if they actually do overlap. Which is the main reason why ANSI C++ members are not keen in having restrict in C++.
- nejenendn 9y agoAgreed. However, C++ pragmatically does have restrict in both clang and g++, which is still useful in cases where you can deductively prove the lack of aliasing.
- pjmlp 9y agoThere are more compilers out there, although I do agree in the context of HPC, those are probably the most used ones.
- noobermin 9y agoWhat I don't get is why someone doesn't make a superb template library with C++ that hides the restricts; it would make writing performant codes in C++ easier and you'd get the host of what C++ has to offer
- quadruplebond 9y agoEigen isn’t good enough? You can offload some stuff to MKL with it also.
- deleted 9y ago[deleted]