Having recently read that the main reason why fortran is faster than c/c++ in numerical computations is because there is no pointer aliasing.
Apparently, using restrict
or __restrict__
keywords allows on a case by case basis to indicate the absence of pointer aliasing for a given memory element.
The icc compiler apparently has an option -fno-alias
which allows one to globally assume that no aliasing is present. On gcc there is -fno-strict-aliasing
, which applies only to a subset of all the aliasing situations.
Is there an option present in gcc, or are there some cases where no aliasing is assumed, when using certain optimization flags?
-fno-strict-aliasing
, you have it backwards. The option cause the compiler to worry that some aliases may exist. By default, it assumes that these aliases do not exist. – Walachiarestrict
keyword matters are pretty rare actually, and it is usually pretty obvious where it matters. This document is quite informative, and emphasizes the fact that the order of loads and stores matter too. But as I said before, the cases where you will use such optimization are quite obvious to spot. – ViviennevivifyGCC
has anything similar to Intel's option-fno-alias
(Which basically is equivalent of annotating each pointer by therestrict
annotation). I actually wish it did. – Sexdecillion