Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Fábio_A_
Beginner
88 Views

Parameter double **mat to cblas_dgemm

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
Black Belt
88 Views

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

Ying_H_Intel
Employee
88 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);
Fábio_A_
Beginner
88 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...

Reply