Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Beowulf hot spots shown pictorially

Author: Sune Fischer

Date: 09:24:28 06/21/02

Go up one level in this thread


On June 21, 2002 at 12:02:36, Dieter Buerssner wrote:

>On June 21, 2002 at 06:03:53, Sune Fischer wrote:
>
>>I can tell you that the modulo operation on a integer is _faster_ than if you do
>>a manual implementation of x%n as x-n*(int)(x/n), I tested that long ago.
>
>This is no big surprise on x86 architecture, because you need to do a "div"
>instruction in either case. The div instruction calculates at the same time the
>result of the division and the modulo (storing them in different registers). So,
>it is clear, that your second instruction is slower.
>
>The "low-level" division routines I know, also calculate the result and the
>modulo at the same time. Some are much like I (and probably you) learned at
>school to do divisions on a piece of paper, where you also get the modulo for
>free, when doing a division.

Ah, yes I guess if go that lowlevel and break down the division algorithm, then
you can improve on the modulo expression, the division is actually giving us
more than we need to know in this case.

>BTW. Why the cast in your expression above?

Because I'm a student of math so it's a habit to be "strict" about things,
anyway it was just to make things absolutely clear.
I hope the compiler is smart enough to not actually do the cast (since it is
done anyway), but perhaps I'm mistaken about that.

-S.

>Regards,
>Dieter



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.