optimization FAQ

Isn't hand-optimized code more efficient?

There is no technical reason why compiled code on the eTPU cannot be as tight as hand-optimized code. The ISO C standard for embedded systems overcomes previous C language limitations related to embedded.

There are three things that the eTPU_C compiler can do very well that hand optimization finds difficult.

  1. Computers are very good at accounting.
  2. Programmers tricks, once added to the knowledge base in the eTPU_C compiler, remains available for everyone's applications forever. The compiler is capable of combining these tricks into combinations that we have not anticipated.
  3. Most of the detail of the instruction set and eTPU architecture is embedded in the compiler. Application developers can rely on this and focus on application details.

In the eTPU_C compiler, we have placed in the code generator rules that allow for sub-command re-ordering. What we found was there are only a few cases where this can happen without un-wanted side effects. We can implement complex rules only as we gather more experience identifying what should be allowed. The problem is the same as for hand coding, except we only need to get the details right once.

Optimizers have three parameters to work with: code size, ram requirements and execution cycles.

  • Optimization occurs when one or more of the three is reduced but not at the expense of the remaining parameters.
  • Compression occurs when there is an exchange between parameters where one or more are reduced at the expense of the remaining parameters.

Another way to look at this: optimizers will not make a bubble sort into a quick sort, but they will make the best bubble sort possible.

top