All compilers come with standard optimization flags: -O2 or -O3 to generate fast code and -Os or -Oz to generate small code. However, these are general flags that provide standard combinations of all the possible optimizations offered by the compiler — over 200 in the case of GCC — which have generally proved to be good across a wide range of programs and architectures.
For any particular program and architecture these flags will not generate the very best code and up until now the only solution has been to exhaustively try setting the various individual flags. Such iterative compilation takes a huge amount of time and is impractical for all but the most valuable code.
The solution is to “learn” which compiler flags best suit each type of source code and store this information in a database. The compiler can then simply look up the characteristics of each program in order to determine the best optimization flags to use. Embecosm’s MAGEEC is the first commercially robust implementation of such a machine learning system and is available for both GCC and LLVM compilers. Furthermore, it doesn’t just select the best optimization flags for each source file — it selects the best flags for each function.
- Automatically select the best optimization flags for your code
- Separate flags selected for each function
- Optimize for code speed, size or energy-efficiency
- Available today for LLVM and GCC, and extensible to other compilers
All modern compilers have hundreds of optimization passes, and most of those passes have tuning parameters that can adjust their precise behavior. The general purpose optimization levels
-Os etc. are collections of those optimizations that have proved generally effective across a wide range of programs.
But these are general purpose flags. For any individual program, the use of these flags will not give the best possible optimization.More details
Thanks to Embecosm's experience, unique skills and novel techniques we were able to complete ambitious research that required searching an enormous computational space.
Dr Simon Hollis University of Bristol
Embecosm developed a first rate GNU toolchain for our architecture, the team is very strong technically, produce great documentation and have been a pleasure to work with.
Andreas Olofsson Adapteva Inc.