Matrix multiplication

Open discussion for MAGMA

Matrix multiplication

Postby luiceur » Tue Jul 10, 2012 9:48 am

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?
Posts: 26
Joined: Tue Jul 10, 2012 4:38 am

Re: Matrix multiplication

Postby Stan Tomov » Tue Jul 10, 2012 1:05 pm

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 Tomov
Posts: 248
Joined: Fri Aug 21, 2009 10:39 pm

Return to User discussion

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests