Why Apple Matrix Multiplication Example Requires Filling C

I am studying Apple Metal , trying to do some GPU computing.

I checked the matrix multiplication example given by Apple. I can’t understand there.

In the file MetalMatrixMult.h

// 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;

It says that matrix C is full. I do not quite understand what it means pad. Is this some kind of alignment? The reason I know there is a type specification in the shader language specification, but I don't know why we need to impose a buffer herer.

Thank.

+4
source share
1 answer

. , ( ), . GPU, .

, 3 (A, B C) , , "" . , C , 8 x 8 : Threadgroup 1 , . Threadgroup 1 8 A 8 B C. , Threadgroup 1, .

, , , C . 12 x 18, - 8 x 8, , C 1,5 x 2,25 . , - 2 x 3 16 x 24 . .

+2

Source: https://habr.com/ru/post/1673436/


All Articles