Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Parameter double **mat to cblas_dgemm

Fábio_A_
Beginner
579 Views

Dear Intel Forum,

I am developing a molecular dynamic system with a several MKL functions, the atoms position is a  double **mat to the mkl function like cblas_dgemm. However, is necessary to convert the pointer ** to *, like:

void mv(double** m,double* v)
{
int i = 0, j = 0,z = 0;

   for(i = 0; i < natom;i++)
   {
         for(j = 0; j < natom;j++)
          {
               v = m; z++;
          }
     }
}

Please, there is a way to use cblas_dgemm without this conversation ?

0 Kudos
3 Replies
TimP
Honored Contributor III
579 Views

No, cblas_dgemm() is simply a wrapper to dgemm() and so the data must be interoperable.

0 Kudos
Ying_H_Intel
Employee
579 Views

Hi Fabio, 

is the pointer of double **mat  point to a continuous memory?   If yes, then you don't need to change,  just feed the cblas_dgemm with 

cblas_dgemm(&m[0][0],  ...) 

it should be ok 

Best  Regards,

Ying 

Here is one sample: 

    A = (double *)mkl_malloc( m*k*sizeof( double ), 64 );

    B = (double *)mkl_malloc( k*n*sizeof( double ), 64 );
    C = (double *)mkl_malloc( m*n*sizeof( double ), 64 );
    if (A == NULL || B == NULL || C == NULL) {
      printf( "\n ERROR: Can't allocate memory for matrices. Aborting... \n\n");
      mkl_free(A);
      mkl_free(B);
      mkl_free(C);
      return 1;
    }

    printf (" Intializing matrix data \n\n");
    for (i = 0; i < (m*k); i++) {
        A = (double)(i+1);
    }

    for (i = 0; i < (k*n); i++) {
        B = (double)(-i-1);
    }

    for (i = 0; i < (m*n); i++) {
        C = 0.0;
    }

    printf (" Computing matrix product using Intel® MKL dgemm function via CBLAS interface \n\n");
    cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 
                m, n, k, alpha, A, k, B, n, beta, C, n);
0 Kudos
Fábio_A_
Beginner
579 Views

Thank you for the reply.
Is point to a continuous memory, i tried this solution, but the solution in different when i use this solution, even with Row ou Col major...

0 Kudos
Reply