-
Notifications
You must be signed in to change notification settings - Fork 1
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
Bit reverse #8
base: master
Are you sure you want to change the base?
Bit reverse #8
Conversation
Byte reversal methodsSome interesting real-world tests using different approaches: Lookup tableA standard lookup table representing all combinations of 8 bits numbers is represented by As such, it more practical to use the more memory-efficient 4 bit flip table since we can easily fit into the given L1 cache line. This will come with a bit of a (hopefully negligible) performance hit since we have to compute the reverse for the 4-bit nibble on-the-fly. Is there a cache-oblivious implementation? According to Silvesteri, there does not exist an optimal cache-oblivious algorithm, but there might be a cache-aware one. VectorizedWhile a vectorized lookup, in practice, takes less time than a equivalent serial implementation, it requires AVX2 instructions. Recent Intel-based CPUs (after Haswell) have AVX2 instructions, so most devices should be supported. Despite this, it might not be as fast as the 4-bit lookup table. |
Description
Move every bit twice without using auxiliary memory. Again treating the string to be rotated as
ab
, observe the identity(a^R b^R)^R = ba
, whereR
is the operation that reverses a string. The “reverse” operation can be accomplished using only constant storage. Thus, with 3 reversals of bit strings, the string can be rotated.Checklist