Prepare matrix A for multiplication

Packing changes the order of values in memory so that a matrix multiplication kernel can load those values more efficiently. The following visualization loads Input Matrix A values into rows of ZA, and writes columns of ZA into Output Packed Data. Packing changes the layout of data, but it doesn’t calculate the matrix product.

To keep this Learning Path open while exploring, open the Pack A visualization in a separate browser tab. Move the tab to a separate window to view the visualization and Learning Path side by side.

Follow the transpose and pack algorithm

Select the play button or advance manually to follow the algorithm:

StageNumber of stepsOperation
Load matrix A10Load Input Matrix A into rows of ZA0–ZA2.
Store packed data8Write full columns of ZA data into rows of Output Packed Data.
Pad the final rows4Write zero-padded columns of ZA data into rows of Output Packed Data. The zero-padding happens because the rows of Input Matrix A aren’t an exact multiple of the ZA tile height.

During matrix A load, predicates determine which rows are active, which in turn determines the elements of Output Packed Data that are zero-padded.

 

What you’ve learned and what’s next

You’ve traced a change in the memory layout of matrix A. The packed General Matrix Multiplication (GEMM) visualization begins with this kind of prepared A data.

The preprocessing example in the SME2 matrix multiplication Learning Path shows how a C kernel prepares its left-hand matrix. Its precise layout belongs to that implementation.

Next, you’ll view a visualization that prepares the other operand for the GEMM visualization, matrix B.