Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/23/07 17:21
Read: times


 
Msg Score: +4
 +4 Informative
#146089 - Optimization
Responding to: ???'s previous message
I have posted some examples for SiLabs USB chips on SiLabs forum. These examples support Keil and SDCC. On this experience, I'm satisfied with the quality of both of these compilers.

But if pressed, Keil has richer optimization options than SDCC, and it appears in the object's code size and RAM usage. The code size of SDCC is greater around 10% than Keil, the RAM usage is almost comparable in these examples. Of course, this figure is altered depending on the structure of the source code. When the firmware has many deep nesting of subroutine calls, it may impact the RAM usage in SDCC; Keil applies call-tree optimization for RAM sharing, but SDCC takes just the leaf-node optimization.

This difference may be significant in the development on the MCU with small code FLASH and RAM size. However, I stress that manual optimization of the source code is the first thing you have to do, before relying to the compiler optimization easily.

For example, SiLabs' original example takes code/data = 2990/181 bytes, and it is reduced to 2305/163.1 in the manually-optimized version. More than 20% of code FLASH and 10% of RAM are saved, just by simplifying the logic flow, refining the usage of variables in the source code. The optimized version is even reinforced for better compliance to the USB spec.

Tsuneo


In these examples, most of source code is common (more than 97%), and the difference like endian is implemented with conditional compilation in pre-prosessor macro.
The compiler options are the default one, either in Keil or SDCC.
Keil - OPTIMIZE (8, SPEED)
SDCC - ?
(--opt-code-size or --opt-code-speed, but I don't see any change between these options, including no option)

"Optimization of SiLabs USB examples in code size"
http://www.cygnal.org/ubb/Forum9/HTML/000938.html
Firmware (C8051F320)
                  code   data   xdata (bytes)
SiLabs
Original  (Keil)  2990   181.0      0
-----------------------------------------------------------------------
Optimized (Keil)  2305   163.1      0  inline POLL_READ and POLL_WRITE
Optimized (SDCC)  2502   163        0
-----------------------------------------------------------------------
Optimized (Keil)  2197   166.1      0  function POLL_READ and POLL_WRITE
Optimized (SDCC)  2494   167        0
"USB CDC (Communication Device Class) implementation for 'F32x and 'F34x" http://www.cygnal.org/ubb/Forum9/HTML/000945.html
Firmware (C8051F320)
      code   data   xdata (bytes)
Keil  3754   73.5     512
SDCC  4012   68       512
"How to convert USB_Interrupt (USB_INT) to HID" http://www.cygnal.org/ubb/Forum9/HTML/001193.html
optimized Firmware (C8051F320)
      code   data   xdata (bytes)
Keil  2531   163.1      0
SDCC  2737   163        0
"USB composite device" http://www.cygnal.org/ubb/Forum9/HTML/001050.html
USB_HID_composite_01.zip Firmware (C8051F320)
      code   data   xdata (bytes)
Keil  3097   31.7     192
SDCC  3413   30       192


List of 13 messages in thread
TopicAuthorDate
Keil vs SDCC            01/01/70 00:00      
   Loaded question            01/01/70 00:00      
   Compiler wars!            01/01/70 00:00      
      support            01/01/70 00:00      
         Support            01/01/70 00:00      
            re: Andy: support            01/01/70 00:00      
      Optimization            01/01/70 00:00      
         good data, however ....            01/01/70 00:00      
            Surely, but in the real application,            01/01/70 00:00      
               that's the crux            01/01/70 00:00      
                  Then, the required comparison is,            01/01/70 00:00      
   My ha'pence worth            01/01/70 00:00      
      Keil thrown in            01/01/70 00:00      

Back to Subject List