-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for bit packing and unpacking operations (PEXT, PDEP) #93
Comments
Right now, SIMD.jl provides an interface to the LLVM vector intrinsics (in https://github.com/eschnett/SIMD.jl/blob/master/src/LLVM_intrinsics.jl), and a The advantage to this is that it keeps the package to a reasonable size (there are many many architecture-specific intrinsics https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html), it means the same functionality is provided for everyone and it avoids non-trivial things like runtime architecture detection. Compilers are usually quite good at pattern matching operations to intrinsics if they are available. Does this not happen here? |
Ok. According to llvm.org for SIMD.jl we have
I found a discourse discussion from 2017 describing how to get this feature pdep(x::UInt32, y::UInt32) = ccall("llvm.x86.bmi.pdep.32", llvmcall, UInt32, (UInt32, UInt32), x, y)
pdep(x::UInt64, y::UInt64) = ccall("llvm.x86.bmi.pdep.64", llvmcall, UInt64, (UInt64, UInt64), x, y)
pext(x::UInt32, y::UInt32) = ccall("llvm.x86.bmi.pext.32", llvmcall, UInt32, (UInt32, UInt32), x, y)
pext(x::UInt64, y::UInt64) = ccall("llvm.x86.bmi.pext.64", llvmcall, UInt64, (UInt64, UInt64), x, y) but since it lives in There are bit manipulation intrinsics
but none of them matches this kind of packing-operation. Thank you for the clarification. Maybe this comes with future versions of LLVM. PS: I was not able to write code in a way that produce these architecture-specific operations. |
Hi,
I have stumbled upon the Parallel bit deposit and extract operations pext and pdep of the X86 Bit manipulation instruction set (BMI). This might not be directly related to SIMD, but since these instructions are quite useful as horizontal operations, it seems a good fit for SIMD.jl
Is there (already) any way to use these assembly instructions from within Julia?
Example:
In the special case of
Vec{N,Bool}
this could be achieved with some bit-twiddling using a single integer multiplication and only scalar bit operations to move the bitsThis...
...is in favor of an alternative with a hierarchical reduction; either with vector operations...
...or without...
Is there some Julia-package already providing such functionality?
kind regards,
Christian
PS: There are several variants I came up with to illustrate this on
Vec{8,Bool}
.The text was updated successfully, but these errors were encountered: