3 ms·
The more CPU-bound your program, the more benefit you'll see from the optimization flags. If your program is constantly waiting around for input on a network ch
by optimalsolver 5y ago
The more CPU-bound your program, the more benefit you'll see from the optimization flags. If your program is constantly waiting around for input on a network channel, then it may not help as much.
My currently used optimization flags are: -O3 -fno-math-errno -fno-signed-zeros -march=native -flto
Only use -march=native if the program is only intended to run on your own machine. It carries out architecture-specific optimizations that make the program non-portable.
Also look into profile-guided optimization, where you compile and run your program, automatically generate a statistical report, then recompile using that generated information. It can result in some dramatic speedups.
https://ddmler.github.io/compiler/2018/06/29/profile-guided-optimization.html https://ddmler.github.io/compiler/2018/06/29/profile-guided-...
- iamcreasy 5y agoThank you. I want to make sure I understood it clearly... I mostly use Java, and my impression is JIT inside JVM introduces hardware specific optimization without any user intervention. But for C/C++ if dependency is included as source - I can use compiler flag to enable platform specific optimizations. But if the dependency was included in the form of a pre-compiled binary, such as a .dll or .so, I am probably not using the the most optimally compiled version of the dependency. Am I right so far?