3 ms·
Quickly identifying a sequence of digits in a string of characters
- BeeOnRope 8y agoSWAR approaches are pretty awesome. They are the poor man's SIMD, and are even useful in combination with SIMD: especially on GPU where you often don't have byte or 16-bit operations in the first place: you can "roll your own" with SWAR rather than just extending every element to 32-bits. I recommend the classic bithacks page: https://graphics.stanford.edu/~seander/bithacks.html https://graphics.stanford.edu/~seander/bithacks.html as a good source, once you work your way through a few of these examples the basic approaches (using carries to check multiple bits, using multiplications as broadcasts, using shits as mini-lookup tables, etc) become clear.