Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

zero-overhead loops?

1 view
Skip to first unread message

Andreas Bellgardt

unread,
Apr 14, 2003, 9:35:59 AM4/14/03
to
Can anybody tell me what "zero-overhead loop" mean.
I read it in a book about DSPs with no further explanation.

Thanks!

Mark A. Odell

unread,
Apr 14, 2003, 9:58:16 AM4/14/03
to
Andreas Bellgardt <bell...@netiera.de> wrote in
news:b7edds$p6b$02$1...@news.t-online.com:

> Can anybody tell me what "zero-overhead loop" mean.
> I read it in a book about DSPs with no further explanation.

http://tinyurl.com/9hlq

Tom Cerul

unread,
Apr 14, 2003, 12:55:39 PM4/14/03
to
specifically this returned from google,

http://www.chipcenter.com/eexpert/bhenderson/bhenderson008.html

Looks like a hardware trick that lets you do "for" loops quickly. You
tell it the start and end addresses and a number of times and ZOOM,
the hardware just does that small piece of code really fast.

Gopi Bulusu

unread,
Apr 23, 2003, 2:49:05 AM4/23/03
to
There is generally an overhead associated with the code generated for
a
loop. This includes setting a counter value before the loop (fixed
overhead)
and instructions to decrement the counter, check for termination
condition
and redo the loop (overhead repeated for each iteration).

A zero overhead loop, is a hardware (CPU) instruction that eliminates
loop overhead. This is achieved by a special "loop" instruction
that repeatedly executes a block of code (start address .. end
address)
a fixed number of times (the loop count).

The loop code can either be a constant value specified in the loop
instruction
or a register value depending on the implementation of the loop
instruction.

A good DSP compiler should take advantage of loop instructions
whenever possible. For small loops, zero overhead loop optimizations
can provide
gains of almost 100% faster execution !

Regards,
gopi

---

Gopi Kumar Bulusu
Sankhya Technologies Private Limited
http://www.sankhya.com
Tel: +91 44 2822 7358
Fax: +91 44 2822 7357

Andreas Bellgardt <bell...@netiera.de> wrote in message news:<b7edds$p6b$02$1...@news.t-online.com>...

Rick Merrill

unread,
Apr 23, 2003, 3:06:09 PM4/23/03
to
Gopi Bulusu wrote:
> There is generally an overhead associated with the code generated for
> a
> loop. This includes setting a counter value before the loop (fixed
> overhead)
> and instructions to decrement the counter, check for termination
> condition
> and redo the loop (overhead repeated for each iteration).
>
> A zero overhead loop, is a hardware (CPU) instruction that eliminates
> loop overhead. This is achieved by a special "loop" instruction
> that repeatedly executes a block of code (start address .. end
> address)
> a fixed number of times (the loop count).
>
> The loop code can either be a constant value specified in the loop
> instruction
> or a register value depending on the implementation of the loop
> instruction.
>
> A good DSP compiler should take advantage of loop instructions
> whenever possible. For small loops, zero overhead loop optimizations
> can provide
> gains of almost 100% faster execution !
>
> Regards,
> gopi

Caveat: the loop may not be allowed to contain subroutine calls on
some implementations, but then it is supposed to be a small loop.
- RM

Jonathan Kirwan

unread,
Apr 23, 2003, 3:46:43 PM4/23/03
to
On Wed, 23 Apr 2003 19:06:09 GMT, Rick Merrill
<RickM...@att2.com> wrote:

><snip>


>Caveat: the loop may not be allowed to contain subroutine calls on
>some implementations, but then it is supposed to be a small loop.

My limited experience with zero-overhead loops is that they are
implemented by dedicating an address comparator to detect early
when the instruction pointer reaches the end of the loop and
forcing it back to the beginning, conditionally on some status
bit(s). It's a compare-equal, though, from what I've seen.
This has it's problems, such as placing a call instruction right
at the end of the loop, but calls within the body often work
just fine. Just add a NOP to the end, if a call is needed
there.

And yes, more often than not, a subroutine call isn't
appropriate where the performance of a zero-overhead loop is
required. But given that they exist, they will be used for a
wide variety of needs. Sometimes, the speed isn't important but
the semantic of a DO..LOOP is; and such loops are usually also
very simple to use, so they get used instead of explicitly
making compares and jumps to form a counted loop.

Jon

0 new messages