Computer Chess Club Archives


Search

Terms

Messages

Subject: PowerPC BitCounting Functions Speed

Author: William Bryant

Date: 18:35:19 04/20/00


PowerPC BitCounting Functions

I tested a number of the bit counting methods found in the reference
files provided by Dan Corbet for speed on my machine.
(from file BC.c)

Each test was 5 calls to the function using
unsigned long long (UInt64) values having from 1 to 16 bits set.
#define Test1		0x0000000000000001
#define Test2		0x0000000100000001
#define Test4		0x0001000100010001
#define Test8		0x0101010101010101
#define Test16		0x1111111111111111

Each test was run for 1000000 iterations and repeated 3 times
for an average time in microseconds.

All functions were inlined and compiled with Metrowerks 5.3
with full optimizations and run on my G3 266mhz machine.

The base value is the function "PopCnt" found in Crafty source
in the section #ifdef Macintosh

<Smaller Time is Better>

Functions			Relative	Absolute
				Time		Time (seconds)
PopCnt     		1.00     	 1.099945

HackMem Functions
hackmemmod			9.24		10.173103
hackmemloop		9.31		10.243583
hackmemunrolled		9.40		10.341939

rmlsbsub			1.18		 1.294476

rmlsbmask			0.96		 1.061217

testlsb			8.95		 9.848707

testmsb		     11.52		12.678724

testsignandshift     18.16		19.972608

testeachbit 	     11.51		12.661518

testeachbit1shl      14.00		15.399991

Table Driven Functions (table of unsigned char)
tableshift			1.90		2.084985
tableuchar			0.68		0.744732	*****
tableshiftcast		1.79		1.972071

Table Driven Functions (table of int)
itableshift		1.79		1.972032
itableuchar		0.80		0.876940
itableshiftcast		1.71		1.877504

sumbits			1.21		1.332092


I wonder if the table functions performed better because for this
test the entire table was able to be kept in catch?

William
wbryant@ix.netcom.com



This page took 0.06 seconds to execute

Last modified: Thu, 07 Jul 11 08:48:38 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.