Path: utzoo!attcan!uunet!lll-winken!ncis!helios.ee.lbl.gov!pasteur!ucbvax!agate!bionet!csd4.milw.wisc.edu!mailrus!ncar!gatech!hubcap!landman From: landman@Sun.COM (Howard A. Landman) Newsgroups: comp.parallel Subject: Re: Clever programming tricks wanted Message-ID: <4150@hubcap.UUCP> Date: 19 Jan 89 21:33:14 GMT Sender: fpst@hubcap.UUCP Lines: 17 Approved: parallel@hubcap.clemson.edu In article <4131@hubcap.UUCP> dave@vax1.cc.uakron.edu (David Stoutamire) writes: >I have invented a technique for counting one bits that I used >in a bit representation of a board game to do lickety-split >move generation. This is essentially the same as the code I posted earlier. I should point out, however, that for EXTREMELY high performance applications it is much faster to have lookup tables. For 32-bit words this gets impractical, but it is quite reasonable to break it into 16-bit halves, look up the two counts, and sum them together. This requires only 5 instructions (mask, lookup, shift, lookup, add). The counts can't get larger than 5 bits, so the table takes no more than 64KB. Your mileage may vary depending on cache size ... Howard A. Landman landman@hanami.sun.com