EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Code execution Speed (Rowley vs CC)

Started by Richard May 25, 2008
I have relatively simple code running in both Rowley and Code
Composer. The Code composer runs MUCH slower than the Rowley code.
For example, simple for(x=0;x<... delay loops run much slower in CC.

Both are configured to oprimize for speed
MSP430F423
32KHz xtal

Is there an initialization that Rowley handles that I am missing in
Code Composer?

Thanks

Rich

Beginning Microcontrollers with the MSP430

While we might guess, we don't know what your specific point is.

First the MSP430 user guides do not mention C code and are not
capable of running C code. C code is always compiled into machine
code.

Second dealy loops are a particularly poor way to evaluate any type
of code quality.

Third if you turn optimisation on then compiler writers, who are
overly concerned with benchmarks at the expense of allowing code
authors do what they have requested, will optimise away code, unless
you explitly use a volatile declaration.

Hope this helps

John Heenan

--- In m..., "Richard" wrote:
>
> I have relatively simple code running in both Rowley and Code
> Composer. The Code composer runs MUCH slower than the Rowley code.
> For example, simple for(x=0;x<... delay loops run much slower in CC.
>
> Both are configured to oprimize for speed
> MSP430F423
> 32KHz xtal
>
> Is there an initialization that Rowley handles that I am missing in
> Code Composer?
>
> Thanks
>
> Rich
>

John,
I understand C code can be compiled different ways. The
difference in speed is huge throughout the code, like a system clock
being configured differently.

Yes, the loop variables are all declred volatile and are not being
optimized away.

Rich

--- In m..., "John Heenan" wrote:
>
> While we might guess, we don't know what your specific point is.
>
> First the MSP430 user guides do not mention C code and are not
> capable of running C code. C code is always compiled into machine
> code.
>
> Second dealy loops are a particularly poor way to evaluate any type
> of code quality.
>
> Third if you turn optimisation on then compiler writers, who are
> overly concerned with benchmarks at the expense of allowing code
> authors do what they have requested, will optimise away code, unless
> you explitly use a volatile declaration.
>
> Hope this helps
>
> John Heenan
>
> --- In m..., "Richard" wrote:
> >
> > I have relatively simple code running in both Rowley and Code
> > Composer. The Code composer runs MUCH slower than the Rowley code.
> > For example, simple for(x=0;x<... delay loops run much slower in CC.
> >
> > Both are configured to oprimize for speed
> > MSP430F423
> > 32KHz xtal
> >
> > Is there an initialization that Rowley handles that I am missing in
> > Code Composer?
> >
> > Thanks
> >
> > Rich
>
Take a look at the assembler output. This will answer your question.

M.

"Richard" :

> John,
> I understand C code can be compiled different ways. The
> difference in speed is huge throughout the code, like a system
> clock being configured differently.
>
> Yes, the loop variables are all declred volatile and are not being
> optimized away.
>
> Rich
>
> --- In m..., "John Heenan" wrote:
>>
>> While we might guess, we don't know what your specific point is.
>>
>> First the MSP430 user guides do not mention C code and are not
>> capable of running C code. C code is always compiled into machine
>> code.
>>
>> Second dealy loops are a particularly poor way to evaluate any
>> type of code quality.
>>
>> Third if you turn optimisation on then compiler writers, who are
>> overly concerned with benchmarks at the expense of allowing code
>> authors do what they have requested, will optimise away code,
>> unless you explitly use a volatile declaration.
>>
>> Hope this helps
>>
>> John Heenan
>>
>> --- In m..., "Richard" wrote:
>> >
>> > I have relatively simple code running in both Rowley and Code
>> > Composer. The Code composer runs MUCH slower than the Rowley
>> > code. For example, simple for(x=0;x<... delay loops run much
>> > slower in CC.
>> >
>> > Both are configured to oprimize for speed
>> > MSP430F423
>> > 32KHz xtal
>> >
>> > Is there an initialization that Rowley handles that I am
>> > missing in Code Composer?
>> >
>> > Thanks
>> >
>> > Rich
>> >
>>
Hi Richard,

Which version of CrossWorks are you using ?
CW430 does not explicitly initialise anything beyond standard C such as the stack, zero the bss.
The startup code does turn off the watchdog, but that's about it.

My guess is that either you're not referencing some variable or even function (for example,
functions that are not called are not compiled/linked in), or else simply that CW430
does generate a hell of a lot better code...

HTH
Kris

-----Original Message-----
From: m... [mailto:m...] On Behalf Of Richard
Sent: Monday, 26 May 2008 4:03 PM
To: m...
Subject: [msp430] Re: Code execution Speed (Rowley vs CC)

John,
I understand C code can be compiled different ways. The
difference in speed is huge throughout the code, like a system clock
being configured differently.

Yes, the loop variables are all declred volatile and are not being
optimized away.

Rich

--- In m..., "John Heenan" wrote:
>
> While we might guess, we don't know what your specific point is.
>
> First the MSP430 user guides do not mention C code and are not
> capable of running C code. C code is always compiled into machine
> code.
>
> Second dealy loops are a particularly poor way to evaluate any type
> of code quality.
>
> Third if you turn optimisation on then compiler writers, who are
> overly concerned with benchmarks at the expense of allowing code
> authors do what they have requested, will optimise away code, unless
> you explitly use a volatile declaration.
>
> Hope this helps
>
> John Heenan
>
> --- In m..., "Richard" wrote:
> >
> > I have relatively simple code running in both Rowley and Code
> > Composer. The Code composer runs MUCH slower than the Rowley code.
> > For example, simple for(x=0;x<... delay loops run much slower in CC.
> >
> > Both are configured to oprimize for speed
> > MSP430F423
> > 32KHz xtal
> >
> > Is there an initialization that Rowley handles that I am missing in
> > Code Composer?
> >
> > Thanks
> >
> > Rich
>
John,

> Third if you turn optimisation on then compiler writers, who are
> overly concerned with benchmarks at the expense of allowing code
> authors do what they have requested, will optimise away code, unless
> you explitly use a volatile declaration.

Man, sometimes you talk utter twaddle. Would you want a compiler that
didn't use registers because you hadn't written "register" in your source?
Utter, utter nonsense.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors

Heh, seems that the old mantra still applies : Garbage In - Garbage Out :-)

-----Original Message-----
From: m... [mailto:m...] On Behalf Of Paul Curtis
Sent: Monday, 26 May 2008 5:53 PM
To: m...
Subject: RE: [msp430] Re: Code execution Speed (Rowley vs CC)

John,

> Third if you turn optimisation on then compiler writers, who are
> overly concerned with benchmarks at the expense of allowing code
> authors do what they have requested, will optimise away code, unless
> you explitly use a volatile declaration.

Man, sometimes you talk utter twaddle. Would you want a compiler that
didn't use registers because you hadn't written "register" in your source?
Utter, utter nonsense.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors

With the context reinserted, instead of removed to make spiteful
personal attack on me from some of the most boring, unimaginative,
spiteful and unemployable people on the planet, your compiler with
optimisation turned on is liable to turn, contrary to your
instructions
{
unsigned char x=0xFF;
while(xx--);
}
into absolutely nothing unless you use instead

{
volatile unsigned char x=0xFF;
while(xx--);
}

The isssue of not using volatile with a delay loop is very well known
for those who are experienced.

John Heenan
--- In m..., "microbit" wrote:
>
> Heh, seems that the old mantra still applies : Garbage In - Garbage
Out :-)
>
> -----Original Message-----
> From: m... [mailto:m...] On
Behalf Of Paul Curtis
> Sent: Monday, 26 May 2008 5:53 PM
> To: m...
> Subject: RE: [msp430] Re: Code execution Speed (Rowley vs CC)
>
> John,
>
> > Third if you turn optimisation on then compiler writers, who are
> > overly concerned with benchmarks at the expense of allowing code
> > authors do what they have requested, will optimise away code,
unless
> > you explitly use a volatile declaration.
>
> Man, sometimes you talk utter twaddle. Would you want a compiler
that
> didn't use registers because you hadn't written "register" in your
source?
> Utter, utter nonsense.
>
> --
> Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
> CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors
>

--- In m..., "John Heenan" wrote:

> With the context reinserted, instead of removed to make spiteful
> personal attack on me from some of the most boring, unimaginative,
> spiteful and unemployable people on the planet, your compiler with
> optimisation turned on is liable to turn, contrary to your
> instructions
> {
> unsigned char x=0xFF;
> while(xx--);
> }
> into absolutely nothing unless you use instead
>
> {
> volatile unsigned char x=0xFF;
> while(xx--);
> }

Your comments would be better directed to the ISO C working group
as "guidance". Better still, refrain from snide comments that berate
compilers which adhere to the standard as if they are beneath
contempt in the transformations they correctly make.

-- Paul.

Hi All,

Looking at the assembly for a simple software delay (pure cheese, I know):

Code Composer:
for(j = 0;j<1050;j++);
0x0000f588 <$C$L5+4>: mov #0,2(sp) ; r3 As=
0x0000f58c <$C$L5+8>: cmp #1050,2(sp) ; #0x041a
0x0000f592 <$C$L5+14>: jc $+14 ; abs 0xf5a0
0x0000f594 <$C$L6>: inc 2(sp)
0x0000f598 <$C$L6+4>: cmp #1050,2(sp) ; #0x041a
0x0000f59e <$C$L6+10>: jnc $-10 ; abs 0xf594

Rowley:
for(j = 0;j<1050;j++);
E0C6 0F43 MOV.W #0, R15
E0C8 1F53 ADD.W #1, R15
E0CA 3F901A04 CMP.W #0x41a, R15
E0CE FC2B JNC @6 ; = E0C8

So it looks like Rowley is generating smaller code, at least in this case.
(It has been my experience that Rowley does a GREAT job optimizing
code. Anyone who does not understand the volatile keyword and how
EMBEDDED code compilers work to reduce code size will have problems)
Rich

--- In m..., Matthias Weingart wrote:
>
> Take a look at the assembler output. This will answer your question.
>
> M.
>
> "Richard" :
>
> > John,
> > I understand C code can be compiled different ways. The
> > difference in speed is huge throughout the code, like a system
> > clock being configured differently.
> >
> > Yes, the loop variables are all declred volatile and are not being
> > optimized away.
> >
> > Rich
> >
> > --- In m..., "John Heenan" wrote:
> >>
> >> While we might guess, we don't know what your specific point is.
> >>
> >> First the MSP430 user guides do not mention C code and are not
> >> capable of running C code. C code is always compiled into machine
> >> code.
> >>
> >> Second dealy loops are a particularly poor way to evaluate any
> >> type of code quality.
> >>
> >> Third if you turn optimisation on then compiler writers, who are
> >> overly concerned with benchmarks at the expense of allowing code
> >> authors do what they have requested, will optimise away code,
> >> unless you explitly use a volatile declaration.
> >>
> >> Hope this helps
> >>
> >> John Heenan
> >>
> >> --- In m..., "Richard" wrote:
> >> >
> >> > I have relatively simple code running in both Rowley and Code
> >> > Composer. The Code composer runs MUCH slower than the Rowley
> >> > code. For example, simple for(x=0;x<... delay loops run much
> >> > slower in CC.
> >> >
> >> > Both are configured to oprimize for speed
> >> > MSP430F423
> >> > 32KHz xtal
> >> >
> >> > Is there an initialization that Rowley handles that I am
> >> > missing in Code Composer?
> >> >
> >> > Thanks
> >> >
> >> > Rich
> >> >
> >

The 2024 Embedded Online Conference