Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Shifting... (OT)

Author: David Blackman

Date: 04:57:41 01/26/01

Go up one level in this thread


On January 25, 2001 at 05:30:23, David Rasmussen wrote:

>Is binary shifting a constant time instruction on most platforms, or does it
>generally depend on how many times you shift?

It's constant time (typically one clock cycle) on most of the current desktop
machines. This may change as clocks get faster and people move to 64 bits. It's
really hard to make big 64 bit shifts go as fast as a 64 bit add if the add uses
all the latest tricks. Also the hardware guys figure that most people care more
about add, so they try harder for that.

Some versions of Compaq Alpha already take 1 clock for small shifts, 2 clocks
for large shifts. This sort of thing will get much more common. We could even
see it stretch to 4 clocks or so for large shifts on some cpus soon.

On some cpus,
(a<<b)
might take longer to do than
(a<<17)
even if b turns out to be 17 at run time. But the difference will likely be
small, probably only one clock.

Some really low end stuff might take time proportional to the shift count, but
we're talking microwave oven controllers here, not something you'd put in a real
computer.

Basically, on any real computer, shifts are fairly fast, and you shouldn't worry
too much about it unless your program is doing big shifts for more than about 5%
of its instructions, which would be a pretty strange sort of program.



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.