Sign in

username or email:

password:



Not a member?
Forgot your password?

Search compdsp



Search tips


Discussion Groups

Free Online Books

See Also

Embedded SystemsFPGA

Discussion Groups | Comp.DSP | C6000 assembler optimizer is optimizing too much

There are 12 messages in this thread.

You are currently looking at messages 1 to .


Is this discussion worth a thumbs up?

0

C6000 assembler optimizer is optimizing too much - Martin Eckel - 2003-09-16 16:10:00

Hello,

Not only once I have had the problem, that the C6000 assembler optimizer
is optimizing to much.

Sometimes I have to read a memory location or memory mapped register -
and then throw the value away, because reading of the register already
makes the wanted effect.

But the assembler optimizer thinks, if the value is thrown away, the
whole read command is unneccessary - and the command is just deleted.

Is there any way to tell the assembler optimizer "don't optimize this
line"?

I don't want to program direct in parallel assembler, I like the serial
assembler ;-)

Best regards,
Martin

______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: C6000 assembler optimizer is optimizing too much - Jim Thomas - 2003-09-16 16:36:00



Martin Eckel wrote:
> Hello,
> 
> Not only once I have had the problem, that the C6000 assembler optimizer
> is optimizing to much.
> 
> Sometimes I have to read a memory location or memory mapped register -
> and then throw the value away, because reading of the register already
> makes the wanted effect.
> 
> But the assembler optimizer thinks, if the value is thrown away, the
> whole read command is unneccessary - and the command is just deleted.
> 
> Is there any way to tell the assembler optimizer "don't optimize this
> line"?

Read up on C's "volatile" directive.  In short, you want to do this:

volatile int control_register;

"volatile" tells the optimizer that the value can change outside the 
program (i.e., it's a hardware register or it's changed by an ISR, or 
it's in shared memory and another program changes it, etc...)

-- 
Jim Thomas            Principal Applications Engineer  Bittware, Inc
j...@bittware.com  http://www.bittware.com          (703) 779-7770
Things could be a lot better around here, but worse is more likely - Calvin

______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: C6000 assembler optimizer is optimizing too much - John McCabe - 2003-09-18 12:49:00

On Tue, 16 Sep 2003 16:36:59 -0400, Jim Thomas <j...@bittware.com>
wrote:

>Read up on C's "volatile" directive.  In short, you want to do this:
>
>volatile int control_register;
>
>"volatile" tells the optimizer that the value can change outside the 
>program (i.e., it's a hardware register or it's changed by an ISR, or 
>it's in shared memory and another program changes it, etc...)

Can you declare locations as volatile using assembler then?


Best Regards
John McCabe

To reply by email replace 'nospam' with 'assen'
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: C6000 assembler optimizer is optimizing too much - Jerry Avins - 2003-09-19 00:52:00


John McCabe wrote:

> On Tue, 16 Sep 2003 16:36:59 -0400, Jim Thomas <j...@bittware.com>
> wrote:
> 
> 
>>Read up on C's "volatile" directive.  In short, you want to do this:
>>
>>volatile int control_register;
>>
>>"volatile" tells the optimizer that the value can change outside the 
>>program (i.e., it's a hardware register or it's changed by an ISR, or 
>>it's in shared memory and another program changes it, etc...)
> 
> 
> Can you declare locations as volatile using assembler then?
> 
> 
> Best Regards
> John McCabe
> 
> To reply by email replace 'nospam' with 'assen'

"Volatile" declares that the data at the location may have changed 
without program intervention, and so muse be read afresh each time. It 
doesn't declare that the value must be read even though it is unused. 
Storing it to a dummy variable might be an [expensive] workaround.

Jerry
-- 
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: C6000 assembler optimizer is optimizing too much - John McCabe - 2003-09-19 06:10:00

On Fri, 19 Sep 2003 00:52:58 -0400, Jerry Avins <j...@ieee.org> wrote:

>"Volatile" declares that the data at the location may have changed
>without program intervention, and so muse be read afresh each time. It
>doesn't declare that the value must be read even though it is unused
>Storing it to a dummy variable might be an [expensive] workaround.

Oh *I* know exactly what volatile is in C, but my question was whether
you can apply a 'volatile' qualifier in C6000 assembler. The OP didn't
mention C anywhere so my assumption was that he wasn't using it!


Best Regards
John McCabe

To reply by email replace 'nospam' with 'assen'
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: C6000 assembler optimizer is optimizing too much - Mark Fiedler - 2003-09-19 12:39:00

j...@nospam.demon.co.uk (John McCabe) wrote in message
news:<3...@news.btclick.com>...
> On Fri, 19 Sep 2003 00:52:58 -0400, Jerry Avins <j...@ieee.org> wrote:
> 
> >"Volatile" declares that the data at the location may have changed
> >without program intervention, and so muse be read afresh each time. It
> >doesn't declare that the value must be read even though it is unused
> >Storing it to a dummy variable might be an [expensive] workaround.
> 
> Oh *I* know exactly what volatile is in C, but my question was whether
> you can apply a 'volatile' qualifier in C6000 assembler. The OP didn't
> mention C anywhere so my assumption was that he wasn't using it!
> 
> 
> Best Regards
> John McCabe
> 

There is no need for the volatile qualifier in assembler.  "volatile"
is strictly a compiler directive to make sure that the compiler
generates assembly code for the C source lines in question rather than
optimizing them away.  Assemblers are more or less WYSIWYG, i.e., they
don't optimize code.

Cheers,
Mark Fiedler
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: C6000 assembler optimizer is optimizing too much - Paul Russell - 2003-09-19 13:37:00

Mark Fiedler wrote:
> 
> There is no need for the volatile qualifier in assembler.  "volatile"
> is strictly a compiler directive to make sure that the compiler
> generates assembly code for the C source lines in question rather than
> optimizing them away.  Assemblers are more or less WYSIWYG, i.e., they
> don't optimize code.
> 

This is simply not true. I have used a number of assemblers in the past 
which feature various levels of code optimisation (although this is 
generally limited to peephole optimisation and scheduling, for obvious 
reasons).

I've never used the C6000 assembler, so I don't know what kind of 
optimisations it performs, but it may be that it has some kind of 
"volatile" qualifier to prevent unwanted load/store optimisations. If I 
were the OP I would be inclined to look at the documentation for the 
assembler for inspiration.

Paul

______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: C6000 assembler optimizer is optimizing too much - Jerry Avins - 2003-09-19 19:27:00

As far as I know, the "volatile" type is specific to C. Are there 
optimizing assemblers? What I meant (but didn't write) was that even if 
"volatile" were available and there was an assembler that second-guessed 
the programmer, it wouldn't address the problem.

Jerry
-- 
Engineering is the art of making what you want from things you can get.


John McCabe wrote:

> On Fri, 19 Sep 2003 00:52:58 -0400, Jerry Avins <j...@ieee.org> wrote:
> 
> 
>>"Volatile" declares that the data at the location may have changed
>>without program intervention, and so muse be read afresh each time. It
>>doesn't declare that the value must be read even though it is unused
>>Storing it to a dummy variable might be an [expensive] workaround.
> 
> 
> Oh *I* know exactly what volatile is in C, but my question was whether
> you can apply a 'volatile' qualifier in C6000 assembler. The OP didn't
> mention C anywhere so my assumption was that he wasn't using it!
> 
> 
> Best Regards
> John McCabe
> 
> To reply by email replace 'nospam' with 'assen'
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: C6000 assembler optimizer is optimizing too much - Andrew Nesterov - 2003-09-19 20:17:00

Martin,

What if reserve space for a global variable (somewhere in .data or .bss
or whatever else, but declare it global) and store it with the context
you have just loaded, perhaps this way you would "deceive" the optimizer,
show it that the loaded value IS used, although such a solution is certainly
waste of resources.

Let me know if this worked or not; a segment of sa code and the result asm
piece would be much appreciated :)

For other posts: I am not sure that even declaring the location to be
read off as volatile in C code would solve the problem, as this
read is soft of "futile", since the value will not be used afterward,
and the optimizer should be wiping off such reads anyway. Might be
the same trick with storing a "garbage" global location would help.

One more .sa problem: it might be so that I need to write a squence
of memory locations in a certain order, e.g. to start a QDMA transfer.
I do know how to ensure a sertain order in C (use commas and a semicolon
in the end, forgotten the term, whatewer "point"), but it seem to be
no ways to enforce this in a serial assembly code?

Regards,

Andrew

Martin Eckel <m...@t-online.de> wrote in message
news:<bk7r38$cne$06$1...@news.t-online.com>...
> Hello,
> 
> Not only once I have had the problem, that the C6000 assembler optimizer
> is optimizing to much.
> 
> Sometimes I have to read a memory location or memory mapped register -
> and then throw the value away, because reading of the register already
> makes the wanted effect.
> 
> But the assembler optimizer thinks, if the value is thrown away, the
> whole read command is unneccessary - and the command is just deleted.
> 
> Is there any way to tell the assembler optimizer "don't optimize this
> line"?
> 
> I don't want to program direct in parallel assembler, I like the serial
> assembler ;-)
> 
> Best regards,
> Martin
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: C6000 assembler optimizer is optimizing too much - Andrew Nesterov - 2003-09-19 20:26:00

Jerry Avins <j...@ieee.org> wrote in message
news:<bke23e$h8h$1...@bob.news.rcn.net>...
> John McCabe wrote:
> 
> > On Tue, 16 Sep 2003 16:36:59 -0400, Jim Thomas <j...@bittware.com>
> > wrote:
> > 
> > 
> >>Read up on C's "volatile" directive.  In short, you want to do this:
> >>
> >>volatile int control register;
> >>
> >>"volatile" tells the optimizer that the value can change outside the 
> >>program (i.e., it's a hardware register or it's changed by an ISR, or 
> >>it's in shared memory and another program changes it, etc...)
> > 
> > 
> > Can you declare locations as volatile using assembler then?
> > 
> > 
> > Best Regards
> > John McCabe
> > 
> > To reply by email replace 'nospam' with 'assen'
> 
> "Volatile" declares that the data at the location may have changed 
> without program intervention, and so muse be read afresh each time. It 
> doesn't declare that the value must be read even though it is unused. 
> Storing it to a dummy variable might be an [expensive] workaround.
> 
> Jerry


Oops, many apologies Jerry, you have already pointed out what I was going
to say! And most unfortunately I have posted it :)

Martin, please disregard my post then,

Andrew
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

| 1 | |