Multi-Dimensional Array Access Order Pitfalls

Accessing 2D arrays against their native storage order (e.g., column-major access on a row-major array in C/C++) creates large, detrimental strides that bypass cache locality, causing repeated cache misses and significantly slowing down execution. Modern CPUs' prefetchers, optimized for sequential access, are often defeated by these large strides.

Sources

Open the full topic