DSPRelated.com
Forums

optimizer problems

Started by Nick Faulkner October 25, 2002
Morning all

I'm using VisualDSP++ 2.0, target processor 21161. My application code will be
large, so I'm trying things out using various optimizer settings. Problem is
that
the optimizer is removing some of my write operations to hardware. For example,
I
have a hardware-based FIFO device which I put data into by repeated writes to
the
same hardware device address.

#define FIFO_ADDRESS 0x00c330000

*(int *)FIFO_ADDRESS = data1;
*(int *)FIFO_ADDRESS = data2;
*(int *)FIFO_ADDRESS = data3;

etc. etc.

I can see why the optimizer would remove all but the last of these write
operations,
but it still does so when I use the 'volatile' declaration as follows;

#define FIFO_ADDRESS 0x00c330000

volatile int *Pointer_to_Hardware;

Pointer_to_Hardware = (int *)FIFO_ADDRESS;

/* output the data to FIFO */
for(i=0;i<20;i++)
{
*Pointer_to_Hardware= i;
}

Any suggestions about how I can overcome this problem? Maybe there's a pragma I

can use to switch the optimizer off for certain bits of my code? Any help
gratefully received, thanks,
Nick
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************



Morning,
Looks like the fact of the variables declaration is not much helpful at all.
Niether volatile, static or as global variable would work.
Seems like the optimizer does trim that piece of code because it does not much
processing, which is what it is supposed to optimize for.
I think you could use inline assembly like:
r0 = data0;
dm(FIFO_ADDRESS) = r0;
Which is finally what you want the compiler to produce. Your could also have
your hardware related routines in one C file and change the settings for only
that file, right-clicking it in the Project Window and disabling the compiler
optimizer for it.
Best regards,
JaaC
SanJaaC Electronics
www.angelfire.com/electronic2/sanjaac
uC - FPGA - DSP
Nick Faulkner <> wrote:Morning all

I'm using VisualDSP++ 2.0, target processor 21161. My application code will be
large, so I'm trying things out using various optimizer settings. Problem is
that
the optimizer is removing some of my write operations to hardware. For example,
I
have a hardware-based FIFO device which I put data into by repeated writes to
the
same hardware device address.

#define FIFO_ADDRESS 0x00c330000

*(int *)FIFO_ADDRESS = data1;
*(int *)FIFO_ADDRESS = data2;
*(int *)FIFO_ADDRESS = data3;

etc. etc.

I can see why the optimizer would remove all but the last of these write
operations,
but it still does so when I use the 'volatile' declaration as follows;

#define FIFO_ADDRESS 0x00c330000

volatile int *Pointer_to_Hardware;

Pointer_to_Hardware = (int *)FIFO_ADDRESS;

/* output the data to FIFO */
for(i=0;i<20;i++)
{
*Pointer_to_Hardware= i;
}

Any suggestions about how I can overcome this problem? Maybe there's a pragma I
can use to switch the optimizer off for certain bits of my code? Any help
gratefully received, thanks,
Nick
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
******************************************************************** _____________________________________
Note: If you do a simple "reply" with your email client, only the author of this
message will receive your answer. You need to do a "reply all" if you want your
answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join: Send an email to

To Post: Send an email to

To Leave: Send an email to

Archives: http://groups.yahoo.com/group/adsp

Other Groups: http://www.dsprelated.com/groups.php3 ">http://docs.yahoo.com/info/terms/

Jaime Andr Aranguren Cardona





Hi,

There is a "hot patch" af ftp.analog.com that addresses VDSP++ 2.0 optimization
issues. Give that a try.

I've got a legacy application written in VDSP 4.1, I tried to get it to work
under VDSP++ 2.0 with no luck.

I'm hopeful that VDSP++ 3.0 will be the ticket. This e-mail may contain SEL confidential information. The opinions expressed
are not necessarily those of SEL. Any unauthorized disclosure, distribution or
other use is prohibited. If you received this e-mail in error, please notify
the sender, permanently delete it, and destroy any printout. Thank you.


--On Friday, October 25, 2002 10:38:59 AM +0100 Nick Faulkner
<> wrote:

># define FIFO_ADDRESS 0x00c330000
> volatile int *Pointer_to_Hardware;
> Pointer_to_Hardware = (int *)FIFO_ADDRESS;

I'd just collapse this to:

#define FIFO (*(volatile int *)0x00c330000)

FIFO = i;

As Chuck says, the initial release of VDSP2.0 had a bug involving volatile,
so you should install the latest cumulative update, which I believe is now
6.1.9.1. It's a zip file on the ADI FTP site. There are also Word files for
all the interim releases showing what's fixed by each update.

If the bug remains after installing this update, compose a small sample
reproducing the bug, with the compiler command line used, and send it to
the support address. Bugs that are easy to reproduce get fixed fast.