In this article
A leading dimension moves within a stored matrix; a batch stride moves to another matrix and need not equal the logical matrix element count.
Draw the stored matrix before the multiplication
A wrapper combines padded matrices into a strided batch and sets every stride from logical dimensions. The rocBLAS GEMM reference distinguishes leading dimensions from matrix-to-matrix strides. Start with the actual storage diagram, including padding. The mathematical dimensions of the multiplication describe the operation; they do not by themselves establish how the next column or next matrix is reached in memory.
Keep transpose interpretation separate from allocation
The HIP programming-model guide explains rocBLAS column-major expectations and row-major interpretation. A transpose flag changes how an operand participates in the operation; it does not physically repack its allocation. Derive leading dimensions from the stored representation for the selected operation. A square, tightly packed demonstration can conceal a wrong assumption because several different size expressions happen to produce the same offset.
Derive the batch jump independently
The rocBLAS datatype reference defines rocblas_stride for strided-batched interfaces. Compute the jump between matrix starts using the actual layout and the interface’s element-based convention, not an unexamined byte count. Padding, a larger surrounding allocation or deliberately separated matrices can make the batch jump differ from the product of logical dimensions. Keep input and output jumps independent. An output batch that overlaps unintentionally can corrupt another result even if individual GEMM arithmetic is correct.
Choose pointer-array batching when appropriate
Strided batching describes a regular relationship between starts. If matrices have irregular addresses, do not force them into that representation by selecting a stride that fits only the first pair. Inspect the appropriate pointer-array batched interface and its device-memory requirements instead. Neither form automatically validates matrix lifetime, handle stream association or shape compatibility. The wrapper should expose its chosen layout contract rather than accept arbitrary tensor views and hope the library infers their storage.
Validate non-square padded examples
Compare a batch of deliberately different matrices against a simple reference, using non-square dimensions and explicit padding. Check every output matrix and preserve untouched padding where required by the fixture. Related guides on HIP portability and reproducible environments provide context. This acceptance establishes storage interpretation for the tested interface. It is distinct from scalar pointer mode, workspace configuration and algorithm tuning, which cannot repair a fundamentally incorrect address map.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.