BitMagic-C++: SSE4.2 funcions (internal)

BitMagic-C++

Functions
SSE4.2 funcions (internal)

Processor specific optimizations for SSE4.2 instructions (internals) More...

## Functions
bm::id_t | bm::sse4_bit_count (const __m128i *block, const __m128i *block_end)
bool | bm::sse4_is_all_zero (const __m128i *BMRESTRICT block)
| check if block is all zero bits More...
bool | bm::sse4_is_digest_zero (const __m128i *BMRESTRICT block)
| check if digest stride is all zero bits More...
void | bm::sse4_block_set_digest (__m128i *dst, unsigned value)
| set digest stride to 0xFF.. or 0x0 value More...
unsigned | bm::sse4_and_block (__m128i *BMRESTRICT dst, const __m128i *BMRESTRICT src)
| AND blocks2 dst &= *src. More...
bool | bm::sse4_and_digest (__m128i *BMRESTRICT dst, const __m128i *BMRESTRICT src)
| AND block digest stride dst &= *src. More...
bool | bm::sse4_and_digest_2way (__m128i *BMRESTRICT dst, const __m128i *BMRESTRICT src1, const __m128i *BMRESTRICT src2)
| AND block digest stride dst = *src1 & src2. More...
bool | bm::sse4_and_digest_5way (__m128i *BMRESTRICT dst, const __m128i *BMRESTRICT src1, const __m128i *BMRESTRICT src2, const __m128i *BMRESTRICT src3, const __m128i *BMRESTRICT src4)
| AND block digest stride. More...
bool | bm::sse4_sub_digest (__m128i *BMRESTRICT dst, const __m128i *BMRESTRICT src)
| SUB (AND NOT) block digest stride dst &= ~*src. More...
bool | bm::sse4_sub_digest_2way (__m128i *BMRESTRICT dst, const __m128i *BMRESTRICT src1, const __m128i *BMRESTRICT src2)
| 2-operand SUB (AND NOT) block digest stride dst = src1 & ~*src2 More...
bool | bm::sse4_is_all_one (const __m128i *BMRESTRICT block)
| check if block is all zero bits More...
BMFORCEINLINE bool | bm::sse42_test_all_one_wave (const void *ptr)
| check if SSE wave is all oxFFFF...FFF More...
BMFORCEINLINE bool | bm::sse42_test_all_zero_wave (const void *ptr)
| check if wave of pointers is all NULL More...
BMFORCEINLINE bool | bm::sse42_test_all_zero_wave2 (const void *ptr0, const void *ptr1)
| check if 2 waves of pointers are all NULL More...
BMFORCEINLINE bool | bm::sse42_test_all_eq_wave2 (const void *ptr0, const void *ptr1)
| check if wave of 2 pointers are the same (null or FULL) More...
unsigned | bm::sse42_bit_block_calc_change (const __m128i *BMRESTRICT block, unsigned size)
unsigned | bm::sse42_bit_block_calc_xor_change (const __m128i *BMRESTRICT block, const __m128i *BMRESTRICT xor_block, unsigned size)
void | bm::sse42_bit_block_calc_change_bc (const __m128i *BMRESTRICT block, unsigned *gc, unsigned *bc)
unsigned | bm::sse4_gap_find (const bm::gap_word_t *BMRESTRICT pbuf, const bm::gap_word_t pos, const unsigned size)
unsigned | bm::sse42_gap_bfind (const unsigned short *BMRESTRICT buf, unsigned pos, unsigned *BMRESTRICT is_set)
| Hybrid binary search, starts as binary, then switches to linear scan. More...
unsigned | bm::sse42_gap_test (const unsigned short *BMRESTRICT buf, unsigned pos)
| Hybrid binary search, starts as binary, then switches to scan. More...
int | bm::sse42_cmpge_u32 (__m128i vect4, unsigned value)
| Experimental (test) function to do SIMD vector search (lower bound) in sorted, growing array. More...
unsigned | bm::sse4_lower_bound_scan_u32 (const unsigned *BMRESTRICT arr, unsigned target, unsigned from, unsigned to)
| lower bound (great or equal) linear scan in ascending order sorted array More...
bool | bm::sse42_shift_l1 (__m128i *block, unsigned *empty_acc, unsigned co1)
| block shift left by 1 More...
bool | bm::sse42_shift_r1 (__m128i *block, unsigned *empty_acc, unsigned co1)
| block shift right by 1 More...
bool | bm::sse42_shift_r1_and (__m128i *block, bm::word_t co1, const __m128i *BMRESTRICT mask_block, bm::id64_t *digest)
| block shift right by 1 plus AND More...
void | bm::sse42_bit_block_xor (bm::word_t *target_block, const bm::word_t *block, const bm::word_t *xor_block, bm::id64_t digest)
| Build partial XOR product of 2 bit-blocks using digest mask. More...

## Detailed Description

Processor specific optimizations for SSE4.2 instructions (internals)

## Function Documentation

## ◆ sse42_bit_block_calc_change()

unsigned bm::sse42_bit_block_calc_change | ( | const __m128i *BMRESTRICT | block,
|  | unsigned | size
| ) |  |
| inline

SSE4.2 calculate number of bit changes from 0 to 1

Definition at line 633 of file bmsse4.h.

## ◆ sse42_bit_block_calc_change_bc()

void bm::sse42_bit_block_calc_change_bc | ( | const __m128i *BMRESTRICT | block,
|  | unsigned * | gc,
|  | unsigned * | bc
| ) |  |
| inline

SSE4.2 calculate number of bit changes from 0 to 1

Definition at line 798 of file bmsse4.h.

References bm::set_block_size.

## ◆ sse42_bit_block_calc_xor_change()

unsigned bm::sse42_bit_block_calc_xor_change | ( | const __m128i *BMRESTRICT | block,
|  | const __m128i *BMRESTRICT | xor_block,
|  | unsigned | size
| ) |  |
| inline

SSE4.2 calculate number of bit changes from 0 to 1 of a XOR product

Definition at line 711 of file bmsse4.h.

## ◆ sse42_bit_block_xor()

void bm::sse42_bit_block_xor | ( | bm::word_t * | target_block,
|  | const bm::word_t * | block,
|  | const bm::word_t * | xor_block,
|  | bm::id64_t | digest
| ) |  |
| inline

Build partial XOR product of 2 bit-blocks using digest mask.

Parameters

  target_block | - target := block ^ xor_block
  block | - arg1
  xor_block | - arg2
  digest | - mask for each block wave to XOR (1) or just copy (0)

Definition at line 1652 of file bmsse4.h.

References bm::block_waves, and bm::set_block_digest_wave_size.

## ◆ sse42_cmpge_u32()

int bm::sse42_cmpge_u32 | ( | __m128i | vect4,
|  | unsigned | value
| ) |  |
| inline

Experimental (test) function to do SIMD vector search (lower bound) in sorted, growing array.

Definition at line 1123 of file bmsse4.h.

## ◆ sse42_gap_bfind()

unsigned bm::sse42_gap_bfind | ( | const unsigned short *BMRESTRICT | buf,
|  | unsigned | pos,
|  | unsigned *BMRESTRICT | is_set
| ) |  |
| inline

Hybrid binary search, starts as binary, then switches to linear scan.

Parameters

  buf | - GAP buffer pointer.
  pos | - index of the element.
  is_set | - output. GAP value (0 or 1).

Returns
  GAP index.

Definition at line 1058 of file bmsse4.h.

References BM_ASSERT, and bm::sse4_gap_find().

Referenced by bm::sse42_gap_test().

## ◆ sse42_gap_test()

unsigned bm::sse42_gap_test | ( | const unsigned short *BMRESTRICT | buf,
|  | unsigned | pos
| ) |  |
| inline

Hybrid binary search, starts as binary, then switches to scan.

Definition at line 1106 of file bmsse4.h.

References bm::sse42_gap_bfind().

Referenced by bm::gap_test_unr().

## ◆ sse42_shift_l1()

bool bm::sse42_shift_l1 | ( | __m128i * | block,
|  | unsigned * | empty_acc,
|  | unsigned | co1
| ) |  |
| inline

block shift left by 1

Definition at line 1437 of file bmsse4.h.

References bm::set_block_size.

## ◆ sse42_shift_r1()

bool bm::sse42_shift_r1 | ( | __m128i * | block,
|  | unsigned * | empty_acc,
|  | unsigned | co1
| ) |  |
| inline

block shift right by 1

Definition at line 1487 of file bmsse4.h.

References bm::set_block_size.

## ◆ sse42_shift_r1_and()

bool bm::sse42_shift_r1_and | ( | __m128i * | block,
|  | bm::word_t | co1,
|  | const __m128i *BMRESTRICT | mask_block,
|  | bm::id64_t * | digest
| ) |  |
| inline

block shift right by 1 plus AND

Returns
  carry over flag

Definition at line 1537 of file bmsse4.h.

References BM_ASSERT, bm::id_max, and bm::set_block_digest_wave_size.

## ◆ sse42_test_all_eq_wave2()

BMFORCEINLINE bool bm::sse42_test_all_eq_wave2 | ( | const void * | ptr0,
|  | const void * | ptr1
| ) |  |

check if wave of 2 pointers are the same (null or FULL)

Definition at line 619 of file bmsse4.h.

Referenced by bm::bvector<>::combine_operation_or().

## ◆ sse42_test_all_one_wave()

BMFORCEINLINE bool bm::sse42_test_all_one_wave | ( | const void * | ptr | ) |

check if SSE wave is all oxFFFF...FFF

Definition at line 584 of file bmsse4.h.

## ◆ sse42_test_all_zero_wave()

BMFORCEINLINE bool bm::sse42_test_all_zero_wave | ( | const void * | ptr | ) |

check if wave of pointers is all NULL

Definition at line 595 of file bmsse4.h.

Referenced by bm::bvector<>::combine_operation_and(), bm::bvector<>::combine_operation_sub(), bm::for_each_bit(), and bm::for_each_nzblock().

## ◆ sse42_test_all_zero_wave2()

BMFORCEINLINE bool bm::sse42_test_all_zero_wave2 | ( | const void * | ptr0,
|  | const void * | ptr1
| ) |  |

check if 2 waves of pointers are all NULL

Definition at line 606 of file bmsse4.h.

Referenced by bm::bvector<>::combine_operation_xor().

## ◆ sse4_and_block()

unsigned bm::sse4_and_block | ( | __m128i *BMRESTRICT | dst,
|  | const __m128i *BMRESTRICT | src
| ) |  |
| inline

AND blocks2 dst &= *src.

Returns
  0 if no bits were set

Definition at line 237 of file bmsse4.h.

References BMRESTRICT, and bm::set_block_size.

## ◆ sse4_and_digest()

bool bm::sse4_and_digest | ( | __m128i *BMRESTRICT | dst,
|  | const __m128i *BMRESTRICT | src
| ) |  |
| inline

AND block digest stride dst &= *src.

Returns
  true if stide is all zero

Definition at line 284 of file bmsse4.h.

## ◆ sse4_and_digest_2way()

bool bm::sse4_and_digest_2way | ( | __m128i *BMRESTRICT | dst,
|  | const __m128i *BMRESTRICT | src1,
|  | const __m128i *BMRESTRICT | src2
| ) |  |
| inline

AND block digest stride dst = *src1 & src2.

Returns
  true if stide is all zero

Definition at line 332 of file bmsse4.h.

## ◆ sse4_and_digest_5way()

bool bm::sse4_and_digest_5way | ( | __m128i *BMRESTRICT | dst,
|  | const __m128i *BMRESTRICT | src1,
|  | const __m128i *BMRESTRICT | src2,
|  | const __m128i *BMRESTRICT | src3,
|  | const __m128i *BMRESTRICT | src4
| ) |  |
| inline

AND block digest stride.

Returns
  true if stide is all zero

Definition at line 379 of file bmsse4.h.

## ◆ sse4_bit_count()

bm::id_t bm::sse4_bit_count | ( | const __m128i * | block,
|  | const __m128i * | block_end
| ) |  |
| inline

SSE4.2 optimized bitcounting .

Definition at line 78 of file bmsse4.h.

## ◆ sse4_block_set_digest()

void bm::sse4_block_set_digest | ( | __m128i * | dst,
|  | unsigned | value
| ) |  |
| inline

set digest stride to 0xFF.. or 0x0 value

Definition at line 219 of file bmsse4.h.

## ◆ sse4_gap_find()

unsigned bm::sse4_gap_find | ( | const bm::gap_word_t *BMRESTRICT | pbuf,
|  | const bm::gap_word_t | pos,
|  | const unsigned | size
| ) |  |
| inline

SSE4.2 check for one to two (variable len) 128 bit SSE lines for gap search results (8 elements)

Definition at line 993 of file bmsse4.h.

References BM_ASSERT, and BMRESTRICT.

Referenced by bm::sse42_gap_bfind().

## ◆ sse4_is_all_one()

bool bm::sse4_is_all_one | ( | const __m128i *BMRESTRICT | block | ) |
| inline

check if block is all zero bits

Definition at line 559 of file bmsse4.h.

References BMRESTRICT, and bm::set_block_size.

## ◆ sse4_is_all_zero()

bool bm::sse4_is_all_zero | ( | const __m128i *BMRESTRICT | block | ) |
| inline

check if block is all zero bits

Definition at line 175 of file bmsse4.h.

References BMRESTRICT, and bm::set_block_size.

## ◆ sse4_is_digest_zero()

bool bm::sse4_is_digest_zero | ( | const __m128i *BMRESTRICT | block | ) |
| inline

check if digest stride is all zero bits

Definition at line 200 of file bmsse4.h.

## ◆ sse4_lower_bound_scan_u32()

unsigned bm::sse4_lower_bound_scan_u32 | ( | const unsigned *BMRESTRICT | arr,
|  | unsigned | target,
|  | unsigned | from,
|  | unsigned | to
| ) |  |
| inline

lower bound (great or equal) linear scan in ascending order sorted array

Definition at line 1154 of file bmsse4.h.

References BMRESTRICT.

## ◆ sse4_sub_digest()

bool bm::sse4_sub_digest | ( | __m128i *BMRESTRICT | dst,
|  | const __m128i *BMRESTRICT | src
| ) |  |
| inline

SUB (AND NOT) block digest stride dst &= ~*src.

Returns
  true if stide is all zero

Definition at line 462 of file bmsse4.h.

## ◆ sse4_sub_digest_2way()

bool bm::sse4_sub_digest_2way | ( | __m128i *BMRESTRICT | dst,
|  | const __m128i *BMRESTRICT | src1,
|  | const __m128i *BMRESTRICT | src2
| ) |  |
| inline

2-operand SUB (AND NOT) block digest stride dst = src1 & ~*src2

Returns
  true if stide is all zero

Definition at line 511 of file bmsse4.h.