Author: Matt Taylor
Date: 10:24:02 02/14/03
Go up one level in this thread
On February 14, 2003 at 12:48:32, Anthony Cozzie wrote: >On February 14, 2003 at 03:40:53, Matt Taylor wrote: > >>AFAIK all suggestions are now incorporated: >>ftp://24.73.126.6/lsb.h >>ftp://24.73.126.6/lsb.c >> >>Somebody (I no longer remember who) asked me to create a version that does not >>use cmovcc so it will run on older chips. I may get around to this, but it is >>not high priority. Staying sane is high priority. >> >>Popcount was also requested; this may make its way into that file very soon -- I >>just need to copy code from the K7 optimization manual. >> >>All versions (inline C and all 3 asm routines) tested in GCC and VC against a >>pure-C routine and seem to work for me. >> >>Once again, suggestions are always welcome. Bug reports are even more welcome. >> >>Happy bit fiddling! >> >>-Matt > > >if you are referring to the MMX code AMD suggests, I tried implementing it and >found it to be inferior to the standard & 0x5555 etc trick. Of course, maybe I >just did it wrong :) Great job on the first bitscan though. I plan on adding it >to my program pretty soon. > >anthony I did not know the MMX code was that slow, though it's not much of a suprise; Athlon's MMX implementation has latency which sometimes can't be avoided. They have an MMX version and integer version. The integer trick is close to the 0x5555 trick, but it diverges at the end. It looks like this: Let x = number to be counted x = x - ((x >> 1) & 0x55555555) x = (x & 0x33333333) + ((x >> 2) & 0x33333333) x = (x + (x >> 4)) & 0x0F0F0F0F x = (x * 0x01010101) >> 24 I believe they apply the same algorithm in MMX to do a 2 parallel 32-bit popcounts. I intend to explore modification of the integer algorithm to support 64-bit popcounting, the MMX algorithm for 64-bit popcounting, and of course the standard trick to which you refer. If I find anything else, I will most certainly explore those routes as well. -Matt
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.