title: Why Apple's Metal Matrix Multiplication Example needs padding C
body: <p>I'm learning Apple's <a href="https://developer.apple.com/metal/" rel="noreferrer">Metal</a> trying to do some GPU computation.</p>
  
  <p>I checked the <a href="https://developer.apple.com/library/content/samplecode/MetalPartialSumsCompute/Introduction/Intro.html#//apple_ref/doc/uid/TP40015013-Intro-DontLinkElementID_2" rel="noreferrer">matrix multiplication example</a> given by Apple. There's a point I cannot understand.</p>
  
  <p>In the file <a href="https://developer.apple.com/library/content/samplecode/MetalPartialSumsCompute/Listings/MetalMatrixMultiplication_MetalMatrixMult_h.html#//apple_ref/doc/uid/TP40015013-MetalMatrixMultiplication_MetalMatrixMult_h-DontLinkElementID_18" rel="noreferrer">MetalMatrixMult.h</a></p>
  
  <pre><code>// Number of rows in matrices A and C.
  @property (nonatomic) uint16_t m;
  
  // Number of columns in matrix A; number of rows in matrix B.
  @property (nonatomic) uint16_t n;
  
  // Number of columns in matrices B and C.
  @property (nonatomic) uint16_t k;
  
  // Output matrix (padded) C row count
  @property (nonatomic, readonly) uint16_t M;
  
  // Output matrix (padded) C column count
  @property (nonatomic, readonly) uint16_t K;
  
  // Output matrix C = A x B
  @property (nonatomic, readonly) float* output;
  </code></pre>
  
  <p>It says the Matrix C is padded. I'm not clear what <code>pad</code> means here. Is it some kind of alignment? Cause I know there are types alignment in Metal's shader language specification, but I don't know why we need to pad a buffer herer.</p>
  
  <p>Thanks.</p>