Home * People * Kim Walisch

Kim Walisch,
a software engineer from Luxembourg, and avocational expert in prime number generation [1] [2], applying the Sieve of Eratosthenes[3] . He is knowledgeable about processor architectures, software optimization and bit-twiddling.

Bitscan

In October 2012, Kim Walisch proposed an improved bitscan routine, multiplying the De Bruijn sequence with a 0-1 mask separated by the least significant one bit of a scanned integer or bitboard. The mask separation is cheaper than the bit isolation due to the x86 lea instruction, performing the decrement of a source register into another target register, not affecting processor flags. This is a 32-bit bitscan forward routine:

const int index32[32] = {
    0,  9,  1, 10, 13, 21,  2, 29, 
   11, 14, 16, 18, 22, 25,  3, 30,
    8, 12, 20, 28, 15, 17, 24,  7,
   19, 27, 23,  6, 26,  5,  4, 31
};
 
/**
 * bitScanForward
 * @author Kim Walisch (2012)
 * @param v 32-bit set
 * @precondition v != 0
 * @return index (0..31) of least significant one bit
 */
int bitScanForward(unsigned int v) {
   return index32[((v ^ (v - 1)) * 0x07C4ACDDU) >> 27];
}

External Links


References

  1. ^ Referent Kim Walisch www.primzahlen.de (German)
  2. ^ Formula for primes from Wikipedia
  3. ^ primesieve - Optimized sieve of Eratosthenes implementation - Google Project Hosting by Kim Walisch

What links here?


Up one level