Storing Matrices in Memory — Data Layout Visualizations

There are many ways in which matrices — two-dimensional entities — can be laid out in one-dimensional computer memory. This page visualizes different such data layouts. To read these graphs, start from the top left, and follow the colored line: This shows the order in which memory is accessed. Each small gray square is one byte. A solid colored line is a memory access; a dashed one is a jump to a different address. Adjust the wraps and strides to the right to explore different transformations.

Some examples: The two most common ways to linearize a matrix are row-major and column-major. Tiling, for example 4x4 row-major tiles, or 4x2 column-major tiles, can give better data locality.

×
×