## Matrix multiplication

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)

### Matrix multiplication

Say that you want to do a simple matrix multiplication in C:
Code: Select all
`#define rows 3#define cols 2 transA = MagmaTrans;  transB = MagmaNoTrans;for (i = 0; i < rows*cols; i++) {    h_A[i] = i;    printf("A[%d] = %f\n",i, h_A[i]);  }  magma_ssetmatrix( rows, cols, h_A, rows, d_A, rows );  magma_ssetmatrix( rows, rows, h_C, rows, d_C, rows );  magmablas_sgemm( transA, transB, rows, rows, rows, alpha, d_A, cols,         d_A, cols, beta,  d_C, cols);magma_sgetmatrix( rows, rows, d_C, rows, h_C2, rows );  for(i = 0; i< rows*rows; i++){    printf("C[%d] = %f\n",i, h_C2[i]);  }`

Why I am not getting the right results?
luiceur

Posts: 26
Joined: Tue Jul 10, 2012 4:38 am

### Re: Matrix multiplication

Double check the parameters (alpha, beta, transposes) and the initialization. I see you initialize 3x2 matrix A and multiply 3x3 matrices. I don't see also the matrix C being initialized.
Stan
Stan Tomov

Posts: 258
Joined: Fri Aug 21, 2009 10:39 pm