Hi,
I'm not sure if any of the following will be of any help, as it's
all fairly general. We've done a lot of DSP on RISC processors. Some
general things we've learned:
- Focus from the start on algorithm optimization rather than fine
details of coding: leave that until last
- The key weakness of RISC for DSP work is the lack of circular
buffers and multiple data paths; this applies particularly to the
ARM7TDMI which has MAC instructions etc. (i.e. if it has circular
buffers, it would be a pretty good DSP). You need to think very
carefully about how buffers are managed and accessed.
- I'd strongly discourage the use of in-line assembler: if you need
assembler, code it separately. Apart from portability issues, it's a
maintenance headache, and involves a lot of extra work.
- On other platforms we code everything in `C' and a few "inner
core" functions in assembler. However, we found on the ARM7TDMI
platforms, the `C' code was as good as anything hand-crafted in
assembler (using GCC with O3). In other words, `C' can work just as
well if you take the right approach
- The "right approach" we found was to simplify the code as much as
possible, get the types right, avoid "tricky" statements etc. etc.
- Code up some alternatives and look at the assembler output by the
compiler. By careful tweaking, you can frequently get significant
improvements. For example, depending on context "sum += *a++ * *b++"
can be a lot faster/slower than "sum = a[i] + b[i]; i++"
- In particular, cut down on the number of data objects being
accessed by a particular block of code: this will help cut down on
the number of loads/stores required.
- Look at coding some special cases: for example, we code small FIR
and IIR filters completely in-line (no loops). If you're after
maximum performance, you might have to sacrifice some generality
- You do NOT need in-line assembler to make use of the enhanced math
instructions (mac etc.): GCC will generate these where appropriate.
It doesn't handle saturation, but this is best avoided in any case.
I appreciate these are very general points: If I get the chance I'll
try and post some more specific examples. In the meantime, hopefully
this will be of some use.
Brendan
--- In lpc2000@yahoogroups.com, "MB" <mb12_il@...> wrote:
>
> Hi,
>
> I'm trying to do some DSP algorithms on my ARM7TDMI, therefore I'm
> aiming for the maximum performace that I can get from this chip.
> The code is optimized for the usage of almost all avalible
registers
> and to spare unnecessary loads and stores. At the begining I tried
> writing it in C, but I got a lot of STR LDR commands that slowed
down
> the process.
>
> For the time being I'm just learning the ARM architecture, though I
> would like (in the future) to use it for some heavy calculations.
>
> Thanks in advance,
> MB
>
> --- In lpc2000@yahoogroups.com, "Bryce Schober" <bryce.schober@>
wrote:
> >
> > Robert's point is a good one. Aviod inline assembler where
possible.
> I've
> > often found that GCC's optimization was better than I would've
come
> up with
> > anyway. I've only used inline assembly in a few cases where I
needed the
> > absolute best performance, which involved using instructions
that it was
> > hard to get GCC to emit. It seems that you're using a pseudo-
opcode that
> > might not even be recognized by the GCC compiler. Regarding
inline
> assembly
> > syntax in general, it seems that you're missing some syntax
concepts
> that
> > can be found here:
> >
> > http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-
HOWTO.html#s2
> >
> > Then, if you really need to get in deep you can check out your
GCC
> version's
> > manual section entitled "Constraints for asm operands", which
will
> also have
> > target-specific bits. But again, as recommended by Robert, stay
away
> from
> > inline assembly, unless absolutely
> >
> necessary.<http://gcc.gnu.org/onlinedocs/gcc-
4.0.1/gcc/Constraints.html#Constraints>
> >
> > On 5/7/06, Robert Adsett <subscriptions@> wrote:
> > >
> > > At 11:15 AM 5/6/2006 +0000, MB wrote:
> > > >I'm trying to use C variables inside inline assembly code,
but can't
> > > >get it to work (the compiler is gcc).
> > > >
> > > >static const short g_psMyArray asm("g_psAsmMyArray:") =
> > > >{ 1, 2, 3, 4};
> > > >
> > > >void myfunc()
> > > >{
> > > > asm("ADRL r14, psAsmMyArray");
> > > >}
> > > >
> > > >This results with an error (something like "symbol is
undefined in
> > > >current file").
> > >
> > > Why not just use C? What's the advantage you are expecting
that's
> > > compelling you to use assembly?
> > >
> > > If you can provide a little more detail maybe we can solve the
> problem in
> > > another way.
> > >
> > > Robert
> > >
> > >
> > > " 'Freedom' has no meaning of itself. There are always
> restrictions, be
> > >
> > > they legal, genetic, or physical. If you don't believe me,
try to
> chew a
> > > radio signal. " -- Kelvin Throop, III
> > > http://www.aeolusdevelopment.com/
> > >
> > >
> > >
> > >
> > > SPONSORED LINKS
> > >
> Microcontrollers<http://groups.yahoo.com/gads?
t=ms&k=Microcontrollers&w1=Microcontrollers&w2=Microprocessor&w3=Inte
l+microprocessors&c=3&s=69&.sig=c-HXthtbZy4TZbI3ib0PMg>
> > >
> Microprocessor<http://groups.yahoo.com/gads?
t=ms&k=Microprocessor&w1=Microcontrollers&w2=Microprocessor&w3=Intel+
microprocessors&c=3&s=69&.sig=ijt0SspWtjogcHCuFD0lUQ>
> Intel
> > >
> microprocessors<http://groups.yahoo.com/gads?
t=ms&k=Intel+microprocessors&w1=Microcontrollers&w2=Microprocessor&w3
=Intel+microprocessors&c=3&s=69&.sig=WOZdpklkgHbXR5quAgrl5w>
> > > ------------------------------
> > > YAHOO! GROUPS LINKS
> > >
> > >
> > > - Visit your group "lpc2000
> <http://groups.yahoo.com/group/lpc2000>"
> > > on the web.
> > >
> > > - To unsubscribe from this group, send an email to:
> > >
> lpc2000-unsubscribe@yahoogroups.com<lpc2000-
unsubscribe@yahoogroups.com?subject=Unsubscribe>
> > >
> > > - Your use of Yahoo! Groups is subject to the Yahoo! Terms
ofShow quoted textHide quoted text
> > > Service <http://docs.yahoo.com/info/terms/>.
> > >
> > >
> > > ------------------------------
> > >
> >
> >
> >
> > --
> > Bryce Schober
> >
> >
> > [Non-text portions of this message have been removed]
> >
>