how to fast set the bitset by using multiple position once

120 views Asked by At

how to fast set the bitset by using multiple position, eg: the position : 1,4,5,6,9,3. the bitset is 0101111001....,whether can use SIMD instruction? I know the simple method, eg: assume the word_t is unsigned char:

void set_bit(word_t* bitset, int position) {
  int index= position / std::numeric_limits<word_t>::digits;
  int offset = position % std::numeric_limits<word_t>::digits;
  bitset[index] |= (1U << (std::numeric_limits<word_t>::digits -1 - offset));
}
0

There are 0 answers