2 ms·
The post was published in 2006. The claim that Fortran arrays are easier for the compiler to optimise than raw pointers in C/C++ may well be true. But I imagin
by RossBencina 10y ago
The post was published in 2006.
The claim that Fortran arrays are easier for the compiler to optimise than raw pointers in C/C++ may well be true. But I imagine that there has been progress on compiler technologies to address auto-vectorisation in C/C++ since the post was written (and since C99, C has the restrict keyword too). Can anyone comment?
- n00b101 10y agoFORTRAN disallows pointer aliasing, which allows the compiler to perform certain instruction re-ordering optimizations. As far as I know this helps more with instruction level parallelism, as opposed to auto-vectorization. C99 introduced the restrict keyword in order to solve the pointer aliasing / instruction reordering issue. Auto-vectorization is a bit different, it uses mathematics of integer polyhedra to perform loop transformations allowing the compiler to replace scalar operations with SIMD vector operations. The Intel C compiler and IBM XL C compiler have been quite good at this for a long time (at least on simple loops that don't really require transformations). More recently GCC implemented the "Graphite" optimizer to handle this type of auto-vectorization, and LLVM has the the "Polly" optimizer. FORTRAN automatically benefits from these optimization improvements because all these compilers have FORTRAN front-ends that translate these languages to an intermediate representation, where the optimizer don't "know" what the source language was. I think the pointer aliasing issue still haunts C because the "restrict" keyword may not be commonly used. So FORTRAN seems even today to have a reputation of being "faster" than C for numerical codes.