fév 5

Simple optimization…

Ore: 18:29 - Tags: Geek

It was my « Real-Time » class yesterday, it’s in this class that I’m learning about programming on microcontroler. Programming on this kind of stuff is different from « normal » programming because you have to think about the resources that will be used by your code.

The problem of many developers right now, is that they tend to think they would not be at better to optimize their code than the compiler do for them … Well, in some way it may be true but I would not be so blind minded about that. Let see some common things that you may expected your compiler to do:

Yesterday, it was mentioned in my class that gcc-avr ( the gcc version use for Atmel MCU programming) had a problem with loop unrolling. I decided to do some research on that with my friend « google » and found out that it may not really be a problem with gcc-avr itself, but with the optimization given to it by default in AVR Studio. For some version, AVR Studio is giving « -O0″ to the compiler which means that no optimization are done by the compiler. A best bet would be to use « -Os ». To learn more about those flags go see the gcc manual.

Bugs in compiler also exist from version to version so it may be wise to check if a bug have been reported for the version of gcc-avr that you are using if you suspected it to be wrong.

You may find interesting to look at the different optimization options offerred by your compiler. See the man page for more informations. By researching on the topic I also found a nice application note about specific to AVR efficient C code.

Comments: none

No Comments

Leave a comment