Vector Optimized Library of Kernels  3.0.0
Architecture-tuned implementations of math kernels

Overview

Computes the population count (popcnt), or Hamming distance of a binary string. This kernel takes in a single unsigned 64-bit value and returns the count of 1's that the value contains.

Dispatcher Prototype

void volk_64u_popcnt(uint64_t* ret, const uint64_t value)

Inputs

  • value: The input value.

Outputs

  • ret: The return value containing the popcnt.

Example

int N = 10;
unsigned int alignment = volk_get_alignment();
uint64_t bitstring[] = {0x0, 0x1, 0xf, 0xffffffffffffffff,
0x5555555555555555, 0xaaaaaaaaaaaaaaaa, 0x2a2a2a2a2a2a2a2a,
0xffffffff, 0x32, 0x64};
uint64_t hamming_distance = 0;
for(unsigned int ii=0; ii<N; ++ii){
volk_64u_popcnt(&hamming_distance, bitstring[ii]);
printf("hamming distance of %lx = %li\n", bitstring[ii], hamming_distance);
}
size_t volk_get_alignment(void)
Get the machine alignment in bytes.
Definition: volk.tmpl.c:90