Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Speaking of fast ways to do things...

Author: Bruce Moreland

Date: 17:02:48 04/19/00

Go up one level in this thread


On April 19, 2000 at 13:49:25, Dann Corbit wrote:

>What is the fastest way to fill a linear array of bytes with zero, given the
>following conditions:
>1.  Intel PII or higher CPU
>2.  Guarantee that the number of bytes is an even number?
>
>I am porting a chess program, and memset() is the bottleneck.  I don't need to
>memset an arbitrary character.  It's always zero.

Assuming you are using MSVC and have inline library functions enabled, try
memset and use -Fc to see the code generated.  If the number of bytes of fill is
a constant, and the byte to fill is a constant, the compiler should understand
what is going on and generate very fast code.  My guess is that it will use a
32-bit "stos" instruction if there are more than a few bytes to fill.  If there
are only a few, it might do register -> memory moves.

bruce




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.