I am studying bitwise operations.
but, I do not understand why they claimed the code is run in parallel.
Compute parity in parallel
unsigned int v; // word value to compute the parity of
v ^= v >> 16;
v ^= v >> 8;
v ^= v >> 4;
v &= 0xf;
return (0x6996 >> v) & 1;
I copied the code from
http://graphics.stanford.edu/~seander/bithacks.html#ParityParallel
Any help will be appreciated.
A naive, sequential method to compute the parity of a 32-bit word would take (order of) 32 operations. This method is parallel (or “vectorized”) because it operates on many bits at once. The first line
v ^= v >> 16combines the 16 high bits with the 16 low bits in just one instruction.