Question regarding lzcnt and blsr

13 views
Skip to first unread message

Rohan Aggarwal

unread,
Sep 25, 2023, 2:54:12 PM9/25/23
to Roaring Bitmaps
Hi I was searching thriugh the library and i do not see usages of lzcnt and blsr. I see a lot of uses of popcnt. Is this understanding correct ?

[rohaagga_croaring croaring]$ grep -R lzcnt
grep: .ade_path: No such file or directory
grep: include/.ade_path: No such file or directory
grep: include/roaring/.ade_path: No such file or directory
grep: include/roaring/bitset/.ade_path: No such file or directory
grep: include/roaring/containers/.ade_path: No such file or directory
grep: include/roaring/misc/.ade_path: No such file or directory
include/roaring/portability.h:#include <lzcntintrin.h> // for  __lzcnt64
include/roaring/portability.h:// On 32-bit x86, we lack 64-bit popcnt, lzcnt, blsr instructions.
include/roaring/portability.h:#define CROARING_TARGET_AVX2 CROARING_TARGET_REGION("avx2,bmi,pclmul,lzcnt,popcnt")
include/roaring/portability.h:#define CROARING_TARGET_AVX512 CROARING_TARGET_REGION("avx2,bmi,bmi2,pclmul,lzcnt,popcnt,avx512f,avx512dq,avx512bw,avx512vbmi2,avx512bitalg,avx512vpopcntdq")
grep: src/.ade_path: No such file or directory
grep: src/containers/.ade_path: No such file or directory


rohaagga_croaring croaring]$ grep -R blsr
grep: .ade_path: No such file or directory
grep: include/.ade_path: No such file or directory
grep: include/roaring/.ade_path: No such file or directory
grep: include/roaring/bitset/.ade_path: No such file or directory
grep: include/roaring/containers/.ade_path: No such file or directory
grep: include/roaring/misc/.ade_path: No such file or directory
include/roaring/portability.h:#include <bmiintrin.h>   // for _blsr_u64
include/roaring/portability.h:// unfortunately, we may not get _blsr_u64, but, thankfully, clang
include/roaring/portability.h:#ifndef _blsr_u64
include/roaring/portability.h:#define _blsr_u64(n) ((n - 1) & n)
include/roaring/portability.h:#endif //  _blsr_u64
include/roaring/portability.h:// On 32-bit x86, we lack 64-bit popcnt, lzcnt, blsr instructions.
grep: src/.ade_path: No such file or directory
grep: src/containers/.ade_path: No such file or directory

Daniel Lemire

unread,
Sep 25, 2023, 5:02:43 PM9/25/23
to Rohan Aggarwal, Roaring Bitmaps
If you want to know whether a library uses a given processor instruction, I recommend compiling it to assembly and then searching for the corresponding instruction in the assembly output, given your target architecture and chosen compiler.

--
You received this message because you are subscribed to the Google Groups "Roaring Bitmaps" group.
To unsubscribe from this group and stop receiving emails from it, send an email to roaring-bitma...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/roaring-bitmaps/016be822-b571-4b94-b2f3-f4765ad09d65n%40googlegroups.com.

Rohan Aggarwal

unread,
Sep 25, 2023, 5:12:17 PM9/25/23
to lem...@gmail.com, Roaring Bitmaps
I am trying to understand something different. We are also having a parallel discussion on using ICC on github. Due to constraints, I cannot use ICX until next year. I am trying to understand by disabling the target region pragmas, am I missing some optimization? My understanding of the target region pragmas is that it is telling the compiler the next section can contain code that uses blsr instruction and not that the following code needs to be optimized using the blsr instruction. Hence I was trying to look in the code where you call blsr inside the target region.

Daniel Lemire

unread,
Sep 25, 2023, 5:33:33 PM9/25/23
to Rohan Aggarwal, Roaring Bitmaps
If you are modifying the library then the result is unsupported and could be inefficient or wrong. You can modify the code to suit your own needs but it is to you to support the result.
Reply all
Reply to author
Forward
0 new messages