3 ms·
Few remarks: -mtune is redundant with march=native turned on; -use -Ofast instead O3/ffast-math it turns some more options as well (although theoretically it
by bluecalm 13y ago
Few remarks:
-mtune is redundant with march=native turned on;
-use -Ofast instead O3/ffast-math it turns some more options as well (although theoretically it might behave in non-standard way with float computations, you need to test this, it wasn't ever a problem for me)
-add -flto it often helps significantly
-it probably won't matter for simple program but you may try compiling with:
-Ofast -march=native -flto -fprofile-generate;
then run the program (it will generate .gcda files) and then recompile with the same options and -fprofile-use;
EDIT:
Some quick tests shows that all the options I mentioned help (MinGW, gcc 4.8.1). Original time on one thread was 3.670s, Ofast and -flto takes it to ~3.630s and adding PGO moves it to 3.46s (there is some variance with all of those) - whooping 5-6% improvement overall :)
- bluecalm 13y agoI can't edit anymore, so replying to myself: On my machine (i7 3770) inserting famous Quake3 hack in place of 1/sqrtf: http://en.wikipedia.org/wiki/Fast_inverse_square_root http://en.wikipedia.org/wiki/Fast_inverse_square_root is faster but not accurate with one iteration (image is very distorted) and slower but accurate with 2 iterations.
- twoodfin 13y agoHow would -flto help when all the code is in one module?
- bluecalm 13y agoAll I know about gcc flags is from testing a lot of combinations of them. I don't really know how -flto works but maybe it does something for functions from included files ?