Superoptimization

Compilers translate software into code executed by actual processors, but that translation is not always as efficient as desired, even when using traditional optimization techniques are used.  Superoptimization attempts to find the the theoretically best translation of a block of code (in terms of code size, execution speed and energy efficiency).  The first attempts were made over 30 years ago using using exhaustive searching and were thus computationally extremely demanding.  In the intervening time, significant advances have been made, both by heuristic improvements to the search algorithm and by the increase in compute power available.  However it remains a technique of purely academic interest.

In the summer of 2014, Innovate UK funded Embecosm to carry out a feasibility study of commercial applications for superoptimization.  The full report is available as Embecosm Application Note 15.  It came up with three core recommendations.

  1. Superoptimization using heuristic exhaustive searching is a viable optimization technique for small code blocks which form the core of performance-critical software applications;
  2. Within the compiler, superoptimization provides an effective technology for creating target specific peephole optimization passes; and
  3. In the medium term, constraint based techniques for superoptimization have the potential to allow superoptimization of larger blocks of code.

In all three cases, the report noted that further work was needed to create practical tools.  For a long time,  the state-of-the-art was the GNU Superoptimizer (GSO), now a quarter of a century old.  More recently a Stanford University have created STOKE, a stochastic superoptimizer, now available as an open source tool.

In the intervening time since GSO was written, computers have become more powerful, they have become multi-core, formal methods have advanced, and a large number of heuristics have been developed.  What is now needed is not a single tool, but a framework for deploying a range of superoptimization techniques in a way that can take advantage of parallel computing. Only with this in place commercial superoptimization becomes practical.

Under the Innovate UK funded TSERO project, Embecosm created an initial implementation of such a framework, the GNU Superoptimizer 2.0 or GSO 2.0.  Initial testing of the framework used the Atmel AVR architecture, and outperformed the best GCC results in 6 out of 10 cases , offering improvements of between 47% and 64%.  Development of GSO 2.0, particularly to support constraint based superoptimization is a research priority for Embecosm.

Embecosm is currently able to use existing superoptimization technology to create peephole optimizers and to superoptimize specific applications.  We also welcome partners to help develop the technology of GSO 2.0 for the future.

Pages in this section

SECURE

The Security Enhancing Compilation for Use in Real Environments (SECURE) project is an InnovateUK supported research program by Embecosm which started in July 2017. Its goal is to take the latest academic ideas for improving security of code, and provide practical reference implications in the main open source compilers, GCC and LLVM. The project has […]

GSO 2.0

The original GNU Superoptimizer (GSO) was pioneering, but has some limitations: it only handles arithmetic instructions, delivers a single result, generates impossible sequences, only supports a carry flag and has a very simple cost model.  Its big advantage is that it is fast. Since GSO was created in 1991, there have been many advances in […]

AAP

An Altruistic Processor (AAP) was created to advance compiler technology for deeply embedded processors with a restricted register set and complex memory structures.  The first version is documented in Embecosm Application Note 13.  It is a 16-bit Harvard architecture with multiple 16-bit word addressed code memories, multiple byte addressed data memories and between 4 and […]

TSERO

2Total Software Energy Reduction and Optimization (TSERO) was an InnovateUK supported follow-on project between Embecosm, Allinea (now part of ARM), Concertim and STFC Daresbury Hartree Center, running from June 2015 to September 2017.  The project aimed to apply the techniques developed in the MAGEEC and Superoptimization projects to compiling energy efficient code for high performance computing […]

Superoptimization

Compilers translate software into code executed by actual processors, but that translation is not always as efficient as desired, even when using traditional optimization techniques are used.  Superoptimization attempts to find the the theoretically best translation of a block of code (in terms of code size, execution speed and energy efficiency).  The first attempts were […]

MAGEEC

The Machine Guided Energy Efficient Compiler (MAGEEEC) project was an InnovateUK supported research program led by Embecosm in partnership with the University of Bristol from May 2013 to November 2014.  Its goal was to make machine learning feasible in commercial compilers, specifically for generating energy efficient code on deeply embedded systems.  The target was to […]