Author: Dann Corbit
Date: 16:13:08 01/02/03
Go up one level in this thread
On January 02, 2003 at 17:06:39, David Rasmussen wrote:
>On January 02, 2003 at 14:53:17, Dann Corbit wrote:
>
>>>
>>>So Duff's Device isn't used in Ferret?! :)
>>
>>Actually, it is almost certain that Duff's device is used in Ferret. A compiler
>>that allows loop unrolling is (in effect) using Duff's device.
>>
>
>Mmm. I would disagree with that logic. Just because to pieces of code result in
>the same assembler output by some compiler, doesn't mean that those two pieces
>of code are equivalent, specifically, they are not of equal quality, in my
>world.
Here is my assertion (which was not made plain):
Loop unrolling is done (generally speaking) by using Duff's device. Hence,
compiled code that is written in C or C++ is probably "using" Duff's device.
BTW (for those who have no idea what we are talking about) here is Duff's device
compared to a normal iteration for a copy operation:
void loopcopy(long *to, long *from, long count)
{
do
*to = *from++;
while (--count > 0);
return;
}
void duffcopy(long *to, long *from, long count)
{
register n = (count + 7) / 8;
switch (count % 8)
{
case 0:
do
{
*to = *from++;
case 7:
*to = *from++;
case 6:
*to = *from++;
case 5:
*to = *from++;
case 4:
*to = *from++;
case 3:
*to = *from++;
case 2:
*to = *from++;
case 1:
*to = *from++;
}
while (--n > 0);
}
return;
}
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.