4 ms·
I've never thought of a micro-lookup-table! That's cool. What have you used those for?
by mithametacs 2y ago
I've never thought of a micro-lookup-table!
That's cool. What have you used those for?
- ack_complete 2y agoTypically just like conventional lookup tables, where you can get the table size down small enough. Indexed palette / quantization coding is a case where this can often work. It's pretty niche given the limitations, but if you can make it work it's often a major speedup since you're able to do 16/32/64 lookups in parallel.
- glangdale 2y agoNot OP, but we use these tables all the time in Hyperscan (for string and character class matching) and it's a long-standing technique to use it for things like SIMD population count (obsoleted now if you have the right AVX-512 ISA, ofc).
- anonymoushn 2y agoYou can test whether a register full of bytes belong to a class of bytes with the high bit unset and distinct lower nibbles in 2 instructions (each with 1 cycle latency). For example the characters that commonly occur in text and must be escaped in json are "\"\\\r\n\t" (5 different bytes). Their lower nibbles are: \": 0010 \t: 1001 \n: 1010 \\: 1100 \r: 1101 Since there are no duplicate lower nibbles, we can test for membership in this set in 2 instructions. If we want to get the value into a general-purpose register and branch on whether it's 0 or not, that's 2 more instructions. For larger sets or sets determined at runtime, see here: http://0x80.pl/notesen/2018-10-18-simd-byte-lookup.html http://0x80.pl/notesen/2018-10-18-simd-byte-lookup.html