CUDA Shared Memory Layout Visualization

Memory Layout Formulas

Dual-Access Layout

address = m + i × M + j × stride + w × (D × stride - padding)
where M = floor(32/D)
padding = (M - (M×D % 32)) % 32
stride = M×D + padding
Warp size = D × stride - padding
Total cells per warp (including padding)

Single-Access Layout

Elements stored in (matrix, column, row) order
Padding every div(32, gcd(32, D)) columns
Final padding added to match dual-access warp size

Dual-Access Layout

Columns = the 32 shared-memory banks.  Rows = 32-element memory lines.  A bank conflict occurs when threads in the same warp access different cells within the same column.

Single-Access Layout

Columns = the 32 shared-memory banks.  Rows = 32-element memory lines.