My first attempt to optimize the project will be to work with the compiler flag options.
By default the compiler is set to compile in this manner "gcc -E -g -o2"
The -E option represents preprocesses only; does not compile, assemble or link.
So I will opt to remove that flag
The -g option enables use of extra debugging information that only GDB can use
Because we are no longer debugging I will remove this as well
The -o2 option is set on by default and it turns on the following flags to increase speed without sacrificing space.
-fdefer-pop
-fmerge-constants
-fthread-jumps
-floop-optimize
-fif-conversion
-fif-conversion2
-fdelayed-branch
-fguess-branch-probability
-fcprop-registers
-fforce-mem
-foptimize-sibling-calls
-fstrength-reduce
-fcse-follow-jumps -fcse-skip-blocks
-frerun-cse-after-loop -frerun-loop-opt
-fgcse -fgcse-lm -fgcse-sm -fgcse-las
-fdelete-null-pointer-checks
-fexpensive-optimizations
-fregmove
-fschedule-insns -fschedule-insns2
-fsched-interblock -fsched-spec
-fcaller-saves
-fpeephole2
-freorder-blocks -freorder-functions
-fstrict-aliasing
-funit-at-a-time
-falign-functions -falign-jumps
-falign-loops -falign-labels
-fcrossjumping
To try and optimize the performance the first thing I will do is change the -o2 to -o3 which will SACRIFICE space for faster execution time. The additional flags will be turned on as well in addition to all the flags listed in -o2
-finline
-functions
-fweb
-frename-registers
RESULTS:
After changing the compilation flags from "gcc -E -g -o2" to "gcc -o3" we have had NO speed up with the program.
charlie medium original -> real 7m10.935s
charlie medium new -> real 7m7.722s
Archie big original -> real 11m40.245s
aarchie big new -> real 11m42.165s
Comments