Quantcast
Channel: Bits, Math and Performance(?)
Browsing latest articles
Browse All 28 View Live

Image may be NSFW.
Clik here to view.

abs and its "extra" result

The abs function has, in its usual (most useful) formulation, one extra value in its codomain than just "all non-negative values". That extra value is the most negative integer, which satisfies abs(x)...

View Article


Square root of bitwise NOT

The square root of bitwise NOT, if it exists, would be some function f such that f(f(x)) = not x, or in other words, f²(x) = not x. It is similar in concept to the √NOT gate in Quantum Computing, but...

View Article


Information on incrementation

Defining incrementJust to avoid any confusion, the operation that this post is about is adding 1 (one) to a value: $$\text{increment}(x) = x + 1$$ Specifically, performing that operation in the domain...

View Article

Image may be NSFW.
Clik here to view.

Why does AND distribute over XOR

blockquote { background: #f9f9f9; border-left: 10px solid #ccc; margin: 1.5em 10px; padding: 0.5em 10px; quotes: "\201C""\201D""\2018""\2019"; } blockquote:before { color: #ccc; content: open-quote;...

View Article

The range a sum cannot fall within

.nobr { white-space: nowrap; } Throughout this post, the variables A, B, and R are used, with R defined as R = A + B, and A ≤ B. Arithmetic in this post is unsigned and modulo 2k. Note that A ≤ B is...

View Article


Partial sums of blsi and blsmsk

blsi is an x86 operation which extracts the rightmost set bit from a number, it can be implemented efficiently in terms of more familiar operations as i&-i. blsmsk is a closely related operation...

View Article

Integer promotion does not help performance

There is a rule in the C language which roughly says that arithmetic operations on short integer types implicitly convert their operands to normal-sized integers, and also give their result as a...

View Article

Bit-level commutativity and "sum gap" revisited

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } In an earlier post, bit-level commutativity, it was shown that addition is...

View Article


Weighted popcnt

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } Since I showed the code below on Twitter, and some people understood it...

View Article


Column-oriented row reduction

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } blockquote footer { background-color: #F5F5F5; clear: both; } blockquote:before { color: #ccc; content: open-quote;...

View Article

Image may be NSFW.
Clik here to view.

(Not) transposing a 16x16 bitmatrix

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } blockquote footer { background-color: #F5F5F5; clear: both; } blockquote:before { color: #ccc; content: open-quote;...

View Article

grevmul

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } blockquote footer { background-color: #F5F5F5; clear: both; } blockquote:before { color: #ccc; content: open-quote;...

View Article

Some ways to check whether an unsigned sum wraps

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } When computing x + y, does the sum wrap? There are various ways to find...

View Article


Propagating bounds through bitwise operations

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } blockquote footer { background-color: #F5F5F5; clear: both; } blockquote:before { color: #ccc; content: open-quote;...

View Article

Image may be NSFW.
Clik here to view.

Permuting bits with GF2P8AFFINEQB

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } It's no secret that GF2P8AFFINEQB can be tricky to think about, even in...

View Article


Partial sums of popcount

The partial sums of popcount, aka A000788: Total number of 1's in binary expansions of 0, ..., n can be computed fairly efficiently with some mysterious code found through its OEIS entry (see the link...

View Article

The solutions to 𝚙𝚘𝚙𝚌𝚗𝚝(𝚡)

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } popcnt(x) < tzcnt(x) asks the question "does x have fewer set bits than...

View Article


Image may be NSFW.
Clik here to view.

Enumerating all mathematical identities (in fixed-size bitvector arithmetic...

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } Once again a boring-but-specific title, I don't want to clickbait the...

View Article

Implementing grevmul with GF2P8AFFINEQB

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } As a reminder, grev is generalized bit-reversal, and performs a...

View Article

Multiplying 64x64 bit-matrices with GF2P8AFFINEQB

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } This is a relatively simple use of GF2P8AFFINEQB. By itself GF2P8AFFINEQB...

View Article

Sharpening a lower bound with KnownBits information

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } I have written about this before, but that was a long time ago, I've had a...

View Article


Sorting the nibbles of a u64

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } I was reminded (on mastodon) of this nibble-sorting technique (it could be...

View Article


Enumerating identities, part 2

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } Part 2 of Enumerating all mathematical identities (in fixed-size bitvector...

View Article

Image may be NSFW.
Clik here to view.

Histogramming bytes with positional popcount (GF2P8AFFINEQB edition)

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } A while ago, after some back and forth on twitter/X with @corsix, I...

View Article

Bit-permuting 16 u32s at once with AVX-512

.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } The basic trick to apply the same bit-permutation to each of the u32s is...

View Article

Browsing latest articles
Browse All 28 View Live