Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Beowulf hot spots shown pictorially

Author: Dieter Buerssner

Date: 09:02:36 06/21/02

Go up one level in this thread


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.

BTW. Why the cast in your expression above?

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.