CPU optimized data structures - more fun with assembler
summary
Assembler implements a poker-hand evaluator that packs rank and suit into bytes, explodes 16-bit rank masks into nibble-aligned MMX lanes, and tests straights via shifted bitwise ANDs and BSR/BSF scans. It iterates ~1.7M community-card combos per matchup but reduces to 48,308 canonical combos by symmetry. Uses MMX SIMD instructions, bitmask per rank/suit layouts and packed saturated subtracts to detect pairs/trips/quads. Handwritten assembly initially outperforms naive C++ but an optimizing compiler closes the gap; debugging, alignment and calling-convention bugs cost time.
AI-written summary · about
chapters (19)
- 0:00Intro
- 2:06Poker
- 2:52Playing Cards
- 5:09Playing Poker
- 6:54The Problem
- 7:48Most Valuable Hand
- 11:14Poker Ranks
- 14:31Obvious Data Structure
- 15:07Array of Integers
- 15:55Data Structure
- 17:19Example
- 17:53Iterating
- 18:36assembler
- 25:33loop
- 28:47overhead
- 39:07bits can reverse
- 43:13four of a kind
- 44:49multicard explode
- 51:15px
related talks
55mUsing Integers as Arrays of Bitfields a.k.a. SWAR Techniques
46mWhat C and C++ can do and when do you need Assembly?
57mAdventures in SIMD-Thinking (part 1 of 2)
31m“Enough x86 Assembly to Be Dangerous”
01h 25mBluff your way in x64 assembler
53mCombining the incompatible, accelerating the unacceleratable, using Go assembler ☠️
54mx86 Internals for Fun & Profit
05mAlgorithm Magic
